KWin
Loading...
Searching...
No Matches
wobblywindows_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: 2008 Cédric Borgese <cedric.borgese@gmail.com>
6 SPDX-FileCopyrightText: 2008 Lucas Murray <lmurray@undefinedfire.com>
7
8 SPDX-License-Identifier: GPL-2.0-or-later
9*/
11
12#include <config-kwin.h>
13
14// KConfigSkeleton
15#include "wobblywindowsconfig.h"
16#include <kwineffects_interface.h>
17
18#include <KLocalizedString>
19#include <KPluginFactory>
20#include <kconfiggroup.h>
21
23
24namespace KWin
25{
26
27//-----------------------------------------------------------------------------
28// WARNING: This is (kinda) copied from wobblywindows.cpp
29
30struct ParameterSet
31{
33 int drag;
35};
36
37static const ParameterSet set_0 = {
38 15,
39 80,
40 10};
41
42static const ParameterSet set_1 = {
43 10,
44 85,
45 10};
46
47static const ParameterSet set_2 = {
48 6,
49 90,
50 10};
51
52static const ParameterSet set_3 = {
53 3,
54 92,
55 20};
56
57static const ParameterSet set_4 = {
58 1,
59 97,
60 25};
61
62ParameterSet pset[5] = {set_0, set_1, set_2, set_3, set_4};
63
64//-----------------------------------------------------------------------------
65
66WobblyWindowsEffectConfig::WobblyWindowsEffectConfig(QObject *parent, const KPluginMetaData &data)
67 : KCModule(parent, data)
68{
69 WobblyWindowsConfig::instance(KWIN_CONFIG);
70 m_ui.setupUi(widget());
71
72 addConfig(WobblyWindowsConfig::self(), widget());
73 connect(m_ui.kcfg_WobblynessLevel, &QSlider::valueChanged, this, &WobblyWindowsEffectConfig::wobblinessChanged);
74}
75
79
81{
82 KCModule::save();
83
84 OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"),
85 QStringLiteral("/Effects"),
86 QDBusConnection::sessionBus());
87 interface.reconfigureEffect(QStringLiteral("wobblywindows"));
88}
89
90void WobblyWindowsEffectConfig::wobblinessChanged()
91{
92 ParameterSet preset = pset[m_ui.kcfg_WobblynessLevel->value()];
93
94 m_ui.kcfg_Stiffness->setValue(preset.stiffness);
95 m_ui.kcfg_Drag->setValue(preset.drag);
96 m_ui.kcfg_MoveFactor->setValue(preset.move_factor);
97}
98
99} // namespace
100
101#include "wobblywindows_config.moc"
102
103#include "moc_wobblywindows_config.cpp"
WobblyWindowsEffectConfig(QObject *parent, const KPluginMetaData &data)