Add QKeySequence to VirtualDesktopManager::addAction overload
There are four usages of this overload, two of them are for the intentionally disabled "Switch to Next/Previous Desktop" actions and the rest are for "Switch One Desktop to X" actions. Due to the order they were added, an empty keybind was set as the default and the actual keybind is never enabled. Now there's a QKeySequence argument to this overload, so an unexpected empty keybind is never added. The two usages of addAction that depend on this empty keybind behavior now pass in an empty QKeySequence. BUG: 475748
This commit is contained in:
parent
be88c8ec49
commit
e398289287
2 changed files with 11 additions and 15 deletions
|
@ -795,18 +795,14 @@ void VirtualDesktopManager::initShortcuts()
|
|||
{
|
||||
initSwitchToShortcuts();
|
||||
|
||||
addAction(QStringLiteral("Switch to Next Desktop"), i18n("Switch to Next Desktop"), &VirtualDesktopManager::slotNext);
|
||||
addAction(QStringLiteral("Switch to Previous Desktop"), i18n("Switch to Previous Desktop"), &VirtualDesktopManager::slotPrevious);
|
||||
addAction(QStringLiteral("Switch to Next Desktop"), i18n("Switch to Next Desktop"), QKeySequence(), &VirtualDesktopManager::slotNext);
|
||||
addAction(QStringLiteral("Switch to Previous Desktop"), i18n("Switch to Previous Desktop"), QKeySequence(), &VirtualDesktopManager::slotPrevious);
|
||||
|
||||
// shortcuts
|
||||
QAction *slotRightAction = addAction(QStringLiteral("Switch One Desktop to the Right"), i18n("Switch One Desktop to the Right"), &VirtualDesktopManager::slotRight);
|
||||
KGlobalAccel::setGlobalShortcut(slotRightAction, QKeySequence(Qt::CTRL | Qt::META | Qt::Key_Right));
|
||||
QAction *slotLeftAction = addAction(QStringLiteral("Switch One Desktop to the Left"), i18n("Switch One Desktop to the Left"), &VirtualDesktopManager::slotLeft);
|
||||
KGlobalAccel::setGlobalShortcut(slotLeftAction, QKeySequence(Qt::CTRL | Qt::META | Qt::Key_Left));
|
||||
QAction *slotUpAction = addAction(QStringLiteral("Switch One Desktop Up"), i18n("Switch One Desktop Up"), &VirtualDesktopManager::slotUp);
|
||||
KGlobalAccel::setGlobalShortcut(slotUpAction, QKeySequence(Qt::CTRL | Qt::META | Qt::Key_Up));
|
||||
QAction *slotDownAction = addAction(QStringLiteral("Switch One Desktop Down"), i18n("Switch One Desktop Down"), &VirtualDesktopManager::slotDown);
|
||||
KGlobalAccel::setGlobalShortcut(slotDownAction, QKeySequence(Qt::CTRL | Qt::META | Qt::Key_Down));
|
||||
addAction(QStringLiteral("Switch One Desktop to the Right"), i18n("Switch One Desktop to the Right"), QKeySequence(Qt::CTRL | Qt::META | Qt::Key_Right), &VirtualDesktopManager::slotRight);
|
||||
addAction(QStringLiteral("Switch One Desktop to the Left"), i18n("Switch One Desktop to the Left"), QKeySequence(Qt::CTRL | Qt::META | Qt::Key_Left), &VirtualDesktopManager::slotLeft);
|
||||
addAction(QStringLiteral("Switch One Desktop Up"), i18n("Switch One Desktop Up"), QKeySequence(Qt::CTRL | Qt::META | Qt::Key_Up), &VirtualDesktopManager::slotUp);
|
||||
addAction(QStringLiteral("Switch One Desktop Down"), i18n("Switch One Desktop Down"), QKeySequence(Qt::CTRL | Qt::META | Qt::Key_Down), &VirtualDesktopManager::slotDown);
|
||||
|
||||
// Gestures
|
||||
// These connections decide which desktop to end on after gesture ends
|
||||
|
@ -917,13 +913,13 @@ QAction *VirtualDesktopManager::addAction(const QString &name, const KLocalizedS
|
|||
return a;
|
||||
}
|
||||
|
||||
QAction *VirtualDesktopManager::addAction(const QString &name, const QString &label, void (VirtualDesktopManager::*slot)())
|
||||
QAction *VirtualDesktopManager::addAction(const QString &name, const QString &label, const QKeySequence &key, void (VirtualDesktopManager::*slot)())
|
||||
{
|
||||
QAction *a = new QAction(this);
|
||||
a->setProperty("componentName", QStringLiteral("kwin"));
|
||||
a->setObjectName(name);
|
||||
a->setText(label);
|
||||
KGlobalAccel::setGlobalShortcut(a, QKeySequence());
|
||||
KGlobalAccel::setGlobalShortcut(a, key);
|
||||
connect(a, &QAction::triggered, this, slot);
|
||||
return a;
|
||||
}
|
||||
|
|
|
@ -471,13 +471,13 @@ private:
|
|||
QAction *addAction(const QString &name, const KLocalizedString &label, uint value, const QKeySequence &key, void (VirtualDesktopManager::*slot)());
|
||||
/**
|
||||
* Creates an action and connects it to the @p slot in this Manager.
|
||||
* Overloaded method for the case that no additional value needs to be passed to the action and
|
||||
* no global shortcut is defined by default.
|
||||
* Overloaded method for the case that no additional value needs to be passed to the action.
|
||||
* @param name The name of the action to be created
|
||||
* @param label The localized name for the action to be created
|
||||
* @param key The global shortcut for the action. If an empty QKeySequence is passed, no global shortcut is defined by default.
|
||||
* @param slot The slot to invoke when the action is triggered
|
||||
*/
|
||||
QAction *addAction(const QString &name, const QString &label, void (VirtualDesktopManager::*slot)());
|
||||
QAction *addAction(const QString &name, const QString &label, const QKeySequence &key, void (VirtualDesktopManager::*slot)());
|
||||
|
||||
QVector<VirtualDesktop *> m_desktops;
|
||||
QPointer<VirtualDesktop> m_current;
|
||||
|
|
Loading…
Reference in a new issue