Added "advanced mode" to wobbly windows settings.

svn path=/trunk/KDE/kdebase/workspace/; revision=857830
This commit is contained in:
Lucas Murray 2008-09-06 14:50:02 +00:00
parent 73f97db976
commit 3bba140b8c
4 changed files with 558 additions and 67 deletions

View file

@ -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.
{

View file

@ -3,6 +3,7 @@
This file is part of the KDE project.
Copyright (C) 2008 Cédric Borgese <cedric.borgese@gmail.com>
Copyright (C) 2008 Lucas Murray <lmurray@undefinedfire.com>
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

View file

@ -3,6 +3,7 @@
This file is part of the KDE project.
Copyright (C) 2008 Cédric Borgese <cedric.borgese@gmail.com>
Copyright (C) 2008 Lucas Murray <lmurray@undefinedfire.com>
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 <http://www.gnu.org/licenses/>.
#include <kcmodule.h>
#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;

View file

@ -5,80 +5,450 @@
<rect>
<x>0</x>
<y>0</y>
<width>279</width>
<height>113</height>
<width>410</width>
<height>300</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout" >
<item row="0" column="0" >
<widget class="QLabel" name="label_3" >
<property name="text" >
<string>Wobblyness:</string>
<item rowspan="5" row="1" column="0" >
<widget class="QGroupBox" name="basicGroup" >
<property name="enabled" >
<bool>true</bool>
</property>
<property name="title" >
<string>Basic</string>
</property>
<property name="checkable" >
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout_2" >
<item row="1" column="0" colspan="3" >
<layout class="QHBoxLayout" name="horizontalLayout" >
<item>
<widget class="QLabel" name="label" >
<property name="text" >
<string>Less</string>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="wobblinessSlider" >
<property name="maximum" >
<number>4</number>
</property>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2" >
<property name="text" >
<string>More</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="1" >
<widget class="QLabel" name="label_3" >
<property name="text" >
<string>&amp;Wobbliness:</string>
</property>
<property name="buddy" >
<cstring>wobblinessSlider</cstring>
</property>
</widget>
</item>
<item row="0" column="2" >
<spacer name="horizontalSpacer" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>140</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="0" column="1" >
<spacer name="horizontalSpacer" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
<item row="6" column="0" colspan="2" >
<widget class="QGroupBox" name="advancedGroup" >
<property name="title" >
<string>Advanced</string>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>184</width>
<height>20</height>
</size>
</property>
</spacer>
<layout class="QGridLayout" name="gridLayout_3" >
<item row="5" column="0" >
<widget class="QLabel" name="label_7" >
<property name="enabled" >
<bool>true</bool>
</property>
<property name="text" >
<string>&amp;Velocity filter:</string>
</property>
<property name="scaledContents" >
<bool>false</bool>
</property>
<property name="textInteractionFlags" >
<set>Qt::LinksAccessibleByMouse</set>
</property>
<property name="buddy" >
<cstring>velocityCombo</cstring>
</property>
</widget>
</item>
<item row="5" column="1" >
<widget class="QComboBox" name="velocityCombo" >
<item>
<property name="text" >
<string>None</string>
</property>
</item>
<item>
<property name="text" >
<string>Four Ring Linear Mean</string>
</property>
</item>
<item>
<property name="text" >
<string>Height Ring Linear Mean</string>
</property>
</item>
<item>
<property name="text" >
<string>Mean With Mean</string>
</property>
</item>
<item>
<property name="text" >
<string>Mean With Median</string>
</property>
</item>
</widget>
</item>
<item row="6" column="0" >
<widget class="QLabel" name="label_8" >
<property name="enabled" >
<bool>true</bool>
</property>
<property name="text" >
<string>Acceleration &amp;filter:</string>
</property>
<property name="scaledContents" >
<bool>false</bool>
</property>
<property name="textInteractionFlags" >
<set>Qt::LinksAccessibleByMouse</set>
</property>
<property name="buddy" >
<cstring>velocityCombo</cstring>
</property>
</widget>
</item>
<item row="6" column="1" >
<widget class="QComboBox" name="accelerationCombo" >
<item>
<property name="text" >
<string>None</string>
</property>
</item>
<item>
<property name="text" >
<string>Four Ring Linear Mean</string>
</property>
</item>
<item>
<property name="text" >
<string>Height Ring Linear Mean</string>
</property>
</item>
<item>
<property name="text" >
<string>Mean With Mean</string>
</property>
</item>
<item>
<property name="text" >
<string>Mean With Median</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0" colspan="2" >
<layout class="QGridLayout" name="gridLayout_4" >
<item row="0" column="0" >
<widget class="QLabel" name="label_4" >
<property name="text" >
<string>&amp;Stiffness:</string>
</property>
<property name="buddy" >
<cstring>stiffnessSlider</cstring>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="label_5" >
<property name="text" >
<string>Dra&amp;g:</string>
</property>
<property name="buddy" >
<cstring>dragSlider</cstring>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QLabel" name="label_6" >
<property name="text" >
<string>&amp;Move factor:</string>
</property>
<property name="buddy" >
<cstring>moveFactorSlider</cstring>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QSlider" name="stiffnessSlider" >
<property name="minimum" >
<number>1</number>
</property>
<property name="maximum" >
<number>50</number>
</property>
<property name="value" >
<number>15</number>
</property>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QSlider" name="dragSlider" >
<property name="minimum" >
<number>50</number>
</property>
<property name="maximum" >
<number>100</number>
</property>
<property name="value" >
<number>85</number>
</property>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="2" column="1" >
<widget class="QSlider" name="moveFactorSlider" >
<property name="minimum" >
<number>1</number>
</property>
<property name="maximum" >
<number>25</number>
</property>
<property name="value" >
<number>10</number>
</property>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="0" column="2" >
<widget class="QSpinBox" name="stiffnessSpin" >
<property name="minimum" >
<number>1</number>
</property>
<property name="maximum" >
<number>50</number>
</property>
<property name="value" >
<number>15</number>
</property>
</widget>
</item>
<item row="1" column="2" >
<widget class="QSpinBox" name="dragSpin" >
<property name="minimum" >
<number>50</number>
</property>
<property name="maximum" >
<number>100</number>
</property>
<property name="value" >
<number>85</number>
</property>
</widget>
</item>
<item row="2" column="2" >
<widget class="QSpinBox" name="moveFactorSpin" >
<property name="minimum" >
<number>1</number>
</property>
<property name="maximum" >
<number>25</number>
</property>
<property name="value" >
<number>10</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="1" column="0" colspan="2" >
<layout class="QHBoxLayout" name="horizontalLayout" >
<item>
<widget class="QLabel" name="label" >
<property name="text" >
<string>Less</string>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="slWobblyness" >
<property name="maximum" >
<number>4</number>
</property>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2" >
<property name="text" >
<string>More</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0" colspan="2" >
<item row="2" column="1" >
<widget class="QCheckBox" name="moveBox" >
<property name="text" >
<string>Wobble when &amp;moving</string>
<string>Wo&amp;bble when moving</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2" >
<item row="3" column="1" >
<widget class="QCheckBox" name="resizeBox" >
<property name="text" >
<string>Wobble when &amp;resizing</string>
</property>
</widget>
</item>
<item row="4" column="1" >
<spacer name="verticalSpacer" >
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item row="5" column="1" >
<widget class="QCheckBox" name="advancedBox" >
<property name="text" >
<string>Enable &amp;advanced mode</string>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>slWobblyness</tabstop>
<tabstop>wobblinessSlider</tabstop>
<tabstop>moveBox</tabstop>
<tabstop>resizeBox</tabstop>
<tabstop>advancedBox</tabstop>
<tabstop>stiffnessSlider</tabstop>
<tabstop>stiffnessSpin</tabstop>
<tabstop>dragSlider</tabstop>
<tabstop>dragSpin</tabstop>
<tabstop>moveFactorSlider</tabstop>
<tabstop>moveFactorSpin</tabstop>
<tabstop>velocityCombo</tabstop>
<tabstop>accelerationCombo</tabstop>
</tabstops>
<resources/>
<connections/>
<connections>
<connection>
<sender>stiffnessSlider</sender>
<signal>valueChanged(int)</signal>
<receiver>stiffnessSpin</receiver>
<slot>setValue(int)</slot>
<hints>
<hint type="sourcelabel" >
<x>209</x>
<y>150</y>
</hint>
<hint type="destinationlabel" >
<x>364</x>
<y>150</y>
</hint>
</hints>
</connection>
<connection>
<sender>stiffnessSpin</sender>
<signal>valueChanged(int)</signal>
<receiver>stiffnessSlider</receiver>
<slot>setValue(int)</slot>
<hints>
<hint type="sourcelabel" >
<x>364</x>
<y>150</y>
</hint>
<hint type="destinationlabel" >
<x>209</x>
<y>150</y>
</hint>
</hints>
</connection>
<connection>
<sender>dragSlider</sender>
<signal>valueChanged(int)</signal>
<receiver>dragSpin</receiver>
<slot>setValue(int)</slot>
<hints>
<hint type="sourcelabel" >
<x>209</x>
<y>181</y>
</hint>
<hint type="destinationlabel" >
<x>364</x>
<y>181</y>
</hint>
</hints>
</connection>
<connection>
<sender>dragSpin</sender>
<signal>valueChanged(int)</signal>
<receiver>dragSlider</receiver>
<slot>setValue(int)</slot>
<hints>
<hint type="sourcelabel" >
<x>364</x>
<y>181</y>
</hint>
<hint type="destinationlabel" >
<x>209</x>
<y>181</y>
</hint>
</hints>
</connection>
<connection>
<sender>moveFactorSlider</sender>
<signal>valueChanged(int)</signal>
<receiver>moveFactorSpin</receiver>
<slot>setValue(int)</slot>
<hints>
<hint type="sourcelabel" >
<x>209</x>
<y>212</y>
</hint>
<hint type="destinationlabel" >
<x>364</x>
<y>212</y>
</hint>
</hints>
</connection>
<connection>
<sender>moveFactorSpin</sender>
<signal>valueChanged(int)</signal>
<receiver>moveFactorSlider</receiver>
<slot>setValue(int)</slot>
<hints>
<hint type="sourcelabel" >
<x>364</x>
<y>212</y>
</hint>
<hint type="destinationlabel" >
<x>209</x>
<y>212</y>
</hint>
</hints>
</connection>
</connections>
</ui>