Drop delegating Workspace::slotInvertScreen

Instead directly connect global shortcut to the method in Platform.
This commit is contained in:
Martin Flöser 2017-09-24 10:10:52 +02:00
parent e6ca321317
commit 9b1827803f
3 changed files with 13 additions and 8 deletions

View file

@ -42,6 +42,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define DEF5( name, key, functor, value ) \
initShortcut(QStringLiteral(name).arg(value), i18n(name, value), key, functor, value);
#define DEF6( name, key, target, fnSlot ) \
initShortcut(QStringLiteral(name), i18n(name), key, target, &fnSlot);
DEF(I18N_NOOP("Walk Through Window Tabs"), 0, slotActivateNextTab);
DEF(I18N_NOOP("Walk Through Window Tabs (Reverse)"), 0, slotActivatePrevTab);
@ -157,7 +160,7 @@ DEF(I18N_NOOP("Switch to Previous Screen"), 0, slotSwitchToPrevScreen);
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);
DEF6(I18N_NOOP("Invert Screen Colors"), 0, kwinApp()->platform(), Platform::invertScreen);
#undef DEF
#undef DEF2

View file

@ -979,6 +979,12 @@ void Workspace::closeActivePopup()
template <typename Slot>
void Workspace::initShortcut(const QString &actionName, const QString &description, const QKeySequence &shortcut, Slot slot, const QVariant &data)
{
initShortcut(actionName, description, shortcut, this, slot, data);
}
template <typename T, typename Slot>
void Workspace::initShortcut(const QString &actionName, const QString &description, const QKeySequence &shortcut, T *receiver, Slot slot, const QVariant &data)
{
QAction *a = new QAction(this);
a->setProperty("componentName", QStringLiteral(KWIN_NAME));
@ -989,7 +995,7 @@ void Workspace::initShortcut(const QString &actionName, const QString &descripti
}
KGlobalAccel::self()->setDefaultShortcut(a, QList<QKeySequence>() << shortcut);
KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << shortcut);
input()->registerShortcut(shortcut, a, this, slot);
input()->registerShortcut(shortcut, a, receiver, slot);
}
/*!
@ -1703,11 +1709,6 @@ void Workspace::slotWindowResize()
performWindowOperation(active_client, Options::UnrestrictedResizeOp);
}
void Workspace::slotInvertScreen()
{
kwinApp()->platform()->invertScreen();
}
#undef USABLE_ACTIVE_CLIENT
void AbstractClient::setShortcut(const QString& _cut)

View file

@ -444,7 +444,6 @@ public Q_SLOTS:
void slotSetupWindowShortcut();
void setupWindowShortcutDone(bool);
void slotToggleCompositing();
void slotInvertScreen();
void updateClientArea();
@ -502,6 +501,8 @@ private:
template <typename Slot>
void initShortcut(const QString &actionName, const QString &description, const QKeySequence &shortcut,
Slot slot, const QVariant &data = QVariant());
template <typename T, typename Slot>
void initShortcut(const QString &actionName, const QString &description, const QKeySequence &shortcut, T *receiver, Slot slot, const QVariant &data = QVariant());
void setupWindowShortcut(AbstractClient* c);
bool switchWindow(AbstractClient *c, Direction direction, QPoint curPos, int desktop);