From c8c15f00579938ce3589d44663c32415baefdd0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Fl=C3=B6ser?= Date: Fri, 21 Jul 2017 16:10:14 +0200 Subject: [PATCH] Use std::bind expression for Workspace::slotWindowtoDesktop Summary: This way we don't need the sender() hack to get the value set on the QAction. Test Plan: New autotest in master still passes Reviewers: #kwin, #plasma Subscribers: plasma-devel Tags: #plasma Differential Revision: https://phabricator.kde.org/D6811 --- kwinbindings.cpp | 5 ++++- useractions.cpp | 3 +-- workspace.h | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/kwinbindings.cpp b/kwinbindings.cpp index 4448f7680f..4ea6429321 100644 --- a/kwinbindings.cpp +++ b/kwinbindings.cpp @@ -39,6 +39,9 @@ along with this program. If not, see . #define DEF4( name, descr, key, functor ) \ initShortcut(QStringLiteral(name), i18n(descr), key, functor); +#define DEF5( name, key, functor, value ) \ + initShortcut(QStringLiteral(name).arg(value), i18n(name, value), key, functor, value); + DEF(I18N_NOOP("Walk Through Window Tabs"), 0, slotActivateNextTab); DEF(I18N_NOOP("Walk Through Window Tabs (Reverse)"), 0, slotActivatePrevTab); @@ -129,7 +132,7 @@ DEF2("Window On All Desktops", I18N_NOOP("Keep Window on All Desktops"), 0, slotWindowOnAllDesktops); for (int i = 1; i < 21; ++i) { - DEF3(I18N_NOOP("Window to Desktop %1"), 0, slotWindowToDesktop, i); + DEF5(I18N_NOOP("Window to Desktop %1"), 0, std::bind(&Workspace::slotWindowToDesktop, this, i), i); } DEF(I18N_NOOP("Window to Next Desktop"), 0, slotWindowToNextDesktop); DEF(I18N_NOOP("Window to Previous Desktop"), 0, slotWindowToPreviousDesktop); diff --git a/useractions.cpp b/useractions.cpp index 850d826237..c3a0360dc4 100644 --- a/useractions.cpp +++ b/useractions.cpp @@ -1247,10 +1247,9 @@ static uint senderValue(QObject *sender) #define USABLE_ACTIVE_CLIENT (active_client && !(active_client->isDesktop() || active_client->isDock())) -void Workspace::slotWindowToDesktop() +void Workspace::slotWindowToDesktop(uint i) { if (USABLE_ACTIVE_CLIENT) { - const uint i = senderValue(sender()); if (i < 1) return; diff --git a/workspace.h b/workspace.h index 0b3ac42d89..2030043068 100644 --- a/workspace.h +++ b/workspace.h @@ -383,7 +383,7 @@ public Q_SLOTS: void performWindowOperation(KWin::AbstractClient* c, Options::WindowOperation op); // Keybindings //void slotSwitchToWindow( int ); - void slotWindowToDesktop(); + void slotWindowToDesktop(uint i); //void slotWindowToListPosition( int ); void slotSwitchToScreen();