--Boundary-00=_kMQVAQcIHHTbQDj Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit Content-Disposition: inline Attached patch tries to port the KCMultiDialog to the new KCModuleProxy. The dialog should work out of the box with the KCModuleProxy, unfortunately that is not the case, the problem discussed below. (of course, root support needs patching) I get a crash on this: void KCMultiDialog::slotAboutToShow(QWidget *page) {     kdDebug( 710 ) << k_funcinfo << endl;     // honor KCModule::buttons     QObject * obj = page->child( 0, "KCModuleProxy" );     if( ! obj )         return;     d->currentModule = ( KCModuleProxy* )obj->qt_cast( "KCModuleProxy" ); //<--crash And with my crippled c++/qt knowledge I can't tell why that does not work nor what possible changes have broken it. Why doesn't the code read "d->currentModule = (KCModuleProxy *) page;"? (but that crashes just as fine) Further, I have some miscellaneous questions: * My patch contains the following section: @ -63,16 +75,17 @@ KCMultiDialog::KCMultiDialog( int dialog          const KGuiItem &user3, int buttonMask, const QString &caption,          QWidget *parent, const char *name, bool modal )      : KDialogBase( dialogFace, caption, buttonMask | Help | Default | Cancel | -            Apply | Ok | User1, Ok, parent, name, modal, true, -            KGuiItem( i18n( "&Reset" ), "undo" ), user2, user3 ) -    , dialogface( dialogFace ) +            Apply | Ok | User1 | User2 | User3, Ok, parent, name, modal, true, +            KStdGuiItem::reset(), KStdGuiItem::adminMode(), user3 ) +    , dialogface( dialogFace ), d( new KCMultiDialogPrivate() ) I've ran out of custom buttons in kdialogbase :) Three is allowed. reset() and adminMode() is needed for internal purposes and the user is allowed to pass two - that's four in total. Any ideas what to do in this situation? * What does the @internal doxygen tag mean in KDE context? * $KDEDIRS is preferred in front of $KDEDIR, AFAICT. Will KDEDIR be deprecated for KDE4? * Is $KDETMP fully supported and an "official" feature? Cheers, Frans --Boundary-00=_kMQVAQcIHHTbQDj Content-Type: text/x-diff; charset="iso-8859-1"; name="kcmultidialog.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="kcmultidialog.diff" Index: kutils/kcmultidialog.cpp =================================================================== RCS file: /home/kde/kdelibs/kutils/kcmultidialog.cpp,v retrieving revision 1.51 diff -u -3 -p -r1.51 kcmultidialog.cpp --- kutils/kcmultidialog.cpp 24 Jan 2004 20:28:02 -0000 1.51 +++ kutils/kcmultidialog.cpp 14 Mar 2004 23:43:24 -0000 @@ -2,6 +2,7 @@ Copyright (c) 2000 Matthias Elter Copyright (c) 2003 Daniel Molkentin Copyright (c) 2003 Matthias Kretz + Copyright (c) 2004 Frans Englich This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -24,6 +25,7 @@ #include #include +#include #include #include #include @@ -39,23 +41,33 @@ #include #include +class KCMultiDialog::KCMultiDialogPrivate +{ + public: + KCMultiDialogPrivate() + : hasRootKCM( false ), currentModule( 0 ) + + {} + bool hasRootKCM; + KCModuleProxy* currentModule; +}; + + KCMultiDialog::KCMultiDialog(QWidget *parent, const char *name, bool modal) : KDialogBase(IconList, i18n("Configure"), Help | Default |Cancel | Apply | - Ok | User1, Ok, parent, name, modal, true, - KGuiItem( i18n( "&Reset" ), "undo" ) ) - , dialogface( IconList ) + Ok | User1 | User2, Ok, parent, name, modal, true, + KStdGuiItem::reset(), KStdGuiItem::adminMode()) + , dialogface( IconList ), d( new KCMultiDialogPrivate() ) { - showButton( User1, false );; init(); } KCMultiDialog::KCMultiDialog( int dialogFace, const QString & caption, QWidget * parent, const char * name, bool modal ) : KDialogBase( dialogFace, caption, Help | Default | Cancel | Apply | Ok | - User1, Ok, parent, name, modal, true, - KGuiItem( i18n( "&Reset" ), "undo" ) ) - , dialogface( dialogFace ) + User1 | User2, Ok, parent, name, modal, true, + KStdGuiItem::reset(), KStdGuiItem::adminMode()) + , dialogface( dialogFace ), d( new KCMultiDialogPrivate() ) { - showButton( User1, false );; init(); } @@ -63,16 +75,17 @@ KCMultiDialog::KCMultiDialog( int dialog const KGuiItem &user3, int buttonMask, const QString &caption, QWidget *parent, const char *name, bool modal ) : KDialogBase( dialogFace, caption, buttonMask | Help | Default | Cancel | - Apply | Ok | User1, Ok, parent, name, modal, true, - KGuiItem( i18n( "&Reset" ), "undo" ), user2, user3 ) - , dialogface( dialogFace ) + Apply | Ok | User1 | User2 | User3, Ok, parent, name, modal, true, + KStdGuiItem::reset(), KStdGuiItem::adminMode(), user3 ) + , dialogface( dialogFace ), d( new KCMultiDialogPrivate() ) { - showButton( User1, false );; init(); } inline void KCMultiDialog::init() { + showButton( User1, false ); + showButton( User2, false ); d = 0L; enableButton(Apply, false); connect(this, SIGNAL(aboutToShowPage(QWidget *)), this, SLOT(slotAboutToShow(QWidget *))); @@ -197,7 +210,6 @@ void KCMultiDialog::clientChanged(bool s void KCMultiDialog::addModule(const QString& path, bool withfallback) { - kdDebug(710) << "KCMultiDialog::addModule " << path << endl; KService::Ptr s = KService::serviceByStorageId(path); if (!s) { @@ -212,6 +224,7 @@ void KCMultiDialog::addModule(const QStr void KCMultiDialog::addModule(const KCModuleInfo& moduleinfo, QStringList parentmodulenames, bool withfallback) { + kdDebug(710) << "KCMultiDialog::addModule " << moduleinfo.moduleName() << endl; @@ -274,12 +287,19 @@ void KCMultiDialog::addModule(const KCMo connect(module, SIGNAL(changed(bool)), this, SLOT(clientChanged(bool))); if( m_modules.count() == 0 ) - aboutToShowPage( page ); + { + emit aboutToShowPage( page ); + } } CreatedModule cm; cm.kcm = module; cm.service = moduleinfo.service(); m_modules.append( cm ); + if ( moduleinfo.needsRootPrivileges() && !d->hasRootKCM ) + { + d->hasRootKCM = true; + showButton( User2, true ); + } } void KCMultiDialog::removeAllModules() @@ -326,16 +346,38 @@ void KCMultiDialog::slotAboutToShow(QWid QObject * obj = page->child( 0, "KCModuleProxy" ); if( ! obj ) return; - KCModuleProxy * module = ( KCModuleProxy* )obj->qt_cast( - "KCModuleProxy" ); - if( ! module ) + d->currentModule = ( KCModuleProxy* )obj->qt_cast( "KCModuleProxy" ); + if( ! d->currentModule ) return; // TODO: if the dialogface is Plain we should hide the buttons instead of // disabling enableButton( KDialogBase::Help, - module->buttons() & KCModule::Help ); + d->currentModule->buttons() & KCModule::Help ); enableButton( KDialogBase::Default, - module->buttons() & KCModule::Default ); + d->currentModule->buttons() & KCModule::Default ); + + /* Enable the Admin Mode button */ + disconnect( 0, SIGNAL(user2Clicked()), 0, 0); + if (d->currentModule->moduleInfo().needsRootPrivileges()) + { + enableButton( User2, true ); + connect( this, SIGNAL(user2Clicked()), d->currentModule, SLOT( runAsRoot() )); + } } +void KCMultiDialog::slotUser2Clicked() /* Admin Mode */ +{ + if ( !d->currentModule ) + return; + + enableButton( User2, false ); + connect ( d->currentModule, SIGNAL( childClosed() ), SLOT( rootExit() )); +} + +void KCMultiDialog::rootExit() +{ + enableButton( User2, true); +} + + // vim: sw=4 et sts=4 Index: kutils/kcmultidialog.h =================================================================== RCS file: /home/kde/kdelibs/kutils/kcmultidialog.h,v retrieving revision 1.31 diff -u -3 -p -r1.31 kcmultidialog.h --- kutils/kcmultidialog.h 15 Jan 2004 15:56:00 -0000 1.31 +++ kutils/kcmultidialog.h 14 Mar 2004 23:43:24 -0000 @@ -209,12 +209,20 @@ protected slots: **/ virtual void slotHelp(); + /** + * This slot is called when the user pressed the "Administrator Mode" + * button + */ + virtual void slotUser2Clicked(); + private slots: void slotAboutToShow(QWidget *); void clientChanged(bool state); + void rootExit(); + private: void init(); void apply(); --Boundary-00=_kMQVAQcIHHTbQDj--