Connect to global shortcut changes

The intent behind this code seemingly was that KGlobalAccel would
update the shortcut of the QAction but that is not the case. This
leads to our config going out of sync when global shortcuts are
changed from the oustide (the kcm) and resetting on next start
since we set shortcuts with NoAutoLoading.
BUG:438662
FIXED-IN:5.84
This commit is contained in:
David Redondo 2021-06-17 09:41:05 +02:00
parent 03c3df109a
commit 3e006a0c42
1 changed files with 6 additions and 1 deletions

View File

@ -744,7 +744,12 @@ void Applet::setGlobalShortcut(const QKeySequence &shortcut)
d->activationAction->setText(i18n("Activate %1 Widget", title()));
d->activationAction->setObjectName(QStringLiteral("activate widget %1").arg(id())); // NO I18N
connect(d->activationAction, &QAction::triggered, this, &Applet::activated);
connect(d->activationAction, SIGNAL(changed()), this, SLOT(globalShortcutChanged()));
connect(KGlobalAccel::self(), &KGlobalAccel::globalShortcutChanged, this, [this](QAction *action, const QKeySequence &shortcut) {
if (action == d->activationAction) {
d->activationAction->setShortcut(shortcut);
d->globalShortcutChanged();
}
});
} else if (d->activationAction->shortcut() == shortcut) {
return;
}