diff --git a/useractions.cpp b/useractions.cpp
index 83e801928f..9123886a5c 100755
--- a/useractions.cpp
+++ b/useractions.cpp
@@ -964,7 +964,7 @@ void Workspace::initShortcuts()
#ifdef KWIN_BUILD_TABBOX
TabBox::TabBox::self()->initShortcuts(actionCollection);
#endif
- VirtualDesktopManager::self()->initShortcuts(actionCollection);
+ VirtualDesktopManager::self()->initShortcuts();
m_userActionsMenu->discard(); // so that it's recreated next time
}
diff --git a/virtualdesktops.cpp b/virtualdesktops.cpp
index 4ea96ef7a8..c71f4f7057 100644
--- a/virtualdesktops.cpp
+++ b/virtualdesktops.cpp
@@ -20,12 +20,12 @@ along with this program. If not, see .
*********************************************************************/
#include "virtualdesktops.h"
// KDE
-#include
-#include
#include
#include
#include
#include
+// Qt
+#include
namespace KWin {
@@ -419,46 +419,48 @@ void VirtualDesktopManager::setNETDesktopLayout(Qt::Orientation orientation, uin
emit layoutChanged(width, height);
}
-void VirtualDesktopManager::initShortcuts(KActionCollection *keys)
+void VirtualDesktopManager::initShortcuts()
{
- QAction *a = keys->addAction(QStringLiteral("Group:Desktop Switching"));
- a->setText(i18n("Desktop Switching"));
- initSwitchToShortcuts(keys);
+ initSwitchToShortcuts();
- addAction(keys, QStringLiteral("Switch to Next Desktop"), i18n("Switch to Next Desktop"), SLOT(slotNext()));
- addAction(keys, QStringLiteral("Switch to Previous Desktop"), i18n("Switch to Previous Desktop"), SLOT(slotPrevious()));
- addAction(keys, QStringLiteral("Switch One Desktop to the Right"), i18n("Switch One Desktop to the Right"), SLOT(slotRight()));
- addAction(keys, QStringLiteral("Switch One Desktop to the Left"), i18n("Switch One Desktop to the Left"), SLOT(slotLeft()));
- addAction(keys, QStringLiteral("Switch One Desktop Up"), i18n("Switch One Desktop Up"), SLOT(slotUp()));
- addAction(keys, QStringLiteral("Switch One Desktop Down"), i18n("Switch One Desktop Down"), SLOT(slotDown()));
+ 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 One Desktop to the Right"), i18n("Switch One Desktop to the Right"), &VirtualDesktopManager::slotRight);
+ addAction(QStringLiteral("Switch One Desktop to the Left"), i18n("Switch One Desktop to the Left"), &VirtualDesktopManager::slotLeft);
+ addAction(QStringLiteral("Switch One Desktop Up"), i18n("Switch One Desktop Up"), &VirtualDesktopManager::slotUp);
+ addAction(QStringLiteral("Switch One Desktop Down"), i18n("Switch One Desktop Down"), &VirtualDesktopManager::slotDown);
}
-void VirtualDesktopManager::initSwitchToShortcuts(KActionCollection *keys)
+void VirtualDesktopManager::initSwitchToShortcuts()
{
const QString toDesktop = QStringLiteral("Switch to Desktop %1");
const KLocalizedString toDesktopLabel = ki18n("Switch to Desktop %1");
- addAction(keys, toDesktop, toDesktopLabel, 1, QKeySequence(Qt::CTRL + Qt::Key_F1), SLOT(slotSwitchTo()));
- addAction(keys, toDesktop, toDesktopLabel, 2, QKeySequence(Qt::CTRL + Qt::Key_F2), SLOT(slotSwitchTo()));
- addAction(keys, toDesktop, toDesktopLabel, 3, QKeySequence(Qt::CTRL + Qt::Key_F3), SLOT(slotSwitchTo()));
- addAction(keys, toDesktop, toDesktopLabel, 4, QKeySequence(Qt::CTRL + Qt::Key_F4), SLOT(slotSwitchTo()));
+ addAction(toDesktop, toDesktopLabel, 1, QKeySequence(Qt::CTRL + Qt::Key_F1), &VirtualDesktopManager::slotSwitchTo);
+ addAction(toDesktop, toDesktopLabel, 2, QKeySequence(Qt::CTRL + Qt::Key_F2), &VirtualDesktopManager::slotSwitchTo);
+ addAction(toDesktop, toDesktopLabel, 3, QKeySequence(Qt::CTRL + Qt::Key_F3), &VirtualDesktopManager::slotSwitchTo);
+ addAction(toDesktop, toDesktopLabel, 4, QKeySequence(Qt::CTRL + Qt::Key_F4), &VirtualDesktopManager::slotSwitchTo);
for (uint i = 5; i <= maximum(); ++i) {
- addAction(keys, toDesktop, toDesktopLabel, i, QKeySequence(), SLOT(slotSwitchTo()));
+ addAction(toDesktop, toDesktopLabel, i, QKeySequence(), &VirtualDesktopManager::slotSwitchTo);
}
}
-void VirtualDesktopManager::addAction(KActionCollection *keys, const QString &name, const KLocalizedString &label, uint value, const QKeySequence &key, const char *slot)
+void VirtualDesktopManager::addAction(const QString &name, const KLocalizedString &label, uint value, const QKeySequence &key, void (VirtualDesktopManager::*slot)())
{
- QAction *a = keys->addAction(name.arg(value), this, slot);
+ QAction *a = new QAction(this);
+ a->setObjectName(name.arg(value));
a->setText(label.subs(value).toString());
a->setData(value);
+ connect(a, &QAction::triggered, this, slot);
KGlobalAccel::self()->setShortcut(a, QList() << key);
}
-void VirtualDesktopManager::addAction(KActionCollection *keys, const QString &name, const QString &label, const char *slot)
+void VirtualDesktopManager::addAction(const QString &name, const QString &label, void (VirtualDesktopManager::*slot)())
{
- QAction *a = keys->addAction(name, this, slot);
+ QAction *a = new QAction(this);
+ a->setObjectName(name);
a->setText(label);
+ connect(a, &QAction::triggered, this, slot);
KGlobalAccel::self()->setShortcut(a, QList());
}
diff --git a/virtualdesktops.h b/virtualdesktops.h
index f81df3e33c..145b638fe4 100644
--- a/virtualdesktops.h
+++ b/virtualdesktops.h
@@ -28,7 +28,6 @@ along with this program. If not, see .
// KDE includes
#include
-class KActionCollection;
class KLocalizedString;
class NETRootInfo;
@@ -177,7 +176,7 @@ public:
**/
uint previous(uint id = 0, bool wrap = true) const;
- void initShortcuts(KActionCollection *keys);
+ void initShortcuts();
/**
* @returns The maximum number of desktops that KWin supports.
@@ -328,29 +327,27 @@ private:
/**
* Creates all the global keyboard shortcuts for "Switch To Desktop n" actions.
**/
- void initSwitchToShortcuts(KActionCollection *keys);
+ void initSwitchToShortcuts();
/**
* Creates an action and connects it to the @p slot in this Manager. This method is
* meant to be used for the case that an additional information needs to be stored in
* the action and the label.
- * @param keys The ActionCollection used to create the Action
* @param name The name of the action to be created
* @param label The localized name for the action to be created
* @param value An additional value added to the label and to the created action
* @param key The global shortcut for the action
* @param slot The slot to invoke when the action is triggered
**/
- void addAction(KActionCollection *keys, const QString &name, const KLocalizedString &label, uint value, const QKeySequence &key, const char *slot);
+ void 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.
- * @param keys The ActionCollection used to create the Action
* @param name The name of the action to be created
* @param label The localized name for the action to be created
* @param slot The slot to invoke when the action is triggered
**/
- void addAction(KActionCollection *keys, const QString &name, const QString &label, const char *slot);
+ void addAction(const QString &name, const QString &label, void (VirtualDesktopManager::*slot)());
uint m_current;
uint m_count;