From fca66bfd9e2ef020c0072d2f6520ae04c9a6c959 Mon Sep 17 00:00:00 2001 From: Richard Dale Date: Thu, 20 Aug 2009 18:20:31 +0000 Subject: [PATCH] * Add a Plasma::AppletScript::addStandardConfigurationPages() method that adds standard pages to a configuration dialog such as the shortcuts one. In conjunction with standardConfigurationDialog() this will allow script engines to use the same dialogs as C++ applets svn path=/branches/KDE/4.3/kdelibs/; revision=1013766 --- applet.cpp | 18 +++++++++--------- scripting/appletscript.cpp | 9 +++++++++ scripting/appletscript.h | 6 ++++++ 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/applet.cpp b/applet.cpp index 2f070b2ca..dcec55a58 100644 --- a/applet.cpp +++ b/applet.cpp @@ -1584,13 +1584,14 @@ void Applet::showConfigurationInterface() } d->addGlobalShortcutsPage(dialog); - connect(dialog, SIGNAL(applyClicked()), this, SLOT(configDialogFinished())); - connect(dialog, SIGNAL(okClicked()), this, SLOT(configDialogFinished())); dialog->show(); } else if (d->script) { d->script->showConfigurationInterface(); } else { - d->generateGenericConfigDialog()->show(); + KConfigDialog *dialog = d->generateGenericConfigDialog(); + createConfigurationInterface(dialog); + d->addGlobalShortcutsPage(dialog); + dialog->show(); } emit releaseVisualFocus(); @@ -1640,12 +1641,6 @@ KConfigDialog *AppletPrivate::generateGenericConfigDialog() dialog->setFaceType(KPageDialog::Auto); dialog->setWindowTitle(configWindowTitle()); dialog->setAttribute(Qt::WA_DeleteOnClose, true); - q->createConfigurationInterface(dialog); - addGlobalShortcutsPage(dialog); - //TODO: Apply button does not correctly work for now, so do not show it - dialog->showButton(KDialog::Apply, false); - QObject::connect(dialog, SIGNAL(applyClicked()), q, SLOT(configDialogFinished())); - QObject::connect(dialog, SIGNAL(okClicked()), q, SLOT(configDialogFinished())); QObject::connect(dialog, SIGNAL(finished()), nullManager, SLOT(deleteLater())); return dialog; } @@ -1668,6 +1663,11 @@ void AppletPrivate::addGlobalShortcutsPage(KConfigDialog *dialog) layout->addWidget(shortcutEditor); layout->addStretch(); dialog->addPage(page, i18n("Keyboard Shortcut"), "preferences-desktop-keyboard"); + + //TODO: Apply button does not correctly work for now, so do not show it + dialog->showButton(KDialog::Apply, false); + QObject::connect(dialog, SIGNAL(applyClicked()), q, SLOT(configDialogFinished())); + QObject::connect(dialog, SIGNAL(okClicked()), q, SLOT(configDialogFinished())); } void AppletPrivate::clearShortcutEditorPtr() diff --git a/scripting/appletscript.cpp b/scripting/appletscript.cpp index 0016c40d0..1ede3e02c 100644 --- a/scripting/appletscript.cpp +++ b/scripting/appletscript.cpp @@ -140,6 +140,15 @@ KConfigDialog *AppletScript::standardConfigurationDialog() return 0; } +void AppletScript::addStandardConfigurationPages(KConfigDialog *dialog) +{ + if (applet()) { + return applet()->d->addGlobalShortcutsPage(dialog); + } + + return; +} + void AppletScript::configChanged() { } diff --git a/scripting/appletscript.h b/scripting/appletscript.h index 33f920d93..c2a750795 100644 --- a/scripting/appletscript.h +++ b/scripting/appletscript.h @@ -180,6 +180,12 @@ protected: */ KConfigDialog *standardConfigurationDialog(); + /** + * This method should be called after a scripting applet has added + * its own pages to a configuration dialog + */ + void addStandardConfigurationPages(KConfigDialog *dialog); + private: AppletScriptPrivate *const d; };