kdeui: ungrab all shortcuts from KGlobalAccelPrivate::remove()

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2024-04-25 10:34:58 +03:00
parent 3996fa22a7
commit 11e40bd6d2
2 changed files with 15 additions and 10 deletions

View file

@ -177,9 +177,9 @@ void KAction::setGlobalShortcut(const QKeySequence &shortcut, ShortcutTypes type
changed = true;
}
//We want to have updateGlobalShortcuts called on a new action in any case so that
//it will be registered properly. In the case of the first setShortcut() call getting an
//empty shortcut parameter this would not happen...
// want to have updateGlobalShortcuts called on a new action in any case so that
// it will be registered properly. In the case of the first setShortcut() call getting an
// empty shortcut parameter this would not happen...
if (changed || d->neverSetGlobalShortcut) {
KGlobalAccel::self()->d->updateGlobalShortcut(this);
d->neverSetGlobalShortcut = false;
@ -199,7 +199,7 @@ void KAction::forgetGlobalShortcut()
d->defaultGlobalShortcut = QKeySequence();
if (d->globalShortcutEnabled) {
d->globalShortcutEnabled = false;
d->neverSetGlobalShortcut = true; //it's a fresh start :)
d->neverSetGlobalShortcut = true; // it's a fresh start :)
KGlobalAccel::self()->d->remove(this);
emit globalShortcutChanged(d->globalShortcut);
}

View file

@ -232,18 +232,23 @@ bool KGlobalAccelPrivate::doRegister(KAction *action)
bool KGlobalAccelPrivate::remove(KAction *action)
{
foreach (const KGlobalAccelStruct &shortcut, filter->shortcuts) {
bool result = false;
bool found = false;
QMutableListIterator<KGlobalAccelStruct> iter(filter->shortcuts);
while (iter.hasNext()) {
const KGlobalAccelStruct shortcut = iter.next();
if (shortcut.action == action) {
found = true;
if (kUngrabKey(shortcut.keyModX, shortcut.keyCodeX)) {
kDebug(s_kglobalaccelarea) << "ungrabbed shortcut" << shortcut.keyModX << shortcut.keyCodeX << shortcut.action;
filter->shortcuts.removeOne(shortcut);
return true;
iter.remove();
result = true;
} else {
kWarning(s_kglobalaccelarea) << "could not ungrab shortcut" << shortcut.keyModX << shortcut.keyCodeX << shortcut.action;
}
kWarning(s_kglobalaccelarea) << "could not ungrab shortcut" << shortcut.keyModX << shortcut.keyCodeX << shortcut.action;
return false;
}
}
return true;
return (result || !found);
}