Use KConfigXT in Dashboard Effect

Thanks to Andrea Scarpino for providing the patch.

REVIEW: 106390
This commit is contained in:
Martin Gräßlin 2012-09-19 09:13:01 +02:00
parent 914729324c
commit 8ad02b5582
7 changed files with 47 additions and 59 deletions

View file

@ -6,6 +6,8 @@ set( kwin4_effect_builtins_sources ${kwin4_effect_builtins_sources}
dashboard/dashboard.cpp
dashboard/dashboard.cpp )
kde4_add_kcfg_files(kwin4_effect_builtins_sources dashboard/dashboardconfig.kcfgc)
# .desktop files
install( FILES
dashboard/dashboard.desktop
@ -19,6 +21,8 @@ set( kwin4_effect_builtins_config_sources ${kwin4_effect_builtins_config_sources
dashboard/dashboard_config.cpp
dashboard/dashboard_config.ui )
kde4_add_kcfg_files(kwin4_effect_builtins_config_sources dashboard/dashboardconfig.kcfgc)
install( FILES
dashboard/dashboard_config.desktop
DESTINATION ${SERVICES_INSTALL_DIR}/kwin )

View file

@ -19,6 +19,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#include "dashboard.h"
// KConfigSkeleton
#include "dashboardconfig.h"
#include <KDE/KConfigGroup>
namespace KWin
@ -66,14 +69,10 @@ void DashboardEffect::unpropagate()
void DashboardEffect::reconfigure(ReconfigureFlags)
{
// read settings again
KConfigGroup config = EffectsHandler::effectConfig("Dashboard");
brightness = qreal(config.readEntry<int>("Brightness", 50)) / 100.0;
saturation = qreal(config.readEntry<int>("Saturation", 50)) / 100.0;
duration = config.readEntry<int>("Duration", 500);
blur = config.readEntry("Blur", false);
brightness = DashboardConfig::brightness()/ 100.0;
saturation = DashboardConfig::saturation()/ 100.0;
duration = DashboardConfig::duration() != 0 ? DashboardConfig::duration() : 500;
blur = DashboardConfig::blur();
timeline.setDuration(animationTime(duration));
}

View file

@ -0,0 +1,21 @@
<?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-Dashboard">
<entry name="Brightness" type="Int">
<default>50</default>
</entry>
<entry name="Saturation" type="Int">
<default>50</default>
</entry>
<entry name="Duration" type="Int">
<default>0</default>
</entry>
<entry name="Blur" type="Bool">
<default>false</default>
</entry>
</group>
</kcfg>

View file

@ -18,6 +18,9 @@
*/
#include "dashboard_config.h"
// KConfigSkeleton
#include "dashboardconfig.h"
#include <kwineffects.h>
namespace KWin
@ -30,10 +33,7 @@ DashboardEffectConfig::DashboardEffectConfig(QWidget *parent, const QVariantList
{
ui.setupUi(this);
connect(ui.brightness, SIGNAL(valueChanged(int)), SLOT(changed()));
connect(ui.saturation, SIGNAL(valueChanged(int)), SLOT(changed()));
connect(ui.duration, SIGNAL(valueChanged(int)), SLOT(changed()));
connect(ui.blur, SIGNAL(stateChanged(int)), SLOT(changed()));
addConfig(DashboardConfig::self(), this);
load();
}
@ -42,51 +42,12 @@ DashboardEffectConfig::~DashboardEffectConfig()
{
}
void DashboardEffectConfig::load()
{
KCModule::load();
KConfigGroup config = EffectsHandler::effectConfig("Dashboard");
const int brightness = config.readEntry<int>("Brightness", 50);
ui.brightness->setValue(brightness);
const int saturation = config.readEntry<int>("Saturation", 50);
ui.saturation->setValue(saturation);
const int duration = config.readEntry("Duration", 500);
ui.duration->setValue(duration);
bool blur = config.readEntry("Blur", false);
ui.blur->setChecked(blur);
emit changed(false);
}
void DashboardEffectConfig::save()
{
KCModule::save();
KConfigGroup config = EffectsHandler::effectConfig("Dashboard");
config.writeEntry("Brightness", ui.brightness->value());
config.writeEntry("Saturation", ui.saturation->value());
config.writeEntry("Duration", ui.duration->value());
config.writeEntry("Blur", ui.blur->isChecked());
config.sync();
emit changed(false);
EffectsHandler::sendReloadMessage("dashboard");
}
void DashboardEffectConfig::defaults()
{
ui.brightness->setValue(50);
ui.saturation->setValue(50);
ui.duration->setValue(500);
ui.blur->setChecked(false);
emit changed(true);
}
} // namespace KWin

View file

@ -35,8 +35,6 @@ public:
~DashboardEffectConfig();
void save();
void load();
void defaults();
private:
bool isBlurEffectAvailable();

View file

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>197</width>
<height>183</height>
<width>239</width>
<height>189</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
@ -44,7 +44,7 @@
</widget>
</item>
<item>
<widget class="QSlider" name="brightness">
<widget class="QSlider" name="kcfg_Brightness">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
@ -110,7 +110,7 @@
</widget>
</item>
<item>
<widget class="QSlider" name="saturation">
<widget class="QSlider" name="kcfg_Saturation">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
@ -166,7 +166,7 @@
</spacer>
</item>
<item>
<widget class="KIntSpinBox" name="duration">
<widget class="KIntSpinBox" name="kcfg_Duration">
<property name="maximum">
<number>3000</number>
</property>
@ -188,7 +188,7 @@
</layout>
</item>
<item>
<widget class="QCheckBox" name="blur">
<widget class="QCheckBox" name="kcfg_Blur">
<property name="toolTip">
<string>The blur effect must be enabled before it can be used.</string>
</property>

View file

@ -0,0 +1,5 @@
File=dashboard.kcfg
ClassName=DashboardConfig
NameSpace=KWin
Singleton=true
Mutators=true