KWin
Loading...
Searching...
No Matches
magnifier_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 Christian Nitschkowski <christian.nitschkowski@kdemail.net>
6
7 SPDX-License-Identifier: GPL-2.0-or-later
8*/
9#include "magnifier_config.h"
10
11#include <config-kwin.h>
12
13// KConfigSkeleton
14#include "magnifierconfig.h"
15#include <kwineffects_interface.h>
16
17#include <QAction>
18
19#include <KActionCollection>
20#include <KGlobalAccel>
21#include <KLocalizedString>
22#include <KPluginFactory>
23#include <kconfiggroup.h>
24
25#include <QDebug>
26#include <QVBoxLayout>
27#include <QWidget>
28
29K_PLUGIN_CLASS(KWin::MagnifierEffectConfig)
30
31namespace KWin
32{
33MagnifierEffectConfig::MagnifierEffectConfig(QObject *parent, const KPluginMetaData &data)
34 : KCModule(parent, data)
35{
36 m_ui.setupUi(widget());
37
38 MagnifierConfig::instance(KWIN_CONFIG);
39 addConfig(MagnifierConfig::self(), widget());
40
41 connect(m_ui.editor, &KShortcutsEditor::keyChange, this, &KCModule::markAsChanged);
42
43 // Shortcut config. The shortcut belongs to the component "kwin"!
44 m_actionCollection = new KActionCollection(this, QStringLiteral("kwin"));
45
46 m_actionCollection->setComponentDisplayName(i18n("KWin"));
47 m_actionCollection->setConfigGroup(QStringLiteral("Magnifier"));
48 m_actionCollection->setConfigGlobal(true);
49
50 QAction *a;
51 a = m_actionCollection->addAction(KStandardAction::ZoomIn);
52 a->setProperty("isConfigurationAction", true);
53 KGlobalAccel::self()->setDefaultShortcut(a, QList<QKeySequence>() << (Qt::META | Qt::Key_Plus) << (Qt::META | Qt::Key_Equal));
54 KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << (Qt::META | Qt::Key_Plus) << (Qt::META | Qt::Key_Equal));
55
56 a = m_actionCollection->addAction(KStandardAction::ZoomOut);
57 a->setProperty("isConfigurationAction", true);
58 KGlobalAccel::self()->setDefaultShortcut(a, QList<QKeySequence>() << (Qt::META | Qt::Key_Minus));
59 KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << (Qt::META | Qt::Key_Minus));
60
61 a = m_actionCollection->addAction(KStandardAction::ActualSize);
62 a->setProperty("isConfigurationAction", true);
63 KGlobalAccel::self()->setDefaultShortcut(a, QList<QKeySequence>() << (Qt::META | Qt::Key_0));
64 KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << (Qt::META | Qt::Key_0));
65
66 m_ui.editor->addCollection(m_actionCollection);
67}
68
70{
71 qDebug() << "Saving config of Magnifier";
72
73 m_ui.editor->save(); // undo() will restore to this state from now on
74 KCModule::save();
75 OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"),
76 QStringLiteral("/Effects"),
77 QDBusConnection::sessionBus());
78 interface.reconfigureEffect(QStringLiteral("magnifier"));
79}
80
82{
83 m_ui.editor->allDefault();
84 KCModule::defaults();
85}
86
87} // namespace
88
89#include "magnifier_config.moc"
90
91#include "moc_magnifier_config.cpp"
MagnifierEffectConfig(QObject *parent, const KPluginMetaData &data)