From 65268e77d47fbfec029372f7b28e1153c236093c Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Tue, 20 Jan 2009 02:11:01 +0000 Subject: [PATCH] by default, applet scripts get the generic config dialog svn path=/trunk/KDE/kdelibs/; revision=913900 --- applet.cpp | 49 ++++++++++++++++++++++++-------------- private/applet_p.h | 3 +++ scripting/appletscript.cpp | 4 ++++ 3 files changed, 38 insertions(+), 18 deletions(-) diff --git a/applet.cpp b/applet.cpp index 86602beec..8a3f128cc 100644 --- a/applet.cpp +++ b/applet.cpp @@ -1394,7 +1394,7 @@ void Applet::showConfigurationInterface() } const QString dialogId = QString("%1settings%2").arg(id()).arg(name()); - KConfigDialog * dlg = KConfigDialog::exists(dialogId); + KConfigDialog *dlg = KConfigDialog::exists(d->configDialogId()); if (dlg) { KWindowSystem::setOnDesktop(dlg->winId(), KWindowSystem::currentDesktop()); @@ -1403,7 +1403,6 @@ void Applet::showConfigurationInterface() return; } - const QString windowTitle = i18nc("@title:window", "%1 Settings", name()); if (d->package && d->configLoader) { QString uiFile = d->package->filePath("mainconfigui"); if (uiFile.isEmpty()) { @@ -1411,7 +1410,7 @@ void Applet::showConfigurationInterface() } KConfigDialog *dialog = new KConfigDialog(0, dialogId, d->configLoader); - dialog->setWindowTitle(windowTitle); + dialog->setWindowTitle(d->configWindowTitle()); dialog->setAttribute(Qt::WA_DeleteOnClose, true); QUiLoader loader; @@ -1436,28 +1435,42 @@ void Applet::showConfigurationInterface() connect(dialog, SIGNAL(finished()), this, SLOT(configDialogFinished())); dialog->show(); } else if (d->script) { - //FIXME: global shorcuts? d->script->showConfigurationInterface(); } else { - KConfigSkeleton *nullManager = new KConfigSkeleton(0); - KConfigDialog *dialog = new KConfigDialog(0, dialogId, nullManager); - dialog->setFaceType(KPageDialog::Auto); - dialog->setWindowTitle(windowTitle); - dialog->setAttribute(Qt::WA_DeleteOnClose, true); - createConfigurationInterface(dialog); - d->addGlobalShortcutsPage(dialog); - connect(dialog, SIGNAL(finished()), nullManager, SLOT(deleteLater())); - //TODO: Apply button does not correctly work for now, so do not show it - dialog->showButton(KDialog::Apply, false); - connect(dialog, SIGNAL(applyClicked()), this, SLOT(configDialogFinished())); - connect(dialog, SIGNAL(okClicked()), this, SLOT(configDialogFinished())); - connect(dialog, SIGNAL(finished()), this, SLOT(configDialogFinished())); - dialog->show(); + d->generateGenericConfigDialog(); } emit releaseVisualFocus(); } +QString AppletPrivate::configDialogId() const +{ + return QString("%1settings%2").arg(appletId).arg(q->name()); +} + +QString AppletPrivate::configWindowTitle() const +{ + return i18nc("@title:window", "%1 Settings", q->name()); +} + +void AppletPrivate::generateGenericConfigDialog() +{ + KConfigSkeleton *nullManager = new KConfigSkeleton(0); + KConfigDialog *dialog = new KConfigDialog(0, configDialogId(), nullManager); + 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()), q, SLOT(configDialogFinished())); + QObject::connect(dialog, SIGNAL(finished()), nullManager, SLOT(deleteLater())); + dialog->show(); +} + void AppletPrivate::addGlobalShortcutsPage(KConfigDialog *dialog) { if (isContainment) { diff --git a/private/applet_p.h b/private/applet_p.h index 0c0a680f3..bcdaa9362 100644 --- a/private/applet_p.h +++ b/private/applet_p.h @@ -79,6 +79,9 @@ public: void addGlobalShortcutsPage(KConfigDialog *dialog); void clearShortcutEditorPtr(); void configDialogFinished(); + void generateGenericConfigDialog(); + QString configDialogId() const; + QString configWindowTitle() const; static uint s_maxAppletId; static uint s_maxZValue; diff --git a/scripting/appletscript.cpp b/scripting/appletscript.cpp index b1a7d59f9..b1c196c97 100644 --- a/scripting/appletscript.cpp +++ b/scripting/appletscript.cpp @@ -21,6 +21,7 @@ #include "applet.h" #include "package.h" +#include "private/applet_p.h" namespace Plasma { @@ -123,6 +124,9 @@ void AppletScript::configNeedsSaving() const void AppletScript::showConfigurationInterface() { + if (applet()) { + applet()->d->generateGenericConfigDialog(); + } } void AppletScript::configChanged()