From 696ea9f4d30ef5431c6c48ef2114ef06bfd03679 Mon Sep 17 00:00:00 2001 From: Alexander Jones Date: Thu, 13 Sep 2012 15:25:18 -0500 Subject: [PATCH] Use KConfigXT in Magnifier Effect REVIEW: 106442 --- effects/magnifier/CMakeLists.txt | 3 ++ effects/magnifier/magnifier.cpp | 11 ++-- effects/magnifier/magnifier.kcfg | 18 +++++++ effects/magnifier/magnifier_config.cpp | 38 +++---------- effects/magnifier/magnifier_config.h | 1 - effects/magnifier/magnifier_config.ui | 71 +++++++++++++------------ effects/magnifier/magnifierconfig.kcfgc | 5 ++ 7 files changed, 75 insertions(+), 72 deletions(-) create mode 100644 effects/magnifier/magnifier.kcfg create mode 100644 effects/magnifier/magnifierconfig.kcfgc diff --git a/effects/magnifier/CMakeLists.txt b/effects/magnifier/CMakeLists.txt index c0c0050fd3..79a308fbae 100644 --- a/effects/magnifier/CMakeLists.txt +++ b/effects/magnifier/CMakeLists.txt @@ -6,6 +6,8 @@ set( kwin4_effect_builtins_sources ${kwin4_effect_builtins_sources} magnifier/magnifier.cpp ) +kde4_add_kcfg_files(kwin4_effect_builtins_sources magnifier/magnifierconfig.kcfgc) + # .desktop files install( FILES magnifier/magnifier.desktop @@ -19,6 +21,7 @@ set( kwin4_effect_builtins_config_sources ${kwin4_effect_builtins_config_sources magnifier/magnifier_config.cpp magnifier/magnifier_config.ui ) +kde4_add_kcfg_files(kwin4_effect_builtins_config_sources magnifier/magnifierconfig.kcfgc) # .desktop files install( FILES diff --git a/effects/magnifier/magnifier.cpp b/effects/magnifier/magnifier.cpp index 710de10b83..0103257fbd 100644 --- a/effects/magnifier/magnifier.cpp +++ b/effects/magnifier/magnifier.cpp @@ -21,12 +21,13 @@ along with this program. If not, see . *********************************************************************/ #include "magnifier.h" +// KConfigSkeleton +#include "magnifierconfig.h" #include #include #include -#include #include #include @@ -82,13 +83,13 @@ bool MagnifierEffect::supported() void MagnifierEffect::reconfigure(ReconfigureFlags) { - KConfigGroup conf = EffectsHandler::effectConfig("Magnifier"); + MagnifierConfig::self()->readConfig(); int width, height; - width = conf.readEntry("Width", 200); - height = conf.readEntry("Height", 200); + width = MagnifierConfig::width(); + height = MagnifierConfig::height(); magnifier_size = QSize(width, height); // Load the saved zoom value. - target_zoom = conf.readEntry("InitialZoom", target_zoom); + target_zoom = MagnifierConfig::initialZoom(); if (target_zoom != zoom) toggle(); } diff --git a/effects/magnifier/magnifier.kcfg b/effects/magnifier/magnifier.kcfg new file mode 100644 index 0000000000..8c36ce6637 --- /dev/null +++ b/effects/magnifier/magnifier.kcfg @@ -0,0 +1,18 @@ + + + + + + 200 + + + 200 + + + 1.0 + + + diff --git a/effects/magnifier/magnifier_config.cpp b/effects/magnifier/magnifier_config.cpp index 67c22ded96..fef5ab52db 100644 --- a/effects/magnifier/magnifier_config.cpp +++ b/effects/magnifier/magnifier_config.cpp @@ -19,6 +19,8 @@ along with this program. If not, see . *********************************************************************/ #include "magnifier_config.h" +// KConfigSkeleton +#include "magnifierconfig.h" #include @@ -51,9 +53,9 @@ MagnifierEffectConfig::MagnifierEffectConfig(QWidget* parent, const QVariantList layout->addWidget(m_ui); + addConfig(MagnifierConfig::self(), m_ui); + connect(m_ui->editor, SIGNAL(keyChange()), this, SLOT(changed())); - connect(m_ui->spinWidth, SIGNAL(valueChanged(int)), this, SLOT(changed())); - connect(m_ui->spinHeight, SIGNAL(valueChanged(int)), this, SLOT(changed())); // Shortcut config. The shortcut belongs to the component "kwin"! m_actionCollection = new KActionCollection(this, KComponentData("kwin")); @@ -75,6 +77,7 @@ MagnifierEffectConfig::MagnifierEffectConfig(QWidget* parent, const QVariantList a->setGlobalShortcut(KShortcut(Qt::META + Qt::Key_0)); m_ui->editor->addCollection(m_actionCollection); + load(); } MagnifierEffectConfig::~MagnifierEffectConfig() @@ -83,48 +86,21 @@ MagnifierEffectConfig::~MagnifierEffectConfig() m_ui->editor->undoChanges(); } -void MagnifierEffectConfig::load() -{ - KCModule::load(); - - KConfigGroup conf = EffectsHandler::effectConfig("Magnifier"); - - int width = conf.readEntry("Width", 200); - int height = conf.readEntry("Height", 200); - m_ui->spinWidth->setValue(width); - m_ui->spinHeight->setValue(height); - - - emit changed(false); -} - void MagnifierEffectConfig::save() { kDebug(1212) << "Saving config of Magnifier" ; - //KCModule::save(); - - KConfigGroup conf = EffectsHandler::effectConfig("Magnifier"); - - conf.writeEntry("Width", m_ui->spinWidth->value()); - conf.writeEntry("Height", m_ui->spinHeight->value()); m_ui->editor->save(); // undo() will restore to this state from now on - - conf.sync(); - - emit changed(false); + KCModule::save(); EffectsHandler::sendReloadMessage("magnifier"); } void MagnifierEffectConfig::defaults() { - m_ui->spinWidth->setValue(200); - m_ui->spinHeight->setValue(200); m_ui->editor->allDefault(); - emit changed(true); + KCModule::defaults(); } - } // namespace #include "magnifier_config.moc" diff --git a/effects/magnifier/magnifier_config.h b/effects/magnifier/magnifier_config.h index e0b5ac2af4..f21652a1b5 100644 --- a/effects/magnifier/magnifier_config.h +++ b/effects/magnifier/magnifier_config.h @@ -45,7 +45,6 @@ public: virtual ~MagnifierEffectConfig(); virtual void save(); - virtual void load(); virtual void defaults(); private: diff --git a/effects/magnifier/magnifier_config.ui b/effects/magnifier/magnifier_config.ui index da368850c0..3b02bdd3cb 100644 --- a/effects/magnifier/magnifier_config.ui +++ b/effects/magnifier/magnifier_config.ui @@ -1,7 +1,8 @@ - + + KWin::MagnifierEffectConfigForm - - + + 0 0 @@ -9,73 +10,73 @@ 181 - + - - + + Size - - - - + + + + &Width: - + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - spinWidth + + kcfg_Width - - - - + + + + 0 0 - + px - + 9999 - + 10 - - - + + + &Height: - + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - spinHeight + + kcfg_Height - - - - + + + + 0 0 - + px - + 9999 - + 10 @@ -84,7 +85,7 @@ - + @@ -97,7 +98,7 @@ KWin::GlobalShortcutsEditor QWidget -
kwineffects.h
+
kwineffects.h
1
diff --git a/effects/magnifier/magnifierconfig.kcfgc b/effects/magnifier/magnifierconfig.kcfgc new file mode 100644 index 0000000000..6286bc8113 --- /dev/null +++ b/effects/magnifier/magnifierconfig.kcfgc @@ -0,0 +1,5 @@ +File=magnifier.kcfg +ClassName=MagnifierConfig +NameSpace=KWin +Singleton=true +Mutators=true