Use KConfigXT in WindowGeometry

Thanks to Andrea Scarpino for providing the patch.

REVIEW: 106413
This commit is contained in:
Martin Gräßlin 2012-09-19 10:17:17 +02:00
parent 9ac20a382d
commit bd91fb10d7
7 changed files with 40 additions and 24 deletions

View file

@ -6,6 +6,8 @@ set( kwin4_effect_builtins_sources ${kwin4_effect_builtins_sources}
windowgeometry/windowgeometry.cpp
)
kde4_add_kcfg_files(kwin4_effect_builtins_sources windowgeometry/windowgeometryconfig.kcfgc)
# .desktop files
install( FILES
windowgeometry/windowgeometry.desktop
@ -20,6 +22,8 @@ set( kwin4_effect_builtins_config_sources ${kwin4_effect_builtins_config_sources
windowgeometry/windowgeometry_config.ui
)
kde4_add_kcfg_files(kwin4_effect_builtins_config_sources windowgeometry/windowgeometryconfig.kcfgc)
# .desktop files
install( FILES
windowgeometry/windowgeometry_config.desktop

View file

@ -19,6 +19,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#include "windowgeometry.h"
// KConfigSkeleton
#include "windowgeometryconfig.h"
#include <QStringBuilder>
#include <kwinconfig.h>
#include <kconfiggroup.h>
@ -73,9 +76,9 @@ WindowGeometry::~WindowGeometry()
void WindowGeometry::reconfigure(ReconfigureFlags)
{
KConfigGroup conf = effects->effectConfig("WindowGeometry");
iHandleMoves = conf.readEntry("Move", true);
iHandleResizes = conf.readEntry("Resize", true);
WindowGeometryConfiguration::self()->readConfig();
iHandleMoves = WindowGeometryConfiguration::move();
iHandleResizes = WindowGeometryConfiguration::resize();
}
void WindowGeometry::paintScreen(int mask, QRegion region, ScreenPaintData &data)

View 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-WindowGeometry">
<entry name="Move" type="Bool">
<default>true</default>
</entry>
<entry name="Resize" type="Bool">
<default>true</default>
</entry>
</group>
</kcfg>

View file

@ -19,6 +19,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#include "windowgeometry_config.h"
// KConfigSkeleton
#include "windowgeometryconfig.h"
#include <kwineffects.h>
#include <KActionCollection>
#include <kaction.h>
@ -50,8 +53,9 @@ WindowGeometryConfig::WindowGeometryConfig(QWidget* parent, const QVariantList&
myUi->shortcuts->addCollection(myActionCollection);
connect(myUi->shortcuts, SIGNAL(keyChange()), this, SLOT(changed()));
connect(myUi->handleMove, SIGNAL(toggled(bool)), this, SLOT(changed()));
connect(myUi->handleResize, SIGNAL(toggled(bool)), this, SLOT(changed()));
addConfig(WindowGeometryConfiguration::self(), myUi);
load();
}
WindowGeometryConfig::~WindowGeometryConfig()
@ -60,32 +64,18 @@ WindowGeometryConfig::~WindowGeometryConfig()
myUi->shortcuts->undoChanges();
}
void WindowGeometryConfig::load()
{
KCModule::load();
KConfigGroup conf = EffectsHandler::effectConfig("WindowGeometry");
myUi->handleMove->setChecked(conf.readEntry("Move", true));
myUi->handleResize->setChecked(conf.readEntry("Resize", true));
emit changed(false);
}
void WindowGeometryConfig::save()
{
KConfigGroup conf = EffectsHandler::effectConfig("WindowGeometry");
conf.writeEntry("Move", myUi->handleMove->isChecked());
conf.writeEntry("Resize", myUi->handleResize->isChecked());
KCModule::save();
myUi->shortcuts->save(); // undo() will restore to this state from now on
conf.sync();
emit changed(false);
EffectsHandler::sendReloadMessage("windowgeometry");
}
void WindowGeometryConfig::defaults()
{
myUi->handleMove->setChecked(true);
myUi->handleResize->setChecked(true);
myUi->shortcuts->allDefault();
emit changed(true);
}
} //namespace
#include "windowgeometry_config.moc"

View file

@ -45,7 +45,6 @@ public:
public slots:
void save();
void load();
void defaults();
private:

View file

@ -12,14 +12,14 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="handleMove">
<widget class="QCheckBox" name="kcfg_Move">
<property name="text">
<string>Display for moving windows</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="handleResize">
<widget class="QCheckBox" name="kcfg_Resize">
<property name="text">
<string>Display for resizing windows</string>
</property>

View file

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