Use KConfigXT in LookingGlass Effect
REVIEW: 106406
This commit is contained in:
parent
f1df9ee2f0
commit
500310b0e8
7 changed files with 51 additions and 45 deletions
|
@ -6,6 +6,8 @@ set( kwin4_effect_builtins_sources ${kwin4_effect_builtins_sources}
|
|||
lookingglass/lookingglass.cpp
|
||||
)
|
||||
|
||||
kde4_add_kcfg_files(kwin4_effect_builtins_sources lookingglass/lookingglassconfig.kcfgc)
|
||||
|
||||
# .desktop files
|
||||
install( FILES
|
||||
lookingglass/lookingglass.desktop
|
||||
|
@ -25,6 +27,8 @@ set( kwin4_effect_builtins_config_sources ${kwin4_effect_builtins_config_sources
|
|||
lookingglass/lookingglass_config.ui
|
||||
)
|
||||
|
||||
kde4_add_kcfg_files(kwin4_effect_builtins_config_sources lookingglass/lookingglassconfig.kcfgc)
|
||||
|
||||
# .desktop files
|
||||
install( FILES
|
||||
lookingglass/lookingglass_config.desktop
|
||||
|
|
|
@ -21,12 +21,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
|
||||
#include "lookingglass.h"
|
||||
|
||||
// KConfigSkeleton
|
||||
#include "lookingglassconfig.h"
|
||||
|
||||
#include <kwinglutils.h>
|
||||
#include <kwinglplatform.h>
|
||||
|
||||
#include <kactioncollection.h>
|
||||
#include <kaction.h>
|
||||
#include <kconfiggroup.h>
|
||||
#include <klocale.h>
|
||||
#include <kdebug.h>
|
||||
#include <KDE/KGlobal>
|
||||
|
@ -88,8 +90,8 @@ bool LookingGlassEffect::supported()
|
|||
|
||||
void LookingGlassEffect::reconfigure(ReconfigureFlags)
|
||||
{
|
||||
KConfigGroup conf = EffectsHandler::effectConfig("LookingGlass");
|
||||
initialradius = conf.readEntry("Radius", 200);
|
||||
LookingGlassConfig::self()->readConfig();
|
||||
initialradius = LookingGlassConfig::radius();
|
||||
radius = initialradius;
|
||||
kDebug(1212) << QString("Radius from config: %1").arg(radius) << endl;
|
||||
actionCollection->readSettings();
|
||||
|
|
12
effects/lookingglass/lookingglass.kcfg
Normal file
12
effects/lookingglass/lookingglass.kcfg
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?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-LookingGlass">
|
||||
<entry name="Radius" type="UInt">
|
||||
<default>200</default>
|
||||
</entry>
|
||||
</group>
|
||||
</kcfg>
|
|
@ -20,6 +20,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
|
||||
#include "lookingglass_config.h"
|
||||
|
||||
// KConfigSkeleton
|
||||
#include "lookingglassconfig.h"
|
||||
|
||||
#include <kwineffects.h>
|
||||
|
||||
#include <klocale.h>
|
||||
|
@ -51,8 +54,8 @@ LookingGlassEffectConfig::LookingGlassEffectConfig(QWidget* parent, const QVaria
|
|||
|
||||
layout->addWidget(m_ui);
|
||||
|
||||
addConfig(LookingGlassConfig::self(), m_ui);
|
||||
connect(m_ui->editor, SIGNAL(keyChange()), this, SLOT(changed()));
|
||||
connect(m_ui->radiusSpin, SIGNAL(valueChanged(int)), this, SLOT(changed()));
|
||||
|
||||
// Shortcut config. The shortcut belongs to the component "kwin"!
|
||||
m_actionCollection = new KActionCollection(this, KComponentData("kwin"));
|
||||
|
@ -82,42 +85,22 @@ LookingGlassEffectConfig::~LookingGlassEffectConfig()
|
|||
m_ui->editor->undoChanges();
|
||||
}
|
||||
|
||||
void LookingGlassEffectConfig::load()
|
||||
{
|
||||
KCModule::load();
|
||||
|
||||
KConfigGroup conf = EffectsHandler::effectConfig("LookingGlass");
|
||||
|
||||
int radius = conf.readEntry("Radius", 200);
|
||||
m_ui->radiusSpin->setValue(radius);
|
||||
emit changed(false);
|
||||
}
|
||||
|
||||
void LookingGlassEffectConfig::save()
|
||||
{
|
||||
kDebug(1212) << "Saving config of LookingGlass" ;
|
||||
//KCModule::save();
|
||||
|
||||
KConfigGroup conf = EffectsHandler::effectConfig("LookingGlass");
|
||||
|
||||
conf.writeEntry("Radius", m_ui->radiusSpin->value());
|
||||
KCModule::save();
|
||||
|
||||
m_ui->editor->save(); // undo() will restore to this state from now on
|
||||
|
||||
conf.sync();
|
||||
|
||||
emit changed(false);
|
||||
EffectsHandler::sendReloadMessage("lookingglass");
|
||||
}
|
||||
|
||||
void LookingGlassEffectConfig::defaults()
|
||||
{
|
||||
m_ui->radiusSpin->setValue(200);
|
||||
m_ui->editor->allDefault();
|
||||
emit changed(true);
|
||||
KCModule::defaults();
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
#include "lookingglass_config.moc"
|
||||
|
|
|
@ -45,7 +45,6 @@ public:
|
|||
virtual ~LookingGlassEffectConfig();
|
||||
|
||||
virtual void save();
|
||||
virtual void load();
|
||||
virtual void defaults();
|
||||
|
||||
private:
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
<ui version="4.0" >
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>KWin::LookingGlassEffectConfigForm</class>
|
||||
<widget class="QWidget" name="KWin::LookingGlassEffectConfigForm" >
|
||||
<property name="geometry" >
|
||||
<widget class="QWidget" name="KWin::LookingGlassEffectConfigForm">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
|
@ -9,32 +10,32 @@
|
|||
<height>185</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout" >
|
||||
<item row="1" column="0" colspan="2" >
|
||||
<widget class="KWin::GlobalShortcutsEditor" native="1" name="editor" />
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="KWin::GlobalShortcutsEditor" name="editor" native="true"/>
|
||||
</item>
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="label" >
|
||||
<property name="text" >
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>&Radius:</string>
|
||||
</property>
|
||||
<property name="alignment" >
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>radiusSpin</cstring>
|
||||
<property name="buddy">
|
||||
<cstring>kcfg_Radius</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" >
|
||||
<widget class="KIntSpinBox" name="radiusSpin" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
|
||||
<item row="0" column="1">
|
||||
<widget class="KIntSpinBox" name="kcfg_Radius">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximum" >
|
||||
<property name="maximum">
|
||||
<number>9999</number>
|
||||
</property>
|
||||
</widget>
|
||||
|
@ -50,7 +51,7 @@
|
|||
<customwidget>
|
||||
<class>KWin::GlobalShortcutsEditor</class>
|
||||
<extends>QWidget</extends>
|
||||
<header location="global" >kwineffects.h</header>
|
||||
<header location="global">kwineffects.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
|
|
5
effects/lookingglass/lookingglassconfig.kcfgc
Normal file
5
effects/lookingglass/lookingglassconfig.kcfgc
Normal file
|
@ -0,0 +1,5 @@
|
|||
File=lookingglass.kcfg
|
||||
ClassName=LookingGlassConfig
|
||||
NameSpace=KWin
|
||||
Singleton=true
|
||||
Mutators=true
|
Loading…
Reference in a new issue