00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
#include <kiconloader.h>
00021
#include <klocale.h>
00022
00023
#include "downloaddialog.h"
00024
#include "knewstuffbutton.h"
00025
#include "knewstuffbutton.moc"
00026
00027
namespace KNS
00028 {
00029
00030 Button::Button(
const QString& what,
00031
const QString& providerList,
00032
const QString& resourceType,
00033
QWidget* parent,
const char* name)
00034 : KPushButton(parent, name),
00035 d(0),
00036 m_providerList(providerList),
00037 m_type(resourceType),
00038 m_downloadDialog(0)
00039 {
00040 setButtonText(what);
00041 init();
00042 }
00043
00044 Button::Button(
QWidget* parent,
const char* name)
00045 : KPushButton(parent, name),
00046 d(0),
00047 m_downloadDialog(0)
00048 {
00049 setButtonText(i18n(
"Download New Stuff"));
00050 init();
00051 }
00052
00053
void Button::init()
00054 {
00055 setIconSet(SmallIconSet(
"knewstuff"));
00056 connect(
this, SIGNAL(clicked()), SLOT(showDialog()));
00057 }
00058
00059
void Button::setButtonText(
const QString& what)
00060 {
00061 setText(i18n(
"Download New %1").arg(what));
00062 }
00063
00064
void Button::setProviderList(
const QString& providerList)
00065 {
00066 m_providerList = providerList;
00067 }
00068
00069
void Button::setResourceType(
const QString& resourceType)
00070 {
00071 m_type = resourceType;
00072 }
00073
00074
void Button::showDialog()
00075 {
00076 emit aboutToShowDialog();
00077
00078
if (!m_downloadDialog)
00079 {
00080 m_downloadDialog =
new DownloadDialog(0,
this);
00081 }
00082
00083 m_downloadDialog->setType(m_type);
00084 m_downloadDialog->load(m_providerList);
00085
00086 m_downloadDialog->exec();
00087 emit dialogFinished();
00088 }
00089
00090 }