Use KConfigXT in Blur effect
REVIEW: 106400
This commit is contained in:
parent
607817eeef
commit
99fcab5c36
7 changed files with 34 additions and 40 deletions
|
@ -6,6 +6,8 @@ set( kwin4_effect_builtins_sources ${kwin4_effect_builtins_sources}
|
|||
blur/blur.cpp
|
||||
blur/blurshader.cpp )
|
||||
|
||||
kde4_add_kcfg_files(kwin4_effect_builtins_sources blur/blurconfig.kcfgc)
|
||||
|
||||
# .desktop files
|
||||
install( FILES
|
||||
blur/blur.desktop
|
||||
|
@ -19,6 +21,8 @@ set( kwin4_effect_builtins_config_sources ${kwin4_effect_builtins_config_sources
|
|||
blur/blur_config.cpp
|
||||
blur/blur_config.ui )
|
||||
|
||||
kde4_add_kcfg_files(kwin4_effect_builtins_config_sources blur/blurconfig.kcfgc)
|
||||
|
||||
# .desktop files
|
||||
install( FILES
|
||||
blur/blur_config.desktop
|
||||
|
|
|
@ -20,12 +20,13 @@
|
|||
|
||||
#include "blur.h"
|
||||
#include "blurshader.h"
|
||||
// KConfigSkeleton
|
||||
#include "blurconfig.h"
|
||||
|
||||
#include <X11/Xatom.h>
|
||||
|
||||
#include <QMatrix4x4>
|
||||
#include <QLinkedList>
|
||||
#include <KConfigGroup>
|
||||
#include <KDebug>
|
||||
|
||||
namespace KWin
|
||||
|
@ -86,11 +87,11 @@ void BlurEffect::reconfigure(ReconfigureFlags flags)
|
|||
{
|
||||
Q_UNUSED(flags)
|
||||
|
||||
KConfigGroup cg = EffectsHandler::effectConfig("Blur");
|
||||
int radius = qBound(2, cg.readEntry("BlurRadius", 12), 14);
|
||||
BlurConfig::self()->readConfig();
|
||||
int radius = qBound(2, BlurConfig::blurRadius(), 14);
|
||||
shader->setRadius(radius);
|
||||
|
||||
m_shouldCache = cg.readEntry("CacheTexture", true);
|
||||
m_shouldCache = BlurConfig::cacheTexture();
|
||||
|
||||
windows.clear();
|
||||
|
||||
|
|
15
effects/blur/blur.kcfg
Normal file
15
effects/blur/blur.kcfg
Normal file
|
@ -0,0 +1,15 @@
|
|||
<?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-Blur">
|
||||
<entry name="BlurRadius" type="Int">
|
||||
<default>12</default>
|
||||
</entry>
|
||||
<entry name="CacheTexture" type="Bool">
|
||||
<default>true</default>
|
||||
</entry>
|
||||
</group>
|
||||
</kcfg>
|
|
@ -18,6 +18,8 @@
|
|||
*/
|
||||
|
||||
#include "blur_config.h"
|
||||
// KConfigSkeleton
|
||||
#include "blurconfig.h"
|
||||
|
||||
#include <kwineffects.h>
|
||||
|
||||
|
@ -30,8 +32,7 @@ BlurEffectConfig::BlurEffectConfig(QWidget *parent, const QVariantList &args)
|
|||
: KCModule(EffectFactory::componentData(), parent, args)
|
||||
{
|
||||
ui.setupUi(this);
|
||||
connect(ui.slider, SIGNAL(valueChanged(int)), SLOT(valueChanged(int)));
|
||||
connect(ui.checkBox, SIGNAL(stateChanged(int)), SLOT(valueChanged(int)));
|
||||
addConfig(BlurConfig::self(), this);
|
||||
|
||||
load();
|
||||
}
|
||||
|
@ -40,40 +41,13 @@ BlurEffectConfig::~BlurEffectConfig()
|
|||
{
|
||||
}
|
||||
|
||||
void BlurEffectConfig::load()
|
||||
{
|
||||
KCModule::load();
|
||||
KConfigGroup cg = EffectsHandler::effectConfig("Blur");
|
||||
ui.slider->setValue(cg.readEntry("BlurRadius", 12) / 2);
|
||||
ui.checkBox->setChecked(cg.readEntry("CacheTexture", true));
|
||||
emit changed(false);
|
||||
}
|
||||
|
||||
void BlurEffectConfig::save()
|
||||
{
|
||||
KCModule::save();
|
||||
|
||||
KConfigGroup cg = EffectsHandler::effectConfig("Blur");
|
||||
cg.writeEntry("BlurRadius", ui.slider->value() * 2);
|
||||
cg.writeEntry("CacheTexture", ui.checkBox->isChecked());
|
||||
cg.sync();
|
||||
|
||||
emit changed(false);
|
||||
EffectsHandler::sendReloadMessage("blur");
|
||||
}
|
||||
|
||||
void BlurEffectConfig::defaults()
|
||||
{
|
||||
emit changed(true);
|
||||
}
|
||||
|
||||
void BlurEffectConfig::valueChanged(int value)
|
||||
{
|
||||
Q_UNUSED(value)
|
||||
emit changed(true);
|
||||
}
|
||||
|
||||
} // namespace KWin
|
||||
|
||||
#include "blur_config.moc"
|
||||
|
||||
|
|
|
@ -35,11 +35,6 @@ public:
|
|||
~BlurEffectConfig();
|
||||
|
||||
void save();
|
||||
void load();
|
||||
void defaults();
|
||||
|
||||
private slots:
|
||||
void valueChanged(int value);
|
||||
|
||||
private:
|
||||
::Ui::BlurEffectConfig ui;
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSlider" name="slider">
|
||||
<widget class="QSlider" name="kcfg_BlurRadius">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
|
@ -75,7 +75,7 @@
|
|||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox">
|
||||
<widget class="QCheckBox" name="kcfg_CacheTexture">
|
||||
<property name="toolTip">
|
||||
<string extracomment="Enables an internal texture cache which saves the background of the blurred area. This results in less repaints and in a slightly higher memory usage."/>
|
||||
</property>
|
||||
|
|
5
effects/blur/blurconfig.kcfgc
Normal file
5
effects/blur/blurconfig.kcfgc
Normal file
|
@ -0,0 +1,5 @@
|
|||
File=blur.kcfg
|
||||
ClassName=BlurConfig
|
||||
NameSpace=KWin
|
||||
Singleton=true
|
||||
Mutators=true
|
Loading…
Reference in a new issue