kdeui: KAction::shortcut() optimization

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2023-08-27 18:46:59 +03:00
parent 048737d48c
commit 558295b483

View file

@ -56,7 +56,6 @@ void KActionPrivate::setActiveGlobalShortcutNoEnable(const KShortcut &cut)
emit q->globalShortcutChanged(cut.primary()); emit q->globalShortcutChanged(cut.primary());
} }
void KActionPrivate::slotTriggered() void KActionPrivate::slotTriggered()
{ {
emit q->triggered(QApplication::mouseButtons(), QApplication::keyboardModifiers()); emit q->triggered(QApplication::mouseButtons(), QApplication::keyboardModifiers());
@ -134,13 +133,13 @@ KShortcut KAction::shortcut(ShortcutTypes type) const
{ {
Q_ASSERT(type); Q_ASSERT(type);
if (type == DefaultShortcut) { if (type == DefaultShortcut) {
QKeySequence primary = property("defaultPrimaryShortcut").value<QKeySequence>(); return KShortcut(
QKeySequence secondary = property("defaultAlternateShortcut").value<QKeySequence>(); property("defaultPrimaryShortcut").value<QKeySequence>(),
return KShortcut(primary, secondary); property("defaultAlternateShortcut").value<QKeySequence>()
);
} }
QKeySequence primary = shortcuts().value(0); const QList cuts = shortcuts();
QKeySequence secondary = shortcuts().value(1); return KShortcut(cuts.value(0), cuts.value(1));
return KShortcut(primary, secondary);
} }
void KAction::setShortcut(const KShortcut &shortcut, ShortcutTypes type) void KAction::setShortcut(const KShortcut &shortcut, ShortcutTypes type)
@ -222,14 +221,13 @@ bool KAction::isGlobalShortcutEnabled() const
return d->globalShortcutEnabled; return d->globalShortcutEnabled;
} }
void KAction::forgetGlobalShortcut() void KAction::forgetGlobalShortcut()
{ {
d->globalShortcut = KShortcut(); d->globalShortcut = KShortcut();
d->defaultGlobalShortcut = KShortcut(); d->defaultGlobalShortcut = KShortcut();
if (d->globalShortcutEnabled) { if (d->globalShortcutEnabled) {
d->globalShortcutEnabled = false; d->globalShortcutEnabled = false;
d->neverSetGlobalShortcut = true; //it's a fresh start :) d->neverSetGlobalShortcut = true; //it's a fresh start :)
KGlobalAccel::self()->d->remove(this, KGlobalAccelPrivate::UnRegister); KGlobalAccel::self()->d->remove(this, KGlobalAccelPrivate::UnRegister);
} }
} }