KNewStuff
knewstuffbutton.cpp
Go to the documentation of this file.
00001 /* 00002 knewstuff3/ui/knewstuffbutton.cpp. 00003 Copyright (c) 2004 Aaron J. Seigo <aseigo@kde.org> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Lesser General Public 00007 License as published by the Free Software Foundation; either 00008 version 2.1 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Lesser General Public License for more details. 00014 00015 You should have received a copy of the GNU Lesser General Public 00016 License along with this library. If not, see <http://www.gnu.org/licenses/>. 00017 */ 00018 00019 #include "knewstuffbutton.h" 00020 00021 #include <kiconloader.h> 00022 #include <klocale.h> 00023 #include <kicon.h> 00024 #include "downloaddialog.h" 00025 00026 namespace KNS3 00027 { 00028 class Button::Private { 00029 public: 00030 QString configFile; 00031 }; 00032 00033 Button::Button(const QString& text, 00034 const QString& configFile, 00035 QWidget* parent) 00036 : KPushButton(parent), 00037 d(new Private) 00038 { 00039 setButtonText(text); 00040 d->configFile = configFile; 00041 init(); 00042 } 00043 00044 Button::Button(QWidget* parent) 00045 : KPushButton(parent), 00046 d(new Private) 00047 { 00048 setButtonText(i18n("Download New Stuff...")); 00049 init(); 00050 } 00051 00052 Button::~Button() 00053 { 00054 delete d; 00055 } 00056 00057 void Button::init() 00058 { 00059 setIcon(KIcon("get-hot-new-stuff")); 00060 connect(this, SIGNAL(clicked()), SLOT(showDialog())); 00061 } 00062 00063 void Button::setButtonText(const QString& what) 00064 { 00065 setText(what); 00066 } 00067 00068 void Button::setConfigFile(const QString& configFile) 00069 { 00070 d->configFile = configFile; 00071 } 00072 00073 void Button::showDialog() 00074 { 00075 emit aboutToShowDialog(); 00076 00077 DownloadDialog dialog(d->configFile, this); 00078 dialog.exec(); 00079 00080 emit dialogFinished(dialog.changedEntries()); 00081 } 00082 00083 } 00084 00085 #include "knewstuffbutton.moc"
KDE 4.6 API Reference