Fix activationAction connection

It was connecting to a deprecated signal, use QAction::changed instead.
Since QAction::changed is more generic and modifying the shortcut seems
expensive, actually check that the property is different from the previous
value.

Reviewed by Vishesh Handa.
This commit is contained in:
Aleix Pol 2014-04-12 20:09:08 +02:00
parent 333bd207ac
commit 9a305de76d
2 changed files with 7 additions and 4 deletions

View File

@ -587,7 +587,7 @@ void Applet::setGlobalShortcut(const QKeySequence &shortcut)
d->activationAction->setText(i18n("Activate %1 Widget", title()));
d->activationAction->setObjectName(QString("activate widget %1").arg(id())); // NO I18N
connect(d->activationAction, SIGNAL(triggered()), this, SIGNAL(activated()));
connect(d->activationAction, SIGNAL(globalShortcutChanged(QKeySequence)),
connect(d->activationAction, SIGNAL(changed()),
this, SLOT(globalShortcutChanged()));
} else if (d->activationAction->shortcut() == shortcut) {
return;

View File

@ -210,10 +210,13 @@ void AppletPrivate::globalShortcutChanged()
if (!activationAction) {
return;
}
KConfigGroup shortcutConfig(mainConfigGroup(), "Shortcuts");
shortcutConfig.writeEntry("global", activationAction->shortcut().toString());
scheduleModificationNotification();
QString newShortCut = activationAction->shortcut().toString();
QString oldShortCut = shortcutConfig.readEntry("global", QString());
if(newShortCut != oldShortCut) {
shortcutConfig.writeEntry("global", newShortCut);
scheduleModificationNotification();
}
//qDebug() << "after" << shortcut.primary() << d->activationAction->globalShortcut().primary();
}