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
This commit is contained in:
Aaron J. Seigo 2009-01-05 18:08:14 +00:00
parent d8c68f8d5f
commit be4c8c2c5e
3 changed files with 21 additions and 14 deletions

View File

@ -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)

View File

@ -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

View File

@ -78,6 +78,7 @@ public:
void destroyMessageOverlay();
void addGlobalShortcutsPage(KConfigDialog *dialog);
void clearShortcutEditorPtr();
void configDialogFinished();
static uint s_maxAppletId;
static uint s_maxZValue;