Use KConfigXT in FlipSwitch effect
REVIEW: 106401
This commit is contained in:
parent
500310b0e8
commit
607817eeef
7 changed files with 68 additions and 76 deletions
|
@ -6,6 +6,8 @@ set( kwin4_effect_builtins_sources ${kwin4_effect_builtins_sources}
|
|||
flipswitch/flipswitch.cpp
|
||||
)
|
||||
|
||||
kde4_add_kcfg_files(kwin4_effect_builtins_sources flipswitch/flipswitchconfig.kcfgc)
|
||||
|
||||
# .desktop files
|
||||
install( FILES
|
||||
flipswitch/flipswitch.desktop
|
||||
|
@ -20,6 +22,8 @@ set( kwin4_effect_builtins_config_sources ${kwin4_effect_builtins_config_sources
|
|||
flipswitch/flipswitch_config.ui
|
||||
)
|
||||
|
||||
kde4_add_kcfg_files(kwin4_effect_builtins_config_sources flipswitch/flipswitchconfig.kcfgc)
|
||||
|
||||
# .desktop files
|
||||
install( FILES
|
||||
flipswitch/flipswitch_config.desktop
|
||||
|
|
|
@ -18,12 +18,13 @@ You should have received a copy of the GNU General Public License
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************/
|
||||
#include "flipswitch.h"
|
||||
// KConfigSkeleton
|
||||
#include "flipswitchconfig.h"
|
||||
|
||||
#include <kwinconfig.h>
|
||||
#include <QFont>
|
||||
#include <QKeyEvent>
|
||||
#include <QMatrix4x4>
|
||||
#include <kconfiggroup.h>
|
||||
|
||||
#include <kdebug.h>
|
||||
#include <KAction>
|
||||
|
@ -94,7 +95,7 @@ bool FlipSwitchEffect::supported()
|
|||
|
||||
void FlipSwitchEffect::reconfigure(ReconfigureFlags)
|
||||
{
|
||||
KConfigGroup conf = effects->effectConfig("FlipSwitch");
|
||||
FlipSwitchConfig::self()->readConfig();
|
||||
foreach (ElectricBorder border, m_borderActivate) {
|
||||
effects->unreserveElectricBorder(border);
|
||||
}
|
||||
|
@ -103,30 +104,24 @@ void FlipSwitchEffect::reconfigure(ReconfigureFlags)
|
|||
}
|
||||
m_borderActivate.clear();
|
||||
m_borderActivateAll.clear();
|
||||
QList<int> borderList = QList<int>();
|
||||
borderList.append(int(ElectricNone));
|
||||
borderList = conf.readEntry("BorderActivate", borderList);
|
||||
foreach (int i, borderList) {
|
||||
foreach (int i, FlipSwitchConfig::borderActivate()) {
|
||||
m_borderActivate.append(ElectricBorder(i));
|
||||
effects->reserveElectricBorder(ElectricBorder(i));
|
||||
}
|
||||
borderList.clear();
|
||||
borderList.append(int(ElectricNone));
|
||||
borderList = conf.readEntry("BorderActivateAll", borderList);
|
||||
foreach (int i, borderList) {
|
||||
foreach (int i, FlipSwitchConfig::borderActivateAll()) {
|
||||
m_borderActivateAll.append(ElectricBorder(i));
|
||||
effects->reserveElectricBorder(ElectricBorder(i));
|
||||
}
|
||||
m_tabbox = conf.readEntry("TabBox", false);
|
||||
m_tabboxAlternative = conf.readEntry("TabBoxAlternative", false);
|
||||
float duration = animationTime(conf, "Duration", 200);
|
||||
m_tabbox = FlipSwitchConfig::tabBox();
|
||||
m_tabboxAlternative = FlipSwitchConfig::tabBoxAlternative();
|
||||
const int duration = animationTime(FlipSwitchConfig::duration() != 0 ? FlipSwitchConfig::duration() : 200);
|
||||
m_timeLine.setDuration(duration);
|
||||
m_startStopTimeLine.setDuration(duration);
|
||||
|
||||
m_angle = conf.readEntry("Angle", 30);
|
||||
m_xPosition = float(conf.readEntry("XPosition", 33)) / 100.0f;
|
||||
m_yPosition = float(conf.readEntry("YPosition", 100)) / 100.0f;
|
||||
m_windowTitle = conf.readEntry("WindowTitle", true);
|
||||
m_angle = FlipSwitchConfig::angle();
|
||||
m_xPosition = FlipSwitchConfig::xPosition() / 100.0f;
|
||||
m_yPosition = FlipSwitchConfig::yPosition() / 100.0f;
|
||||
m_windowTitle = FlipSwitchConfig::windowTitle();
|
||||
}
|
||||
|
||||
void FlipSwitchEffect::prePaintScreen(ScreenPrePaintData& data, int time)
|
||||
|
|
32
effects/flipswitch/flipswitch.kcfg
Normal file
32
effects/flipswitch/flipswitch.kcfg
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
|
||||
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
|
||||
<kcfgfile name="kwinrc"/>
|
||||
<group name="Effect-FlipSwitch">
|
||||
<entry name="BorderActivate" type="IntList" />
|
||||
<entry name="BorderActivateAll" type="IntList" />
|
||||
<entry name="TabBox" type="Bool">
|
||||
<default>false</default>
|
||||
</entry>
|
||||
<entry name="TabBoxAlternative" type="Bool">
|
||||
<default>false</default>
|
||||
</entry>
|
||||
<entry name="Duration" type="Int">
|
||||
<default>0</default>
|
||||
</entry>
|
||||
<entry name="Angle" type="Int">
|
||||
<default>30</default>
|
||||
</entry>
|
||||
<entry name="XPosition" type="Int">
|
||||
<default>33</default>
|
||||
</entry>
|
||||
<entry name="YPosition" type="Int">
|
||||
<default>100</default>
|
||||
</entry>
|
||||
<entry name="WindowTitle" type="Bool">
|
||||
<default>true</default>
|
||||
</entry>
|
||||
</group>
|
||||
</kcfg>
|
|
@ -18,6 +18,9 @@ You should have received a copy of the GNU General Public License
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************/
|
||||
#include "flipswitch_config.h"
|
||||
// KConfigSkeleton
|
||||
#include "flipswitchconfig.h"
|
||||
|
||||
#include <kwineffects.h>
|
||||
|
||||
#include <kconfiggroup.h>
|
||||
|
@ -59,12 +62,7 @@ FlipSwitchEffectConfig::FlipSwitchEffectConfig(QWidget* parent, const QVariantLi
|
|||
|
||||
m_ui->shortcutEditor->addCollection(m_actionCollection);
|
||||
|
||||
connect(m_ui->durationSpin, SIGNAL(valueChanged(int)), SLOT(changed()));
|
||||
connect(m_ui->angleSpin, SIGNAL(valueChanged(int)), SLOT(changed()));
|
||||
connect(m_ui->horizontalSlider, SIGNAL(valueChanged(int)), SLOT(changed()));
|
||||
connect(m_ui->verticalSlider, SIGNAL(valueChanged(int)), SLOT(changed()));
|
||||
connect(m_ui->windowTitleBox, SIGNAL(stateChanged(int)), SLOT(changed()));
|
||||
connect(m_ui->shortcutEditor, SIGNAL(keyChange()), this, SLOT(changed()));
|
||||
addConfig(FlipSwitchConfig::self(), m_ui);
|
||||
|
||||
load();
|
||||
}
|
||||
|
@ -73,53 +71,13 @@ FlipSwitchEffectConfig::~FlipSwitchEffectConfig()
|
|||
{
|
||||
}
|
||||
|
||||
void FlipSwitchEffectConfig::load()
|
||||
{
|
||||
KCModule::load();
|
||||
|
||||
KConfigGroup conf = EffectsHandler::effectConfig("FlipSwitch");
|
||||
|
||||
m_ui->durationSpin->setValue(conf.readEntry("Duration", 0));
|
||||
m_ui->angleSpin->setValue(conf.readEntry("Angle", 30));
|
||||
m_ui->horizontalSlider->setValue(conf.readEntry("XPosition", 33));
|
||||
// slider bottom is 0, effect bottom is 100
|
||||
m_ui->verticalSlider->setValue(100 - conf.readEntry("YPosition", 100));
|
||||
m_ui->windowTitleBox->setChecked(conf.readEntry("WindowTitle", true));
|
||||
|
||||
emit changed(false);
|
||||
}
|
||||
|
||||
void FlipSwitchEffectConfig::save()
|
||||
{
|
||||
KConfigGroup conf = EffectsHandler::effectConfig("FlipSwitch");
|
||||
KCModule::save();
|
||||
|
||||
conf.writeEntry("Duration", m_ui->durationSpin->value());
|
||||
conf.writeEntry("Angle", m_ui->angleSpin->value());
|
||||
conf.writeEntry("XPosition", m_ui->horizontalSlider->value());
|
||||
// slider bottom is 0, effect bottom is 100
|
||||
conf.writeEntry("YPosition", 100 - m_ui->verticalSlider->value());
|
||||
conf.writeEntry("WindowTitle", m_ui->windowTitleBox->isChecked());
|
||||
|
||||
m_ui->shortcutEditor->save();
|
||||
|
||||
conf.sync();
|
||||
|
||||
emit changed(false);
|
||||
EffectsHandler::sendReloadMessage("flipswitch");
|
||||
}
|
||||
|
||||
void FlipSwitchEffectConfig::defaults()
|
||||
{
|
||||
m_ui->durationSpin->setValue(0);
|
||||
m_ui->angleSpin->setValue(30);
|
||||
m_ui->horizontalSlider->setValue(33);
|
||||
// slider bottom is 0, effect bottom is 100
|
||||
m_ui->verticalSlider->setValue(0);
|
||||
m_ui->windowTitleBox->setChecked(true);
|
||||
m_ui->shortcutEditor->allDefault();
|
||||
emit changed(true);
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -46,8 +46,6 @@ public:
|
|||
|
||||
public slots:
|
||||
virtual void save();
|
||||
virtual void load();
|
||||
virtual void defaults();
|
||||
|
||||
private:
|
||||
FlipSwitchEffectConfigForm* m_ui;
|
||||
|
|
|
@ -26,12 +26,12 @@
|
|||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>durationSpin</cstring>
|
||||
<cstring>kcfg_Duration</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="KIntSpinBox" name="durationSpin">
|
||||
<widget class="KIntSpinBox" name="kcfg_Duration">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
|
@ -55,12 +55,12 @@
|
|||
<string>Angle:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>angleSpin</cstring>
|
||||
<cstring>kcfg_Angle</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="KIntSpinBox" name="angleSpin">
|
||||
<widget class="KIntSpinBox" name="kcfg_Angle">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
|
@ -81,14 +81,14 @@
|
|||
<string>Horizontal position of front:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>horizontalSlider</cstring>
|
||||
<cstring>kcfg_XPosition</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QSlider" name="horizontalSlider">
|
||||
<widget class="QSlider" name="kcfg_XPosition">
|
||||
<property name="maximum">
|
||||
<number>100</number>
|
||||
</property>
|
||||
|
@ -136,14 +136,14 @@
|
|||
<string>Vertical position of front:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>verticalSlider</cstring>
|
||||
<cstring>kcfg_YPosition</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QSlider" name="verticalSlider">
|
||||
<widget class="QSlider" name="kcfg_YPosition">
|
||||
<property name="maximum">
|
||||
<number>100</number>
|
||||
</property>
|
||||
|
@ -186,7 +186,7 @@
|
|||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="windowTitleBox">
|
||||
<widget class="QCheckBox" name="kcfg_WindowTitle">
|
||||
<property name="text">
|
||||
<string>Display window &titles</string>
|
||||
</property>
|
||||
|
@ -233,7 +233,7 @@
|
|||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>durationSpin</tabstop>
|
||||
<tabstop>kcfg_Duration</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
|
5
effects/flipswitch/flipswitchconfig.kcfgc
Normal file
5
effects/flipswitch/flipswitchconfig.kcfgc
Normal file
|
@ -0,0 +1,5 @@
|
|||
File=flipswitch.kcfg
|
||||
ClassName=FlipSwitchConfig
|
||||
NameSpace=KWin
|
||||
Singleton=true
|
||||
Mutators=true
|
Loading…
Reference in a new issue