File indexing completed on 2024-11-10 04:57:13
0001 /* 0002 KWin - the KDE window manager 0003 This file is part of the KDE project. 0004 0005 SPDX-FileCopyrightText: 2008 Cédric Borgese <cedric.borgese@gmail.com> 0006 SPDX-FileCopyrightText: 2008 Lucas Murray <lmurray@undefinedfire.com> 0007 0008 SPDX-License-Identifier: GPL-2.0-or-later 0009 */ 0010 #include "wobblywindows_config.h" 0011 0012 #include <config-kwin.h> 0013 0014 // KConfigSkeleton 0015 #include "wobblywindowsconfig.h" 0016 #include <kwineffects_interface.h> 0017 0018 #include <KLocalizedString> 0019 #include <KPluginFactory> 0020 #include <kconfiggroup.h> 0021 0022 K_PLUGIN_CLASS(KWin::WobblyWindowsEffectConfig) 0023 0024 namespace KWin 0025 { 0026 0027 //----------------------------------------------------------------------------- 0028 // WARNING: This is (kinda) copied from wobblywindows.cpp 0029 0030 struct ParameterSet 0031 { 0032 int stiffness; 0033 int drag; 0034 int move_factor; 0035 }; 0036 0037 static const ParameterSet set_0 = { 0038 15, 0039 80, 0040 10}; 0041 0042 static const ParameterSet set_1 = { 0043 10, 0044 85, 0045 10}; 0046 0047 static const ParameterSet set_2 = { 0048 6, 0049 90, 0050 10}; 0051 0052 static const ParameterSet set_3 = { 0053 3, 0054 92, 0055 20}; 0056 0057 static const ParameterSet set_4 = { 0058 1, 0059 97, 0060 25}; 0061 0062 ParameterSet pset[5] = {set_0, set_1, set_2, set_3, set_4}; 0063 0064 //----------------------------------------------------------------------------- 0065 0066 WobblyWindowsEffectConfig::WobblyWindowsEffectConfig(QObject *parent, const KPluginMetaData &data) 0067 : KCModule(parent, data) 0068 { 0069 WobblyWindowsConfig::instance(KWIN_CONFIG); 0070 m_ui.setupUi(widget()); 0071 0072 addConfig(WobblyWindowsConfig::self(), widget()); 0073 connect(m_ui.kcfg_WobblynessLevel, &QSlider::valueChanged, this, &WobblyWindowsEffectConfig::wobblinessChanged); 0074 } 0075 0076 WobblyWindowsEffectConfig::~WobblyWindowsEffectConfig() 0077 { 0078 } 0079 0080 void WobblyWindowsEffectConfig::save() 0081 { 0082 KCModule::save(); 0083 0084 OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"), 0085 QStringLiteral("/Effects"), 0086 QDBusConnection::sessionBus()); 0087 interface.reconfigureEffect(QStringLiteral("wobblywindows")); 0088 } 0089 0090 void WobblyWindowsEffectConfig::wobblinessChanged() 0091 { 0092 ParameterSet preset = pset[m_ui.kcfg_WobblynessLevel->value()]; 0093 0094 m_ui.kcfg_Stiffness->setValue(preset.stiffness); 0095 m_ui.kcfg_Drag->setValue(preset.drag); 0096 m_ui.kcfg_MoveFactor->setValue(preset.move_factor); 0097 } 0098 0099 } // namespace 0100 0101 #include "wobblywindows_config.moc" 0102 0103 #include "moc_wobblywindows_config.cpp"