diff --git a/effects/wobblywindows/CMakeLists.txt b/effects/wobblywindows/CMakeLists.txt index f3cb50b51a..a736bdab04 100644 --- a/effects/wobblywindows/CMakeLists.txt +++ b/effects/wobblywindows/CMakeLists.txt @@ -6,6 +6,8 @@ set( kwin4_effect_builtins_sources ${kwin4_effect_builtins_sources} wobblywindows/wobblywindows.cpp ) +kde4_add_kcfg_files(kwin4_effect_builtins_sources wobblywindows/wobblywindowsconfig.kcfgc) + # .desktop files install( FILES wobblywindows/wobblywindows.desktop @@ -20,6 +22,8 @@ set( kwin4_effect_builtins_config_sources ${kwin4_effect_builtins_config_sources wobblywindows/wobblywindows_config.ui ) +kde4_add_kcfg_files(kwin4_effect_builtins_config_sources wobblywindows/wobblywindowsconfig.kcfgc) + # .desktop files install( FILES wobblywindows/wobblywindows_config.desktop diff --git a/effects/wobblywindows/wobblywindows.cpp b/effects/wobblywindows/wobblywindows.cpp index d940a8aaa6..dbfbdc3516 100644 --- a/effects/wobblywindows/wobblywindows.cpp +++ b/effects/wobblywindows/wobblywindows.cpp @@ -10,9 +10,9 @@ License. See the file "COPYING" for the exact licensing terms. #include "wobblywindows.h" +#include "wobblywindowsconfig.h" #include -#include #include #define USE_ASSERT @@ -38,20 +38,6 @@ License. See the file "COPYING" for the exact licensing terms. namespace KWin { -static const qreal STIFFNESS = 0.15; -static const qreal DRAG = 0.80; -static const qreal MOVEFACTOR = 0.10; - -static const int XTESSELATION = 20; -static const int YTESSELATION = 20; - -static const qreal MINVELOCITY = 0.0; -static const qreal MAXVELOCITY = 1000.0; -static const qreal STOPVELOCITY = 0.5; -static const qreal MINACCELERATION = 0.0; -static const qreal MAXACCELERATION = 1000.0; -static const qreal STOPACCELERATION = 5.0; - struct ParameterSet { qreal stiffness; qreal drag; @@ -188,46 +174,45 @@ WobblyWindowsEffect::~WobblyWindowsEffect() void WobblyWindowsEffect::reconfigure(ReconfigureFlags) { - KConfigGroup conf = effects->effectConfig("Wobbly"); + WobblyWindowsConfig::self()->readConfig(); - - QString settingsMode = conf.readEntry("Settings", "Auto"); + QString settingsMode = WobblyWindowsConfig::settings(); if (settingsMode != "Custom") { - unsigned int wobblynessLevel = conf.readEntry("WobblynessLevel", 0); + unsigned int wobblynessLevel = WobblyWindowsConfig::wobblynessLevel(); if (wobblynessLevel > 4) { kDebug(1212) << "Wrong value for \"WobblynessLevel\" : " << wobblynessLevel; wobblynessLevel = 4; } setParameterSet(pset[wobblynessLevel]); - if (conf.readEntry("AdvancedMode", false)) { - m_stiffness = conf.readEntry("Stiffness", STIFFNESS * 100.0) / 100.0; - m_drag = conf.readEntry("Drag", DRAG * 100.0) / 100.0; - m_move_factor = conf.readEntry("MoveFactor", MOVEFACTOR * 100.0) / 100.0; + if (WobblyWindowsConfig::advancedMode()) { + m_stiffness = WobblyWindowsConfig::stiffness() / 100.0; + m_drag = WobblyWindowsConfig::drag() / 100.0; + m_move_factor = WobblyWindowsConfig::moveFactor() / 100.0; } } else { // Custom method, read all values from config file. - m_stiffness = conf.readEntry("Stiffness", STIFFNESS); - m_drag = conf.readEntry("Drag", DRAG); - m_move_factor = conf.readEntry("MoveFactor", MOVEFACTOR); + m_stiffness = WobblyWindowsConfig::stiffness() / 100.0; + m_drag = WobblyWindowsConfig::drag() / 100.0; + m_move_factor = WobblyWindowsConfig::moveFactor() / 100.0; - m_xTesselation = conf.readEntry("XTesselation", XTESSELATION); - m_yTesselation = conf.readEntry("YTesselation", YTESSELATION); + m_xTesselation = WobblyWindowsConfig::xTesselation(); + m_yTesselation = WobblyWindowsConfig::yTesselation(); - m_minVelocity = conf.readEntry("MinVelocity", MINVELOCITY); - m_maxVelocity = conf.readEntry("MaxVelocity", MAXVELOCITY); - m_stopVelocity = conf.readEntry("StopVelocity", STOPVELOCITY); - m_minAcceleration = conf.readEntry("MinAcceleration", MINACCELERATION); - m_maxAcceleration = conf.readEntry("MaxAcceleration", MAXACCELERATION); - m_stopAcceleration = conf.readEntry("StopAcceleration", STOPACCELERATION); + m_minVelocity = WobblyWindowsConfig::minVelocity(); + m_maxVelocity = WobblyWindowsConfig::maxVelocity(); + m_stopVelocity = WobblyWindowsConfig::stopVelocity(); + m_minAcceleration = WobblyWindowsConfig::minAcceleration(); + m_maxAcceleration = WobblyWindowsConfig::maxAcceleration(); + m_stopAcceleration = WobblyWindowsConfig::stopAcceleration(); - m_moveEffectEnabled = conf.readEntry("MoveEffect", true); - m_openEffectEnabled = conf.readEntry("OpenEffect", false); + m_moveEffectEnabled = WobblyWindowsConfig::moveEffect(); + m_openEffectEnabled = WobblyWindowsConfig::openEffect(); // disable close effect by default for now as it doesn't do what I want. - m_closeEffectEnabled = conf.readEntry("CloseEffect", false); + m_closeEffectEnabled = WobblyWindowsConfig::closeEffect(); } - m_moveWobble = conf.readEntry("MoveWobble", true); - m_resizeWobble = conf.readEntry("ResizeWobble", true); + m_moveWobble = WobblyWindowsConfig::moveWobble(); + m_resizeWobble = WobblyWindowsConfig::resizeWobble(); #if defined VERBOSE_MODE kDebug(1212) << "Parameters :\n" << diff --git a/effects/wobblywindows/wobblywindows.kcfg b/effects/wobblywindows/wobblywindows.kcfg new file mode 100644 index 0000000000..b8ddd4a64e --- /dev/null +++ b/effects/wobblywindows/wobblywindows.kcfg @@ -0,0 +1,66 @@ + + + + + + 0 + + + Auto + + + true + + + true + + + false + + + 15 + + + 80 + + + 10 + + + 20 + + + 20 + + + 0.0 + + + 1000.0 + + + 0.5 + + + 0.0 + + + 1000.0 + + + 5.0 + + + true + + + false + + + false + + + diff --git a/effects/wobblywindows/wobblywindows_config.cpp b/effects/wobblywindows/wobblywindows_config.cpp index 8b65b4881f..9a04dc6193 100644 --- a/effects/wobblywindows/wobblywindows_config.cpp +++ b/effects/wobblywindows/wobblywindows_config.cpp @@ -20,6 +20,8 @@ along with this program. If not, see . *********************************************************************/ #include "wobblywindows_config.h" +// KConfigSkeleton +#include "wobblywindowsconfig.h" #include @@ -81,15 +83,8 @@ WobblyWindowsEffectConfig::WobblyWindowsEffectConfig(QWidget* parent, const QVar { m_ui.setupUi(this); - connect(m_ui.wobblinessSlider, SIGNAL(valueChanged(int)), this, SLOT(changed())); - connect(m_ui.wobblinessSlider, SIGNAL(valueChanged(int)), this, SLOT(wobblinessChanged())); - connect(m_ui.moveBox, SIGNAL(stateChanged(int)), this, SLOT(changed())); - connect(m_ui.resizeBox, SIGNAL(stateChanged(int)), this, SLOT(changed())); - connect(m_ui.advancedBox, SIGNAL(stateChanged(int)), this, SLOT(changed())); - connect(m_ui.advancedBox, SIGNAL(stateChanged(int)), this, SLOT(advancedChanged())); - connect(m_ui.stiffnessSpin, SIGNAL(valueChanged(int)), this, SLOT(changed())); - connect(m_ui.dragSpin, SIGNAL(valueChanged(int)), this, SLOT(changed())); - connect(m_ui.moveFactorSpin, SIGNAL(valueChanged(int)), this, SLOT(changed())); + addConfig(WobblyWindowsConfig::self(), this); + connect(m_ui.kcfg_WobblynessLevel, SIGNAL(valueChanged(int)), this, SLOT(wobblinessChanged())); load(); } @@ -98,87 +93,20 @@ WobblyWindowsEffectConfig::~WobblyWindowsEffectConfig() { } -void WobblyWindowsEffectConfig::load() -{ - KCModule::load(); - - KConfigGroup conf = EffectsHandler::effectConfig("Wobbly"); - bool change = true; - - unsigned int wobblynessLevel = 0; - QString settingsMode = conf.readEntry("Settings", "Auto"); - if (settingsMode != "Custom") { - wobblynessLevel = conf.readEntry("WobblynessLevel", 0); - change = false; - } - if (wobblynessLevel > 4) { - wobblynessLevel = 4; - change = true; - } - m_ui.wobblinessSlider->setSliderPosition(wobblynessLevel); - - m_ui.moveBox->setChecked(conf.readEntry("MoveWobble", true)); - m_ui.resizeBox->setChecked(conf.readEntry("ResizeWobble", true)); - m_ui.advancedBox->setChecked(conf.readEntry("AdvancedMode", false)); - - m_ui.stiffnessSlider->setValue(conf.readEntry("Stiffness", pset[0].stiffness)); - m_ui.dragSlider->setValue(conf.readEntry("Drag", pset[0].drag)); - m_ui.moveFactorSlider->setValue(conf.readEntry("MoveFactor", pset[0].move_factor)); - - advancedChanged(); - - emit changed(change); -} - void WobblyWindowsEffectConfig::save() { - KConfigGroup conf = EffectsHandler::effectConfig("Wobbly"); - conf.writeEntry("Settings", "Auto"); + KCModule::save(); - conf.writeEntry("WobblynessLevel", m_ui.wobblinessSlider->value()); - - conf.writeEntry("MoveWobble", m_ui.moveBox->isChecked()); - conf.writeEntry("ResizeWobble", m_ui.resizeBox->isChecked()); - conf.writeEntry("AdvancedMode", m_ui.advancedBox->isChecked()); - - conf.writeEntry("Stiffness", m_ui.stiffnessSpin->value()); - conf.writeEntry("Drag", m_ui.dragSpin->value()); - conf.writeEntry("MoveFactor", m_ui.moveFactorSpin->value()); - - emit changed(false); EffectsHandler::sendReloadMessage("wobblywindows"); } -void WobblyWindowsEffectConfig::defaults() -{ - m_ui.wobblinessSlider->setSliderPosition(0); - - m_ui.moveBox->setChecked(true); - m_ui.resizeBox->setChecked(true); - m_ui.advancedBox->setChecked(false); - - m_ui.stiffnessSlider->setValue(pset[0].stiffness); - m_ui.dragSlider->setValue(pset[0].drag); - m_ui.moveFactorSlider->setValue(pset[0].move_factor); - - emit changed(true); -} - -void WobblyWindowsEffectConfig::advancedChanged() -{ - if (m_ui.advancedBox->isChecked()) - m_ui.advancedGroup->setEnabled(true); - else - m_ui.advancedGroup->setEnabled(false); -} - void WobblyWindowsEffectConfig::wobblinessChanged() { - ParameterSet preset = pset[m_ui.wobblinessSlider->value()]; + ParameterSet preset = pset[m_ui.kcfg_WobblynessLevel->value()]; - m_ui.stiffnessSlider->setValue(preset.stiffness); - m_ui.dragSlider->setValue(preset.drag); - m_ui.moveFactorSlider->setValue(preset.move_factor); + m_ui.kcfg_Stiffness->setValue(preset.stiffness); + m_ui.kcfg_Drag->setValue(preset.drag); + m_ui.kcfg_MoveFactor->setValue(preset.move_factor); } } // namespace diff --git a/effects/wobblywindows/wobblywindows_config.h b/effects/wobblywindows/wobblywindows_config.h index c918cff750..6531c77561 100644 --- a/effects/wobblywindows/wobblywindows_config.h +++ b/effects/wobblywindows/wobblywindows_config.h @@ -40,11 +40,8 @@ public: public slots: virtual void save(); - virtual void load(); - virtual void defaults(); private slots: - void advancedChanged(); void wobblinessChanged(); private: diff --git a/effects/wobblywindows/wobblywindows_config.ui b/effects/wobblywindows/wobblywindows_config.ui index d427dd295c..0498a64168 100644 --- a/effects/wobblywindows/wobblywindows_config.ui +++ b/effects/wobblywindows/wobblywindows_config.ui @@ -1,143 +1,147 @@ - + + WobblyWindowsEffectConfigForm - - + + 0 0 - 375 + 399 229 - - - - + + + + + false + + Advanced - - - - + + + + &Stiffness: - + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - stiffnessSlider + + kcfg_Stiffness - - - + + + 1 - + 50 - + 15 - + Qt::Horizontal - - - + + + 1 - + 50 - + 15 - - - + + + Dra&g: - + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - dragSlider + + kcfg_Drag - - - + + + &Move factor: - + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - moveFactorSlider + + kcfg_MoveFactor - - - + + + 50 - + 100 - + 85 - + Qt::Horizontal - - - + + + 50 - + 100 - + 85 - - - + + + 1 - + 25 - + 10 - + Qt::Horizontal - - - + + + 1 - + 25 - + 10 @@ -145,26 +149,26 @@ - - - + + + Wo&bble when moving - - - + + + Wobble when &resizing - - - + + + Qt::Vertical - + 20 0 @@ -172,61 +176,61 @@ - - - + + + Enable &advanced mode - - - + + + true - + &Wobbliness - + false - - - - + + + + Less - - - + + + 120 0 - + 4 - + Qt::Horizontal - - - + + + More - - - + + + Qt::Vertical - + 20 0 @@ -238,11 +242,6 @@ - advancedGroup - moveBox - resizeBox - advancedBox - basicGroup @@ -252,30 +251,30 @@ - wobblinessSlider - moveBox - resizeBox - advancedBox - stiffnessSlider + kcfg_WobblynessLevel + kcfg_MoveWobble + kcfg_ResizeWobble + kcfg_AdvancedMode + kcfg_Stiffness stiffnessSpin - dragSlider + kcfg_Drag dragSpin - moveFactorSlider + kcfg_MoveFactor moveFactorSpin - stiffnessSlider + kcfg_Stiffness valueChanged(int) stiffnessSpin setValue(int) - - 209 - 150 + + 304 + 149 - + 364 150 @@ -284,80 +283,96 @@ stiffnessSpin valueChanged(int) - stiffnessSlider + kcfg_Stiffness setValue(int) - + 364 150 - - 209 - 150 + + 304 + 149 - dragSlider + kcfg_Drag valueChanged(int) dragSpin setValue(int) - - 209 - 181 + + 304 + 177 - - 364 - 181 + + 378 + 180 dragSpin valueChanged(int) - dragSlider + kcfg_Drag setValue(int) - - 364 - 181 + + 378 + 180 - - 209 - 181 + + 304 + 177 - moveFactorSlider + kcfg_MoveFactor valueChanged(int) moveFactorSpin setValue(int) - - 209 - 212 + + 304 + 205 - - 364 - 212 + + 378 + 208 moveFactorSpin valueChanged(int) - moveFactorSlider + kcfg_MoveFactor setValue(int) - - 364 - 212 + + 378 + 208 - - 209 - 212 + + 304 + 205 + + + + + kcfg_AdvancedMode + toggled(bool) + advancedGroup + setEnabled(bool) + + + 249 + 80 + + + 220 + 131 diff --git a/effects/wobblywindows/wobblywindowsconfig.kcfgc b/effects/wobblywindows/wobblywindowsconfig.kcfgc new file mode 100644 index 0000000000..b678137034 --- /dev/null +++ b/effects/wobblywindows/wobblywindowsconfig.kcfgc @@ -0,0 +1,5 @@ +File=wobblywindows.kcfg +ClassName=WobblyWindowsConfig +NameSpace=KWin +Singleton=true +Mutators=true