diff --git a/effects/wobblywindows.cpp b/effects/wobblywindows.cpp index ebc10480e7..d53571b22a 100644 --- a/effects/wobblywindows.cpp +++ b/effects/wobblywindows.cpp @@ -198,6 +198,16 @@ WobblyWindowsEffect::WobblyWindowsEffect() 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; + + m_velocityFilter = GridFilter(conf.readEntry("VelocityFilterEnum", int(HeightRingLinearMean))); + m_accelerationFilter = GridFilter(conf.readEntry("AccelerationFilterEnum", int(HeightRingLinearMean))); + } } else // Custom method, read all values from config file. { diff --git a/effects/wobblywindows_config.cpp b/effects/wobblywindows_config.cpp index 025a2b3f7c..cd41cd39cf 100644 --- a/effects/wobblywindows_config.cpp +++ b/effects/wobblywindows_config.cpp @@ -3,6 +3,7 @@ This file is part of the KDE project. Copyright (C) 2008 Cédric Borgese + Copyright (C) 2008 Lucas Murray This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -34,14 +35,84 @@ KWIN_EFFECT_CONFIG_FACTORY namespace KWin { +//----------------------------------------------------------------------------- +// WARNING: This is (kinda) copied from wobblywindows.cpp + +struct ParameterSet +{ + int stiffness; + int drag; + int move_factor; + + WobblyWindowsEffect::GridFilter velocityFilter; + WobblyWindowsEffect::GridFilter accelerationFilter; +}; + +ParameterSet set_0 = +{ + 10, + 80, + 10, + WobblyWindowsEffect::FourRingLinearMean, + WobblyWindowsEffect::HeightRingLinearMean, +}; + +ParameterSet set_1 = +{ + 15, + 85, + 10, + WobblyWindowsEffect::HeightRingLinearMean, + WobblyWindowsEffect::MeanWithMean, +}; + +ParameterSet set_2 = +{ + 6, + 90, + 10, + WobblyWindowsEffect::HeightRingLinearMean, + WobblyWindowsEffect::NoFilter, +}; + +ParameterSet set_3 = +{ + 3, + 92, + 20, + WobblyWindowsEffect::HeightRingLinearMean, + WobblyWindowsEffect::HeightRingLinearMean, +}; + +ParameterSet set_4 = +{ + 1, + 97, + 25, + WobblyWindowsEffect::HeightRingLinearMean, + WobblyWindowsEffect::HeightRingLinearMean, +}; + +ParameterSet pset[5] = { set_0, set_1, set_2, set_3, set_4 }; + +//----------------------------------------------------------------------------- + WobblyWindowsEffectConfig::WobblyWindowsEffectConfig(QWidget* parent, const QVariantList& args) : KCModule(EffectFactory::componentData(), parent, args) { m_ui.setupUi(this); - connect(m_ui.slWobblyness, SIGNAL(valueChanged(int)), this, SLOT(slotSlWobblyness(int))); + 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())); + connect(m_ui.velocityCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed())); + connect(m_ui.accelerationCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed())); load(); } @@ -64,20 +135,25 @@ void WobblyWindowsEffectConfig::load() wobblynessLevel = conf.readEntry("WobblynessLevel", 1); change = false; } - if (wobblynessLevel > 4) { wobblynessLevel = 4; change = true; } + m_ui.wobblinessSlider->setSliderPosition(wobblynessLevel); - m_ui.slWobblyness->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)); - bool moving = conf.readEntry("MoveWobble", true); - m_ui.moveBox->setChecked(moving); + m_ui.stiffnessSlider->setValue(conf.readEntry("Stiffness", pset[1].stiffness)); + m_ui.dragSlider->setValue(conf.readEntry("Drag", pset[1].drag)); + m_ui.moveFactorSlider->setValue(conf.readEntry("MoveFactor", pset[1].move_factor)); - bool resizing = conf.readEntry("ResizeWobble", true); - m_ui.resizeBox->setChecked(resizing); + m_ui.velocityCombo->setCurrentIndex(conf.readEntry("VelocityFilterEnum", int(WobblyWindowsEffect::HeightRingLinearMean))); + m_ui.accelerationCombo->setCurrentIndex(conf.readEntry("AccelerationFilterEnum", int(WobblyWindowsEffect::MeanWithMean))); + + advancedChanged(); emit changed(change); } @@ -85,12 +161,20 @@ void WobblyWindowsEffectConfig::load() void WobblyWindowsEffectConfig::save() { KConfigGroup conf = EffectsHandler::effectConfig("Wobbly"); - conf.writeEntry("Settings", "Auto"); - conf.writeEntry("WobblynessLevel", m_ui.slWobblyness->value()); + + 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()); + + conf.writeEntry("VelocityFilterEnum", m_ui.velocityCombo->currentIndex()); + conf.writeEntry("AccelerationFilterEnum", m_ui.accelerationCombo->currentIndex()); emit changed(false); EffectsHandler::sendReloadMessage("wobblywindows"); @@ -98,17 +182,41 @@ void WobblyWindowsEffectConfig::save() void WobblyWindowsEffectConfig::defaults() { - m_ui.slWobblyness->setSliderPosition(2); - m_ui.moveBox->setChecked( true ); - m_ui.resizeBox->setChecked( true ); + m_ui.wobblinessSlider->setSliderPosition(1); + + m_ui.moveBox->setChecked(true); + m_ui.resizeBox->setChecked(true); + m_ui.advancedBox->setChecked(false); + + m_ui.stiffnessSlider->setValue(pset[1].stiffness); + m_ui.dragSlider->setValue(pset[1].drag); + m_ui.moveFactorSlider->setValue(pset[1].move_factor); + + m_ui.velocityCombo->setCurrentIndex(int(WobblyWindowsEffect::HeightRingLinearMean)); + m_ui.accelerationCombo->setCurrentIndex(int(WobblyWindowsEffect::MeanWithMean)); emit changed(true); } -void WobblyWindowsEffectConfig::slotSlWobblyness(int) -{ - 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()]; + + m_ui.stiffnessSlider->setValue(preset.stiffness); + m_ui.dragSlider->setValue(preset.drag); + m_ui.moveFactorSlider->setValue(preset.move_factor); + + m_ui.velocityCombo->setCurrentIndex(preset.velocityFilter); + m_ui.accelerationCombo->setCurrentIndex(preset.accelerationFilter); + } } // namespace diff --git a/effects/wobblywindows_config.h b/effects/wobblywindows_config.h index 9b749560eb..8324703db5 100644 --- a/effects/wobblywindows_config.h +++ b/effects/wobblywindows_config.h @@ -3,6 +3,7 @@ This file is part of the KDE project. Copyright (C) 2008 Cédric Borgese + Copyright (C) 2008 Lucas Murray This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -24,6 +25,7 @@ along with this program. If not, see . #include #include "ui_wobblywindows_config.h" +#include "wobblywindows.h" namespace KWin @@ -42,7 +44,8 @@ public slots: virtual void defaults(); private slots: - void slotSlWobblyness(int); + void advancedChanged(); + void wobblinessChanged(); private: ::Ui::WobblyWindowsEffectConfigForm m_ui; diff --git a/effects/wobblywindows_config.ui b/effects/wobblywindows_config.ui index 8de09a129b..30e49f31ec 100644 --- a/effects/wobblywindows_config.ui +++ b/effects/wobblywindows_config.ui @@ -5,80 +5,450 @@ 0 0 - 279 - 113 + 410 + 300 - - - - Wobblyness: + + + + true + + Basic + + + false + + + + + + + + Less + + + + + + + 4 + + + Qt::Horizontal + + + + + + + More + + + + + + + + + &Wobbliness: + + + wobblinessSlider + + + + + + + Qt::Horizontal + + + + 140 + 20 + + + + + - - - - Qt::Horizontal + + + + Advanced - - - 184 - 20 - - - + + + + + true + + + &Velocity filter: + + + false + + + Qt::LinksAccessibleByMouse + + + velocityCombo + + + + + + + + None + + + + + Four Ring Linear Mean + + + + + Height Ring Linear Mean + + + + + Mean With Mean + + + + + Mean With Median + + + + + + + + true + + + Acceleration &filter: + + + false + + + Qt::LinksAccessibleByMouse + + + velocityCombo + + + + + + + + None + + + + + Four Ring Linear Mean + + + + + Height Ring Linear Mean + + + + + Mean With Mean + + + + + Mean With Median + + + + + + + + + + &Stiffness: + + + stiffnessSlider + + + + + + + Dra&g: + + + dragSlider + + + + + + + &Move factor: + + + moveFactorSlider + + + + + + + 1 + + + 50 + + + 15 + + + Qt::Horizontal + + + + + + + 50 + + + 100 + + + 85 + + + Qt::Horizontal + + + + + + + 1 + + + 25 + + + 10 + + + Qt::Horizontal + + + + + + + 1 + + + 50 + + + 15 + + + + + + + 50 + + + 100 + + + 85 + + + + + + + 1 + + + 25 + + + 10 + + + + + + + - - - - - - Less - - - - - - - 4 - - - Qt::Horizontal - - - - - - - More - - - - - - + - Wobble when &moving + Wo&bble when moving - + Wobble when &resizing + + + + Qt::Vertical + + + + 20 + 0 + + + + + + + + Enable &advanced mode + + + - slWobblyness + wobblinessSlider moveBox resizeBox + advancedBox + stiffnessSlider + stiffnessSpin + dragSlider + dragSpin + moveFactorSlider + moveFactorSpin + velocityCombo + accelerationCombo - + + + stiffnessSlider + valueChanged(int) + stiffnessSpin + setValue(int) + + + 209 + 150 + + + 364 + 150 + + + + + stiffnessSpin + valueChanged(int) + stiffnessSlider + setValue(int) + + + 364 + 150 + + + 209 + 150 + + + + + dragSlider + valueChanged(int) + dragSpin + setValue(int) + + + 209 + 181 + + + 364 + 181 + + + + + dragSpin + valueChanged(int) + dragSlider + setValue(int) + + + 364 + 181 + + + 209 + 181 + + + + + moveFactorSlider + valueChanged(int) + moveFactorSpin + setValue(int) + + + 209 + 212 + + + 364 + 212 + + + + + moveFactorSpin + valueChanged(int) + moveFactorSlider + setValue(int) + + + 364 + 212 + + + 209 + 212 + + + +