From 830a1d19dd849b52396cdcb545dd14c3ef946a4e Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Tue, 24 Feb 2009 02:32:48 +0000 Subject: [PATCH] give access to the standard config dialog to script engines that care to use it svn path=/trunk/KDE/kdelibs/; revision=930708 --- applet.cpp | 7 ++++--- private/applet_p.h | 2 +- scripting/appletscript.cpp | 13 ++++++++++++- scripting/appletscript.h | 9 +++++++++ 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/applet.cpp b/applet.cpp index 63589502c..f28efaee7 100644 --- a/applet.cpp +++ b/applet.cpp @@ -181,6 +181,7 @@ Applet::~Applet() } } + // clean up our config dialog, if any delete d; } @@ -1548,7 +1549,7 @@ void Applet::showConfigurationInterface() } else if (d->script) { d->script->showConfigurationInterface(); } else { - d->generateGenericConfigDialog(); + d->generateGenericConfigDialog()->show(); } emit releaseVisualFocus(); @@ -1564,7 +1565,7 @@ QString AppletPrivate::configWindowTitle() const return i18nc("@title:window", "%1 Settings", q->name()); } -void AppletPrivate::generateGenericConfigDialog() +KConfigDialog *AppletPrivate::generateGenericConfigDialog() { KConfigSkeleton *nullManager = new KConfigSkeleton(0); KConfigDialog *dialog = new KConfigDialog(0, configDialogId(), nullManager); @@ -1579,7 +1580,7 @@ void AppletPrivate::generateGenericConfigDialog() QObject::connect(dialog, SIGNAL(okClicked()), q, SLOT(configDialogFinished())); QObject::connect(dialog, SIGNAL(finished()), q, SLOT(configDialogFinished())); QObject::connect(dialog, SIGNAL(finished()), nullManager, SLOT(deleteLater())); - dialog->show(); + return dialog; } void AppletPrivate::addGlobalShortcutsPage(KConfigDialog *dialog) diff --git a/private/applet_p.h b/private/applet_p.h index 82e15ef71..02f36536e 100644 --- a/private/applet_p.h +++ b/private/applet_p.h @@ -83,7 +83,7 @@ public: void addGlobalShortcutsPage(KConfigDialog *dialog); void clearShortcutEditorPtr(); void configDialogFinished(); - void generateGenericConfigDialog(); + KConfigDialog *generateGenericConfigDialog(); QString configDialogId() const; QString configWindowTitle() const; diff --git a/scripting/appletscript.cpp b/scripting/appletscript.cpp index b1c196c97..7866ff3b1 100644 --- a/scripting/appletscript.cpp +++ b/scripting/appletscript.cpp @@ -19,6 +19,8 @@ #include "scripting/appletscript.h" +#include "kconfigdialog.h" + #include "applet.h" #include "package.h" #include "private/applet_p.h" @@ -125,10 +127,19 @@ void AppletScript::configNeedsSaving() const void AppletScript::showConfigurationInterface() { if (applet()) { - applet()->d->generateGenericConfigDialog(); + applet()->d->generateGenericConfigDialog()->show(); } } +KConfigDialog *AppletScript::standardConfigurationDialog() +{ + if (applet()) { + return applet()->d->generateGenericConfigDialog(); + } + + return 0; +} + void AppletScript::configChanged() { } diff --git a/scripting/appletscript.h b/scripting/appletscript.h index 933292c57..ccb753a99 100644 --- a/scripting/appletscript.h +++ b/scripting/appletscript.h @@ -32,6 +32,7 @@ class QAction; class QPainter; class QStyleOptionGraphicsItem; +class KConfigDialog; namespace Plasma { @@ -165,6 +166,14 @@ protected: */ const Package *package() const; + /** + * @return a standard Plasma applet configuration dialog, ready + * to have pages added to it. + * + * Note that the dialog returned is set to delete on close. + */ + KConfigDialog *standardConfigurationDialog(); + private: AppletScriptPrivate *const d; };