-rw-r--r-- | microkde/kutils/kcmultidialog.cpp | 7 | ||||
-rw-r--r-- | microkde/kutils/kcmultidialog.h | 2 |
2 files changed, 7 insertions, 2 deletions
diff --git a/microkde/kutils/kcmultidialog.cpp b/microkde/kutils/kcmultidialog.cpp index 6c82e4f..e7aa9d1 100644 --- a/microkde/kutils/kcmultidialog.cpp +++ b/microkde/kutils/kcmultidialog.cpp @@ -1,202 +1,205 @@ /* Copyright (c) 2000 Matthias Elter <elter@kde.org> Copyright (c) 2003 Daniel Molkentin <molkentin@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <qhbox.h> #include <qvbox.h> #include <qcursor.h> #include <qlayout.h> #include <klocale.h> #include <kglobal.h> #include <kdebug.h> #include <kiconloader.h> #include <kmessagebox.h> //US #include <klibloader.h> #include <krun.h> #include <kprocess.h> #include "kcmultidialog.h" //US #include "kcmultidialog.moc" //US #include "kcmoduleloader.h" KCMultiDialog::KCMultiDialog(const QString& baseGroup, QWidget *parent, const char *name, bool modal) : KDialogBase(IconList, i18n("Configure"), Default |Cancel | Apply | Ok, Ok, parent, name, modal, true), d(0L) { enableButton(Apply, false); //connect(this, SIGNAL(aboutToShowPage(QWidget *)), this, SLOT(slotAboutToShow(QWidget *))); connect( this, SIGNAL( defaultClicked() ), SLOT( slotDefault() ) ); _baseGroup = baseGroup; mMainWidget = new KJanusWidget( this, "JanusWidget", KJanusWidget::Tabbed ); setMainWidget(mMainWidget ); #ifdef DESKTOP_VERSION resize(640,480); #else resize(640,480); setMaximumSize( KMIN(KGlobal::getDesktopWidth()-5, 640), KMIN(KGlobal::getDesktopHeight()-20, 480)); //showMaximized(); #endif } KCMultiDialog::~KCMultiDialog() { //US moduleDict.setAutoDelete(true); } void KCMultiDialog::slotDefault() { int curPageIndex = mMainWidget->activePageIndex(); QPtrListIterator<KCModule> it(modules); for (; it.current(); ++it) { if (pageIndex((QWidget *)(*it)->parent()) == curPageIndex) { (*it)->defaults(); clientChanged(true); return; } } } - +void KCMultiDialog::accept() +{ + slotOk(); +} void KCMultiDialog::slotApply() { qDebug("KCMultiDialog::slotApply clicked"); QPtrListIterator<KCModule> it(modules); for (; it.current(); ++it) (*it)->save(); clientChanged(false); emit applyClicked(); } void KCMultiDialog::slotOk() { qDebug("KCMultiDialog::slotOk clicked"); QPtrListIterator<KCModule> it(modules); for (; it.current(); ++it) (*it)->save(); - accept(); + QDialog::accept(); emit okClicked(); } void KCMultiDialog::slotHelp() { /*US KURL url( KURL("help:/"), _docPath ); if (url.protocol() == "help" || url.protocol() == "man" || url.protocol() == "info") { KProcess process; process << "khelpcenter" << url.url(); process.start(KProcess::DontCare); process.detach(); } else { new KRun(url); } */ } void KCMultiDialog::clientChanged(bool state) { enableButton(Apply, state); } /*US void KCMultiDialog::addModule(const QString& path, bool withfallback) { kdDebug(1208) << "KCMultiDialog::addModule " << path << endl; KCModuleInfo info(path, _baseGroup); QHBox* page = addHBoxPage(info.moduleName(), info.comment(), KGlobal::iconLoader()->loadIcon(info.icon(), KIcon::Desktop, KIcon::SizeMedium)); if(!page) { KCModuleLoader::unloadModule(info); return; } moduleDict.insert(page, new LoadInfo(path, withfallback)); if (modules.isEmpty()) slotAboutToShow(page); } */ QVBox * KCMultiDialog::getNewVBoxPage( const QString & modulename ) { QVBox *page = mMainWidget->addVBoxPage(modulename , QString::null,QPixmap() ); return page; } //US special method for microkde. We dop noty want to load everything dynamically. void KCMultiDialog::addModule(KCModule* module ) //, const QString& modulename, const QString& iconname) { modules.append(module); connect(module, SIGNAL(changed(bool)), this, SLOT(clientChanged(bool))); //US module->load(); } void KCMultiDialog::slotAboutToShow(QWidget *page) { /*US LoadInfo *loadInfo = moduleDict[page]; if (!loadInfo) return; QApplication::setOverrideCursor(Qt::WaitCursor); moduleDict.remove(page); KCModuleInfo info(loadInfo->path, _baseGroup); KCModule *module = KCModuleLoader::loadModule(info, loadInfo->withfallback); if (!module) { QApplication::restoreOverrideCursor(); KCModuleLoader::showLastLoaderError(this); delete loadInfo; return; } module->reparent(page,0,QPoint(0,0),true); connect(module, SIGNAL(changed(bool)), this, SLOT(clientChanged(bool))); //setHelp( docpath, QString::null ); _docPath = info.docPath(); modules.append(module); //KCGlobal::repairAccels( topLevelWidget() ); delete loadInfo; QApplication::restoreOverrideCursor(); diff --git a/microkde/kutils/kcmultidialog.h b/microkde/kutils/kcmultidialog.h index 1aa66b2..768faea 100644 --- a/microkde/kutils/kcmultidialog.h +++ b/microkde/kutils/kcmultidialog.h @@ -19,128 +19,130 @@ */ #ifndef KCMULTIDIALOG_H #define KCMULTIDIALOG_H #include <qptrlist.h> #include <qptrdict.h> #include <kdialogbase.h> #include <kjanuswidget.h> #include <kcmodule.h> /** * A class that offers a @ref KDialogBase containing arbitrary KControl Modules * * @short A method that offers a @ref KDialogBase containing arbitrary * KControl Modules. * * @author Matthias Elter <elter@kde.org>, Daniel Molkentin <molkentin@kde.org> * @since 3.2 */ class KCMultiDialog : public KDialogBase { Q_OBJECT public: /** * Constructs a new KCMultiDialog * * @param parent The parent Widget * @param name The widget name * @param baseGroup The baseGroup, if you want to call a module out of * kcontrol, just keep "settings" * @param modal If you pass true here, the dialog will be modal **/ KCMultiDialog(const QString& baseGroup = QString::fromLatin1("settings"), QWidget *parent=0, const char *name=0, bool modal=false); /** * Destructor **/ virtual ~KCMultiDialog(); /** * Add a module. * * @param module Specify the name of the module that is to be added * to the list of modules the dialog will show. * * @param withfallback Try harder to load the module. Might result * in the module appearing outside the dialog. **/ //US void addModule(const QString& module, bool withfallback=true); //US special method for microkde. We dop noty want to load everything dynamically. void addModule(KCModule* module );//, const QString& modulename, const QString& iconname); QVBox* getNewVBoxPage(const QString & modulename) ; protected slots: /** * This slot is called when the user presses the "Default" Button * You can reimplement it if needed. * * @note Make sure you call the original implementation! **/ virtual void slotDefault(); /** * This slot is called when the user presses the "Apply" Button * You can reimplement it if needed * * @note Make sure you call the original implementation! **/ virtual void slotApply(); /** * This slot is called when the user presses the "OK" Button * You can reimplement it if needed * * @note Make sure you call the original implementation! **/ virtual void slotOk(); /** * This slot is called when the user presses the "Help" Button * You can reimplement it if needed * * @note Make sure you call the original implementation! **/ virtual void slotHelp(); + void accept(); + private slots: void slotAboutToShow(QWidget *); void clientChanged(bool state); private: /*US struct LoadInfo { LoadInfo(const QString &_path, bool _withfallback) : path(_path), withfallback(_withfallback) { } QString path; bool withfallback; }; */ QPtrList<KCModule> modules; /* QPtrDict<LoadInfo> moduleDict; QString _docPath; */ QString _baseGroup; //US KJanusWidget* mMainWidget; // For future use class KCMultiDialogPrivate; KCMultiDialogPrivate *d; }; #endif //KCMULTIDIALOG_H |