Changeset View
Changeset View
Standalone View
Standalone View
effects/diminactive/diminactive_config.cpp
1 | /******************************************************************** | 1 | /******************************************************************** | ||
---|---|---|---|---|---|
2 | KWin - the KDE window manager | 2 | KWin - the KDE window manager | ||
3 | This file is part of the KDE project. | 3 | This file is part of the KDE project. | ||
4 | 4 | | |||
5 | Copyright (C) 2007 Christian Nitschkowski <christian.nitschkowski@kdemail.net> | 5 | Copyright (C) 2007 Christian Nitschkowski <christian.nitschkowski@kdemail.net> | ||
6 | Copyright (C) 2018 Vlad Zagorodniy <vladzzag@gmail.com> | ||||
6 | 7 | | |||
7 | This program is free software; you can redistribute it and/or modify | 8 | This program is free software; you can redistribute it and/or modify | ||
8 | it under the terms of the GNU General Public License as published by | 9 | it under the terms of the GNU General Public License as published by | ||
9 | the Free Software Foundation; either version 2 of the License, or | 10 | the Free Software Foundation; either version 2 of the License, or | ||
10 | (at your option) any later version. | 11 | (at your option) any later version. | ||
11 | 12 | | |||
12 | This program is distributed in the hope that it will be useful, | 13 | This program is distributed in the hope that it will be useful, | ||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | GNU General Public License for more details. | 16 | GNU General Public License for more details. | ||
16 | 17 | | |||
17 | You should have received a copy of the GNU General Public License | 18 | You should have received a copy of the GNU General Public License | ||
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 19 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | *********************************************************************/ | 20 | *********************************************************************/ | ||
20 | 21 | | |||
21 | #include "diminactive_config.h" | 22 | #include "diminactive_config.h" | ||
23 | | ||||
22 | // KConfigSkeleton | 24 | // KConfigSkeleton | ||
23 | #include "diminactiveconfig.h" | 25 | #include "diminactiveconfig.h" | ||
24 | #include <config-kwin.h> | 26 | #include <config-kwin.h> | ||
25 | 27 | | |||
26 | #include <kwineffects_interface.h> | 28 | #include <kwineffects_interface.h> | ||
27 | 29 | | |||
28 | #include <KLocalizedString> | | |||
29 | #include <kconfiggroup.h> | | |||
30 | #include <KAboutData> | 30 | #include <KAboutData> | ||
31 | #include <KPluginFactory> | 31 | #include <KPluginFactory> | ||
32 | 32 | | |||
33 | #include <QWidget> | | |||
34 | #include <QVBoxLayout> | | |||
35 | | ||||
36 | K_PLUGIN_FACTORY_WITH_JSON(DimInactiveEffectConfigFactory, | 33 | K_PLUGIN_FACTORY_WITH_JSON(DimInactiveEffectConfigFactory, | ||
37 | "diminactive_config.json", | 34 | "diminactive_config.json", | ||
38 | registerPlugin<KWin::DimInactiveEffectConfig>();) | 35 | registerPlugin<KWin::DimInactiveEffectConfig>();) | ||
39 | 36 | | |||
40 | namespace KWin | 37 | namespace KWin | ||
41 | { | 38 | { | ||
42 | 39 | | |||
43 | DimInactiveEffectConfigForm::DimInactiveEffectConfigForm(QWidget* parent) : QWidget(parent) | 40 | DimInactiveEffectConfig::DimInactiveEffectConfig(QWidget *parent, const QVariantList &args) | ||
41 | : KCModule(KAboutData::pluginData(QStringLiteral("diminactive")), parent, args) | ||||
44 | { | 42 | { | ||
45 | setupUi(this); | 43 | m_ui.setupUi(this); | ||
44 | DimInactiveConfig::instance(KWIN_CONFIG); | ||||
45 | addConfig(DimInactiveConfig::self(), this); | ||||
46 | load(); | ||||
46 | } | 47 | } | ||
47 | 48 | | |||
48 | DimInactiveEffectConfig::DimInactiveEffectConfig(QWidget* parent, const QVariantList& args) : | 49 | DimInactiveEffectConfig::~DimInactiveEffectConfig() | ||
49 | KCModule(KAboutData::pluginData(QStringLiteral("diminactive")), parent, args) | | |||
50 | { | 50 | { | ||
51 | m_ui = new DimInactiveEffectConfigForm(this); | | |||
52 | | ||||
53 | QVBoxLayout* layout = new QVBoxLayout(this); | | |||
54 | | ||||
55 | layout->addWidget(m_ui); | | |||
56 | | ||||
57 | DimInactiveConfig::instance(KWIN_CONFIG); | | |||
58 | addConfig(DimInactiveConfig::self(), m_ui); | | |||
59 | | ||||
60 | load(); | | |||
61 | } | 51 | } | ||
62 | 52 | | |||
63 | void DimInactiveEffectConfig::save() | 53 | void DimInactiveEffectConfig::save() | ||
64 | { | 54 | { | ||
65 | KCModule::save(); | 55 | KCModule::save(); | ||
56 | | ||||
66 | OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"), | 57 | OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"), | ||
67 | QStringLiteral("/Effects"), | 58 | QStringLiteral("/Effects"), | ||
68 | QDBusConnection::sessionBus()); | 59 | QDBusConnection::sessionBus()); | ||
69 | interface.reconfigureEffect(QStringLiteral("diminactive")); | 60 | interface.reconfigureEffect(QStringLiteral("diminactive")); | ||
70 | } | 61 | } | ||
71 | 62 | | |||
72 | } // namespace | 63 | } // namespace KWin | ||
73 | 64 | | |||
74 | #include "diminactive_config.moc" | 65 | #include "diminactive_config.moc" |