KWin
Loading...
Searching...
No Matches
overvieweffectkcm.cpp
Go to the documentation of this file.
1/*
2 SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6#include "overvieweffectkcm.h"
7
8#include <config-kwin.h>
9
10#include "overviewconfig.h"
11
12#include <kwineffects_interface.h>
13
14#include <KActionCollection>
15#include <KGlobalAccel>
16#include <KLocalizedString>
17#include <KPluginFactory>
18
19#include <QAction>
20
21K_PLUGIN_CLASS(KWin::OverviewEffectConfig)
22
23namespace KWin
24{
25
26OverviewEffectConfig::OverviewEffectConfig(QObject *parent, const KPluginMetaData &data)
27 : KCModule(parent, data)
28{
29 ui.setupUi(widget());
30 OverviewConfig::instance(KWIN_CONFIG);
31 addConfig(OverviewConfig::self(), widget());
32
33 auto actionCollection = new KActionCollection(this, QStringLiteral("kwin"));
34
35 actionCollection->setComponentDisplayName(i18n("KWin"));
36 actionCollection->setConfigGroup(QStringLiteral("Overview"));
37 actionCollection->setConfigGlobal(true);
38
39 QAction *cycleAction = actionCollection->addAction(QStringLiteral("Cycle Overview"));
40 cycleAction->setText(i18nc("@action Overview and Grid View are the name of KWin effects", "Cycle through Overview and Grid View"));
41 cycleAction->setProperty("isConfigurationAction", true);
42 KGlobalAccel::self()->setDefaultShortcut(cycleAction, {});
43 KGlobalAccel::self()->setShortcut(cycleAction, {});
44
45 QAction *reverseCycleAction = actionCollection->addAction(QStringLiteral("Cycle Overview Opposite"));
46 reverseCycleAction->setText(i18nc("@action Grid View and Overview are the name of KWin effects", "Cycle through Grid View and Overview"));
47 reverseCycleAction->setProperty("isConfigurationAction", true);
48 KGlobalAccel::self()->setDefaultShortcut(reverseCycleAction, {});
49 KGlobalAccel::self()->setShortcut(reverseCycleAction, {});
50
51 const QKeySequence defaultOverviewShortcut = Qt::META | Qt::Key_W;
52 QAction *overviewAction = actionCollection->addAction(QStringLiteral("Overview"));
53 overviewAction->setText(i18nc("@action Overview is the name of a KWin effect", "Toggle Overview"));
54 overviewAction->setProperty("isConfigurationAction", true);
55 KGlobalAccel::self()->setDefaultShortcut(overviewAction, {defaultOverviewShortcut});
56 KGlobalAccel::self()->setShortcut(overviewAction, {defaultOverviewShortcut});
57
58 const QKeySequence defaultGridShortcut = Qt::META | Qt::Key_G;
59 QAction *gridAction = actionCollection->addAction(QStringLiteral("Grid View"));
60 gridAction->setText(i18nc("@action Grid View is the name of a KWin effect", "Toggle Grid View"));
61 gridAction->setProperty("isConfigurationAction", true);
62 KGlobalAccel::self()->setDefaultShortcut(gridAction, {defaultGridShortcut});
63 KGlobalAccel::self()->setShortcut(gridAction, {defaultGridShortcut});
64
65 ui.shortcutsEditor->addCollection(actionCollection);
66 connect(ui.shortcutsEditor, &KShortcutsEditor::keyChange, this, &KCModule::markAsChanged);
67}
68
70{
71 KCModule::save();
72 ui.shortcutsEditor->save();
73
74 OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"),
75 QStringLiteral("/Effects"),
76 QDBusConnection::sessionBus());
77 interface.reconfigureEffect(QStringLiteral("overview"));
78}
79
81{
82 ui.shortcutsEditor->allDefault();
83 KCModule::defaults();
84}
85
86} // namespace KWin
87
88#include "overvieweffectkcm.moc"
89
90#include "moc_overvieweffectkcm.cpp"
OverviewEffectConfig(QObject *parent, const KPluginMetaData &data)