1
/********************************************************************
2
KWin - the KDE window manager
3
This file is part of the KDE project.
5
Copyright (C) 2008 Cédric Borgese <cedric.borgese@gmail.com>
6
Copyright (C) 2008 Lucas Murray <lmurray@undefinedfire.com>
8
This program is free software; you can redistribute it and/or modify
9
it under the terms of the GNU General Public License as published by
10
the Free Software Foundation; either version 2 of the License, or
11
(at your option) any later version.
13
This program is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
GNU General Public License for more details.
18
You should have received a copy of the GNU General Public License
19
along with this program. If not, see <http://www.gnu.org/licenses/>.
20
*********************************************************************/
22
#include "wobblywindows_config.h"
24
#include <kwineffects.h>
29
#include <kconfiggroup.h>
34
KWIN_EFFECT_CONFIG_FACTORY
36
//-----------------------------------------------------------------------------
37
// WARNING: This is (kinda) copied from wobblywindows.cpp
45
ParameterSet set_0 = {
51
ParameterSet set_1 = {
57
ParameterSet set_2 = {
63
ParameterSet set_3 = {
69
ParameterSet set_4 = {
75
ParameterSet pset[5] = { set_0, set_1, set_2, set_3, set_4 };
77
//-----------------------------------------------------------------------------
79
WobblyWindowsEffectConfig::WobblyWindowsEffectConfig(QWidget* parent, const QVariantList& args) :
80
KCModule(EffectFactory::componentData(), parent, args)
84
connect(m_ui.wobblinessSlider, SIGNAL(valueChanged(int)), this, SLOT(changed()));
85
connect(m_ui.wobblinessSlider, SIGNAL(valueChanged(int)), this, SLOT(wobblinessChanged()));
86
connect(m_ui.moveBox, SIGNAL(stateChanged(int)), this, SLOT(changed()));
87
connect(m_ui.resizeBox, SIGNAL(stateChanged(int)), this, SLOT(changed()));
88
connect(m_ui.advancedBox, SIGNAL(stateChanged(int)), this, SLOT(changed()));
89
connect(m_ui.advancedBox, SIGNAL(stateChanged(int)), this, SLOT(advancedChanged()));
90
connect(m_ui.stiffnessSpin, SIGNAL(valueChanged(int)), this, SLOT(changed()));
91
connect(m_ui.dragSpin, SIGNAL(valueChanged(int)), this, SLOT(changed()));
92
connect(m_ui.moveFactorSpin, SIGNAL(valueChanged(int)), this, SLOT(changed()));
97
WobblyWindowsEffectConfig::~WobblyWindowsEffectConfig()
101
void WobblyWindowsEffectConfig::load()
105
KConfigGroup conf = EffectsHandler::effectConfig("Wobbly");
108
unsigned int wobblynessLevel = 0;
109
QString settingsMode = conf.readEntry("Settings", "Auto");
110
if (settingsMode != "Custom") {
111
wobblynessLevel = conf.readEntry("WobblynessLevel", 0);
114
if (wobblynessLevel > 4) {
118
m_ui.wobblinessSlider->setSliderPosition(wobblynessLevel);
120
m_ui.moveBox->setChecked(conf.readEntry("MoveWobble", true));
121
m_ui.resizeBox->setChecked(conf.readEntry("ResizeWobble", true));
122
m_ui.advancedBox->setChecked(conf.readEntry("AdvancedMode", false));
124
m_ui.stiffnessSlider->setValue(conf.readEntry("Stiffness", pset[0].stiffness));
125
m_ui.dragSlider->setValue(conf.readEntry("Drag", pset[0].drag));
126
m_ui.moveFactorSlider->setValue(conf.readEntry("MoveFactor", pset[0].move_factor));
130
emit changed(change);
133
void WobblyWindowsEffectConfig::save()
135
KConfigGroup conf = EffectsHandler::effectConfig("Wobbly");
136
conf.writeEntry("Settings", "Auto");
138
conf.writeEntry("WobblynessLevel", m_ui.wobblinessSlider->value());
140
conf.writeEntry("MoveWobble", m_ui.moveBox->isChecked());
141
conf.writeEntry("ResizeWobble", m_ui.resizeBox->isChecked());
142
conf.writeEntry("AdvancedMode", m_ui.advancedBox->isChecked());
144
conf.writeEntry("Stiffness", m_ui.stiffnessSpin->value());
145
conf.writeEntry("Drag", m_ui.dragSpin->value());
146
conf.writeEntry("MoveFactor", m_ui.moveFactorSpin->value());
149
EffectsHandler::sendReloadMessage("wobblywindows");
152
void WobblyWindowsEffectConfig::defaults()
154
m_ui.wobblinessSlider->setSliderPosition(0);
156
m_ui.moveBox->setChecked(true);
157
m_ui.resizeBox->setChecked(true);
158
m_ui.advancedBox->setChecked(false);
160
m_ui.stiffnessSlider->setValue(pset[0].stiffness);
161
m_ui.dragSlider->setValue(pset[0].drag);
162
m_ui.moveFactorSlider->setValue(pset[0].move_factor);
167
void WobblyWindowsEffectConfig::advancedChanged()
169
if (m_ui.advancedBox->isChecked())
170
m_ui.advancedGroup->setEnabled(true);
172
m_ui.advancedGroup->setEnabled(false);
175
void WobblyWindowsEffectConfig::wobblinessChanged()
177
ParameterSet preset = pset[m_ui.wobblinessSlider->value()];
179
m_ui.stiffnessSlider->setValue(preset.stiffness);
180
m_ui.dragSlider->setValue(preset.drag);
181
m_ui.moveFactorSlider->setValue(preset.move_factor);
186
#include "wobblywindows_config.moc"