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>
32 KWIN_EFFECT_CONFIG_FACTORY
38 //-----------------------------------------------------------------------------
39 // WARNING: This is (kinda) copied from wobblywindows.cpp
83 ParameterSet pset
[5] = { set_0
, set_1
, set_2
, set_3
, set_4
};
85 //-----------------------------------------------------------------------------
87 WobblyWindowsEffectConfig::WobblyWindowsEffectConfig(QWidget
* parent
, const QVariantList
& args
) :
88 KCModule(EffectFactory::componentData(), parent
, args
)
92 connect(m_ui
.wobblinessSlider
, SIGNAL(valueChanged(int)), this, SLOT(changed()));
93 connect(m_ui
.wobblinessSlider
, SIGNAL(valueChanged(int)), this, SLOT(wobblinessChanged()));
94 connect(m_ui
.moveBox
, SIGNAL(stateChanged(int)), this, SLOT(changed()));
95 connect(m_ui
.resizeBox
, SIGNAL(stateChanged(int)), this, SLOT(changed()));
96 connect(m_ui
.advancedBox
, SIGNAL(stateChanged(int)), this, SLOT(changed()));
97 connect(m_ui
.advancedBox
, SIGNAL(stateChanged(int)), this, SLOT(advancedChanged()));
98 connect(m_ui
.stiffnessSpin
, SIGNAL(valueChanged(int)), this, SLOT(changed()));
99 connect(m_ui
.dragSpin
, SIGNAL(valueChanged(int)), this, SLOT(changed()));
100 connect(m_ui
.moveFactorSpin
, SIGNAL(valueChanged(int)), this, SLOT(changed()));
105 WobblyWindowsEffectConfig::~WobblyWindowsEffectConfig()
109 void WobblyWindowsEffectConfig::load()
113 KConfigGroup conf
= EffectsHandler::effectConfig("Wobbly");
116 unsigned int wobblynessLevel
= 0;
117 QString settingsMode
= conf
.readEntry("Settings", "Auto");
118 if (settingsMode
!= "Custom")
120 wobblynessLevel
= conf
.readEntry("WobblynessLevel", 0);
123 if (wobblynessLevel
> 4)
128 m_ui
.wobblinessSlider
->setSliderPosition(wobblynessLevel
);
130 m_ui
.moveBox
->setChecked(conf
.readEntry("MoveWobble", true));
131 m_ui
.resizeBox
->setChecked(conf
.readEntry("ResizeWobble", true));
132 m_ui
.advancedBox
->setChecked(conf
.readEntry("AdvancedMode", false));
134 m_ui
.stiffnessSlider
->setValue(conf
.readEntry("Stiffness", pset
[0].stiffness
));
135 m_ui
.dragSlider
->setValue(conf
.readEntry("Drag", pset
[0].drag
));
136 m_ui
.moveFactorSlider
->setValue(conf
.readEntry("MoveFactor", pset
[0].move_factor
));
140 emit
changed(change
);
143 void WobblyWindowsEffectConfig::save()
145 KConfigGroup conf
= EffectsHandler::effectConfig("Wobbly");
146 conf
.writeEntry("Settings", "Auto");
148 conf
.writeEntry("WobblynessLevel", m_ui
.wobblinessSlider
->value());
150 conf
.writeEntry("MoveWobble", m_ui
.moveBox
->isChecked());
151 conf
.writeEntry("ResizeWobble", m_ui
.resizeBox
->isChecked());
152 conf
.writeEntry("AdvancedMode", m_ui
.advancedBox
->isChecked());
154 conf
.writeEntry("Stiffness", m_ui
.stiffnessSpin
->value());
155 conf
.writeEntry("Drag", m_ui
.dragSpin
->value());
156 conf
.writeEntry("MoveFactor", m_ui
.moveFactorSpin
->value());
159 EffectsHandler::sendReloadMessage("wobblywindows");
162 void WobblyWindowsEffectConfig::defaults()
164 m_ui
.wobblinessSlider
->setSliderPosition(0);
166 m_ui
.moveBox
->setChecked(true);
167 m_ui
.resizeBox
->setChecked(true);
168 m_ui
.advancedBox
->setChecked(false);
170 m_ui
.stiffnessSlider
->setValue(pset
[0].stiffness
);
171 m_ui
.dragSlider
->setValue(pset
[0].drag
);
172 m_ui
.moveFactorSlider
->setValue(pset
[0].move_factor
);
177 void WobblyWindowsEffectConfig::advancedChanged()
179 if(m_ui
.advancedBox
->isChecked())
180 m_ui
.advancedGroup
->setEnabled(true);
182 m_ui
.advancedGroup
->setEnabled(false);
185 void WobblyWindowsEffectConfig::wobblinessChanged()
187 ParameterSet preset
= pset
[m_ui
.wobblinessSlider
->value()];
189 m_ui
.stiffnessSlider
->setValue(preset
.stiffness
);
190 m_ui
.dragSlider
->setValue(preset
.drag
);
191 m_ui
.moveFactorSlider
->setValue(preset
.move_factor
);
196 #include "wobblywindows_config.moc"