KWin
Loading...
Searching...
No Matches
invert_config.cpp
Go to the documentation of this file.
1/*
2 KWin - the KDE window manager
3 This file is part of the KDE project.
4
5 SPDX-FileCopyrightText: 2007 Rivo Laks <rivolaks@hot.ee>
6
7 SPDX-License-Identifier: GPL-2.0-or-later
8*/
9
10#include "invert_config.h"
11#include <kwineffects_interface.h>
12
13#include <QAction>
14
15#include <KActionCollection>
16#include <KGlobalAccel>
17#include <KLocalizedString>
18#include <KPluginFactory>
19#include <KShortcutsEditor>
20
21#include <QVBoxLayout>
22
23K_PLUGIN_CLASS(KWin::InvertEffectConfig)
24
25namespace KWin
26{
27
28InvertEffectConfig::InvertEffectConfig(QObject *parent, const KPluginMetaData &data)
29 : KCModule(parent, data)
30{
31 QVBoxLayout *layout = new QVBoxLayout(widget());
32
33 // Shortcut config. The shortcut belongs to the component "kwin"!
34 KActionCollection *actionCollection = new KActionCollection(widget(), QStringLiteral("kwin"));
35 actionCollection->setComponentDisplayName(i18n("KWin"));
36
37 QAction *a = actionCollection->addAction(QStringLiteral("Invert"));
38 a->setText(i18n("Toggle Invert Effect"));
39 a->setProperty("isConfigurationAction", true);
40 KGlobalAccel::self()->setDefaultShortcut(a, QList<QKeySequence>() << (Qt::CTRL | Qt::META | Qt::Key_I));
41 KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << (Qt::CTRL | Qt::META | Qt::Key_I));
42
43 QAction *b = actionCollection->addAction(QStringLiteral("InvertWindow"));
44 b->setText(i18n("Toggle Invert Effect on Window"));
45 b->setProperty("isConfigurationAction", true);
46 KGlobalAccel::self()->setDefaultShortcut(b, QList<QKeySequence>() << (Qt::CTRL | Qt::META | Qt::Key_U));
47 KGlobalAccel::self()->setShortcut(b, QList<QKeySequence>() << (Qt::CTRL | Qt::META | Qt::Key_U));
48
49 mShortcutEditor = new KShortcutsEditor(actionCollection, widget(),
50 KShortcutsEditor::GlobalAction, KShortcutsEditor::LetterShortcutsDisallowed);
51 connect(mShortcutEditor, &KShortcutsEditor::keyChange, this, &KCModule::markAsChanged);
52 layout->addWidget(mShortcutEditor);
53}
54
56{
57 KCModule::load();
58
59 setNeedsSave(false);
60}
61
63{
64 KCModule::save();
65
66 mShortcutEditor->save(); // undo() will restore to this state from now on
67
68 setNeedsSave(false);
69 OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"),
70 QStringLiteral("/Effects"),
71 QDBusConnection::sessionBus());
72 interface.reconfigureEffect(QStringLiteral("invert"));
73}
74
76{
77 mShortcutEditor->allDefault();
78
79 setNeedsSave(true);
80}
81
82} // namespace
83
84#include "invert_config.moc"
85
86#include "moc_invert_config.cpp"
InvertEffectConfig(QObject *parent, const KPluginMetaData &data)