From 2e1f02821051218024626779332685bfbb589c95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Fri, 6 Sep 2013 10:52:47 +0200 Subject: [PATCH] KWin/VirtualDesktops ported to new global shortcut system No more Kaction, no more KShortcut. --- virtualdesktops.cpp | 22 +++++++++------------- virtualdesktops.h | 3 +-- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/virtualdesktops.cpp b/virtualdesktops.cpp index af6bc45e1a..4ea96ef7a8 100644 --- a/virtualdesktops.cpp +++ b/virtualdesktops.cpp @@ -23,8 +23,8 @@ along with this program. If not, see . #include #include #include +#include #include -#include #include namespace KWin { @@ -437,33 +437,29 @@ void VirtualDesktopManager::initSwitchToShortcuts(KActionCollection *keys) { const QString toDesktop = QStringLiteral("Switch to Desktop %1"); const KLocalizedString toDesktopLabel = ki18n("Switch to Desktop %1"); - addAction(keys, toDesktop, toDesktopLabel, 1, KShortcut(Qt::CTRL + Qt::Key_F1), SLOT(slotSwitchTo())); - addAction(keys, toDesktop, toDesktopLabel, 2, KShortcut(Qt::CTRL + Qt::Key_F2), SLOT(slotSwitchTo())); - addAction(keys, toDesktop, toDesktopLabel, 3, KShortcut(Qt::CTRL + Qt::Key_F3), SLOT(slotSwitchTo())); - addAction(keys, toDesktop, toDesktopLabel, 4, KShortcut(Qt::CTRL + Qt::Key_F4), SLOT(slotSwitchTo())); + 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())); for (uint i = 5; i <= maximum(); ++i) { - addAction(keys, toDesktop, toDesktopLabel, i, KShortcut(), SLOT(slotSwitchTo())); + addAction(keys, toDesktop, toDesktopLabel, i, QKeySequence(), SLOT(slotSwitchTo())); } } -void VirtualDesktopManager::addAction(KActionCollection *keys, const QString &name, const KLocalizedString &label, uint value, const KShortcut &key, const char *slot) +void VirtualDesktopManager::addAction(KActionCollection *keys, const QString &name, const KLocalizedString &label, uint value, const QKeySequence &key, const char *slot) { QAction *a = keys->addAction(name.arg(value), this, slot); a->setText(label.subs(value).toString()); -#if KWIN_QT5_PORTING - a->setGlobalShortcut(key); -#endif a->setData(value); + KGlobalAccel::self()->setShortcut(a, QList() << key); } void VirtualDesktopManager::addAction(KActionCollection *keys, const QString &name, const QString &label, const char *slot) { QAction *a = keys->addAction(name, this, slot); -#if KWIN_QT5_PORTING - a->setGlobalShortcut(KShortcut()); -#endif a->setText(label); + KGlobalAccel::self()->setShortcut(a, QList()); } void VirtualDesktopManager::slotSwitchTo() diff --git a/virtualdesktops.h b/virtualdesktops.h index 0630ba6196..f81df3e33c 100644 --- a/virtualdesktops.h +++ b/virtualdesktops.h @@ -30,7 +30,6 @@ along with this program. If not, see . class KActionCollection; class KLocalizedString; -class KShortcut; class NETRootInfo; namespace KWin { @@ -341,7 +340,7 @@ private: * @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 KShortcut &key, const char *slot); + void addAction(KActionCollection *keys, const QString &name, const KLocalizedString &label, uint value, const QKeySequence &key, const char *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