From a6f32bf3e835b7abfc8c49cf5a9ab90535c37845 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Tue, 10 Dec 2013 10:01:13 +0100 Subject: [PATCH] [kwin] Do not use a KActionCollection for Workspace's global shortcut actions The ActionCollection was only used for two features: * setting the object name * finding the action for retrieving it's shortcut This can also be achieved by just setting the object name and searching for the children of the Workspace singleton. --- composite.cpp | 2 +- kwinbindings.cpp | 11 ----------- useractions.cpp | 12 ++++-------- workspace.cpp | 1 - workspace.h | 4 ---- 5 files changed, 5 insertions(+), 25 deletions(-) diff --git a/composite.cpp b/composite.cpp index c7109bd433..16a0c91fe8 100644 --- a/composite.cpp +++ b/composite.cpp @@ -420,7 +420,7 @@ void Compositor::toggleCompositing() slotToggleCompositing(); // TODO only operate on script level here? if (m_suspended) { // when disabled show a shortcut how the user can get back compositing - const auto shortcuts = KGlobalAccel::self()->shortcut(workspace()->actionCollection()->action(QStringLiteral("Suspend Compositing"))); + const auto shortcuts = KGlobalAccel::self()->shortcut(workspace()->findChild(QStringLiteral("Suspend Compositing"))); if (!shortcuts.isEmpty()) { // display notification only if there is the shortcut const QString message = i18n("Desktop effects have been suspended by another application.
" diff --git a/kwinbindings.cpp b/kwinbindings.cpp index dcc6aad5c6..3c9f57c471 100644 --- a/kwinbindings.cpp +++ b/kwinbindings.cpp @@ -37,17 +37,10 @@ along with this program. If not, see . initShortcut(QStringLiteral(name).arg(value), i18n(name, value), key, &Workspace::fnSlot, value); -a = actionCollection->addAction(QStringLiteral("Program:kwin")); -a->setText(i18n("System")); - -a = actionCollection->addAction(QStringLiteral("Group:Navigation")); -a->setText(i18n("Navigation")); DEF(I18N_NOOP("Walk Through Window Tabs"), 0, slotActivateNextTab); DEF(I18N_NOOP("Walk Through Window Tabs (Reverse)"), 0, slotActivatePrevTab); DEF(I18N_NOOP("Remove Window From Group"), 0, slotUntab); -a = actionCollection->addAction(QStringLiteral("Group:Windows")); -a->setText(i18n("Windows")); DEF(I18N_NOOP("Window Operations Menu"), Qt::ALT + Qt::Key_F3, slotWindowOperations); DEF2("Window Close", I18N_NOOP("Close Window"), @@ -125,8 +118,6 @@ DEF2("Increase Opacity", I18N_NOOP("Increase Opacity of Active Window by 5 %"), DEF2("Decrease Opacity", I18N_NOOP("Decrease Opacity of Active Window by 5 %"), 0, slotLowerWindowOpacity); -a = actionCollection->addAction(QStringLiteral("Group:Window Desktop")); -a->setText(i18n("Window & Desktop")); DEF2("Window On All Desktops", I18N_NOOP("Keep Window on All Desktops"), 0, slotWindowOnAllDesktops); @@ -154,8 +145,6 @@ for (int i = 0; i < 8; ++i) { DEF(I18N_NOOP("Switch to Next Screen"), 0, slotSwitchToNextScreen); DEF(I18N_NOOP("Switch to Previous Screen"), 0, slotSwitchToPrevScreen); -a = actionCollection->addAction(QStringLiteral("Group:Miscellaneous")); -a->setText(i18n("Miscellaneous")); DEF(I18N_NOOP("Kill Window"), Qt::CTRL + Qt::ALT + Qt::Key_Escape, slotKillWindow); DEF(I18N_NOOP("Suspend Compositing"), Qt::SHIFT + Qt::ALT + Qt::Key_F12, slotToggleCompositing); DEF(I18N_NOOP("Invert Screen Colors"), 0, slotInvertScreen); diff --git a/useractions.cpp b/useractions.cpp index 90aad330a2..a2cd020e0d 100755 --- a/useractions.cpp +++ b/useractions.cpp @@ -183,8 +183,7 @@ void UserActionsMenu::helperDialog(const QString& message, const QWeakPointeractionCollection(); - QAction* action = keys->action(name); + QAction* action = Workspace::self()->findChild(name); assert(action != NULL); const auto shortcuts = KGlobalAccel::self()->shortcut(action); return QStringLiteral("%1 (%2)").arg(action->text()) @@ -268,7 +267,7 @@ void UserActionsMenu::init() }); auto setShortcut = [](QAction *action, const QString &actionName) { - const auto shortcuts = KGlobalAccel::self()->shortcut(Workspace::self()->actionCollection()->action(actionName)); + const auto shortcuts = KGlobalAccel::self()->shortcut(Workspace::self()->findChild(actionName)); if (!shortcuts.isEmpty()) { action->setShortcut(shortcuts.first()); } @@ -940,7 +939,8 @@ void Workspace::closeActivePopup() template void Workspace::initShortcut(const QString &actionName, const QString &description, const QKeySequence &shortcut, Slot slot, const QVariant &data) { - QAction *a = keys->addAction(actionName); + QAction *a = new QAction(this); + a->setObjectName(actionName); a->setText(description); if (data.isValid()) { a->setData(data); @@ -955,10 +955,6 @@ void Workspace::initShortcut(const QString &actionName, const QString &descripti */ void Workspace::initShortcuts() { - keys = new KActionCollection(this); - KActionCollection* actionCollection = keys; - QAction* a = 0L; - #define IN_KWIN #include "kwinbindings.cpp" #ifdef KWIN_BUILD_TABBOX diff --git a/workspace.cpp b/workspace.cpp index 5f68d267ce..3975b63b9d 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -147,7 +147,6 @@ Workspace::Workspace(bool restore) , session_saving(false) , block_focus(0) , m_userActionsMenu(new UserActionsMenu(this)) - , keys(0) , client_keys(NULL) , client_keys_dialog(NULL) , client_keys_client(NULL) diff --git a/workspace.h b/workspace.h index f8fba4d9c7..3ac8279034 100644 --- a/workspace.h +++ b/workspace.h @@ -191,9 +191,6 @@ public: int oldDisplayWidth() const; int oldDisplayHeight() const; - KActionCollection* actionCollection() const { - return keys; - } KActionCollection* clientKeys() const { return client_keys; } @@ -507,7 +504,6 @@ private: void modalActionsSwitch(bool enabled); - KActionCollection* keys; KActionCollection* client_keys; ShortcutDialog* client_keys_dialog; Client* client_keys_client;