From be4c8c2c5ed00084fc8f35aee338f44022d148a6 Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Mon, 5 Jan 2009 18:08:14 +0000 Subject: [PATCH] if an applet overrode configChanged (it is virtual), the keyboard shortcuts wouldn't get picked up; so move that all to a private slot and now configChangedcan be safely used instead of connecting up to the dialog signals yourself as an added bonus svn path=/trunk/KDE/kdelibs/; revision=906175 --- applet.cpp | 33 +++++++++++++++++++-------------- applet.h | 1 + private/applet_p.h | 1 + 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/applet.cpp b/applet.cpp index cfa470a9c..b4c7527b8 100644 --- a/applet.cpp +++ b/applet.cpp @@ -1398,10 +1398,10 @@ void Applet::showConfigurationInterface() dialog->addPage(w, i18n("Settings"), icon(), i18n("%1 Settings", name())); d->addGlobalShortcutsPage(dialog); - connect(dialog, SIGNAL(applyClicked()), this, SLOT(configChanged())); - connect(dialog, SIGNAL(okClicked()), this, SLOT(configChanged())); + connect(dialog, SIGNAL(applyClicked()), this, SLOT(configDialogFinished())); + connect(dialog, SIGNAL(okClicked()), this, SLOT(configDialogFinished())); //FIXME: in this case use another ad-hoc slot? - connect(dialog, SIGNAL(finished()), this, SLOT(configChanged())); + connect(dialog, SIGNAL(finished()), this, SLOT(configDialogFinished())); dialog->show(); } else if (d->script) { //FIXME: global shorcuts? @@ -1417,9 +1417,9 @@ void Applet::showConfigurationInterface() 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(configChanged())); - connect(dialog, SIGNAL(okClicked()), this, SLOT(configChanged())); - connect(dialog, SIGNAL(finished()), this, SLOT(configChanged())); + connect(dialog, SIGNAL(applyClicked()), this, SLOT(configDialogFinished())); + connect(dialog, SIGNAL(okClicked()), this, SLOT(configDialogFinished())); + connect(dialog, SIGNAL(finished()), this, SLOT(configDialogFinished())); dialog->show(); } @@ -1451,19 +1451,24 @@ void AppletPrivate::clearShortcutEditorPtr() shortcutEditor = 0; } +void AppletPrivate::configDialogFinished() +{ + if (shortcutEditor) { + QKeySequence sequence = shortcutEditor->keySequence(); + if (sequence != q->globalShortcut().primary()) { + q->setGlobalShortcut(KShortcut(sequence)); + emit q->configNeedsSaving(); + } + } + + q->configChanged(); +} + void Applet::configChanged() { if (d->script) { d->script->configChanged(); } - - if (d->shortcutEditor) { - QKeySequence sequence = d->shortcutEditor->keySequence(); - if (sequence != globalShortcut().primary()) { - setGlobalShortcut(KShortcut(sequence)); - emit configNeedsSaving(); - } - } } void Applet::createConfigurationInterface(KConfigDialog *parent) diff --git a/applet.h b/applet.h index 1d79b6cc5..19ece2018 100644 --- a/applet.h +++ b/applet.h @@ -843,6 +843,7 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget Q_PRIVATE_SLOT(d, void updateRect(const QRectF& rect)) Q_PRIVATE_SLOT(d, void destroyMessageOverlay()) Q_PRIVATE_SLOT(d, void clearShortcutEditorPtr()) + Q_PRIVATE_SLOT(d, void configDialogFinished()) /** * Reimplemented from QGraphicsItem diff --git a/private/applet_p.h b/private/applet_p.h index d5d94741b..0c0a680f3 100644 --- a/private/applet_p.h +++ b/private/applet_p.h @@ -78,6 +78,7 @@ public: void destroyMessageOverlay(); void addGlobalShortcutsPage(KConfigDialog *dialog); void clearShortcutEditorPtr(); + void configDialogFinished(); static uint s_maxAppletId; static uint s_maxZValue;