From b8630d19ecbe4fb1076c942d1a61ee76239ba2c9 Mon Sep 17 00:00:00 2001 From: Salva Ardid Date: Tue, 11 Sep 2012 18:42:46 -0400 Subject: [PATCH] Use KConfigXT in DimInactive Effect REVIEW: 106422 --- effects/diminactive/CMakeLists.txt | 4 + effects/diminactive/diminactive.cpp | 14 ++- effects/diminactive/diminactive.kcfg | 24 ++++ effects/diminactive/diminactive_config.cpp | 50 +------- effects/diminactive/diminactive_config.h | 2 - effects/diminactive/diminactive_config.ui | 121 ++++++++++---------- effects/diminactive/diminactiveconfig.kcfgc | 5 + 7 files changed, 105 insertions(+), 115 deletions(-) create mode 100644 effects/diminactive/diminactive.kcfg create mode 100644 effects/diminactive/diminactiveconfig.kcfgc diff --git a/effects/diminactive/CMakeLists.txt b/effects/diminactive/CMakeLists.txt index 2d143e9392..1ce7bcaa4f 100644 --- a/effects/diminactive/CMakeLists.txt +++ b/effects/diminactive/CMakeLists.txt @@ -6,6 +6,8 @@ set( kwin4_effect_builtins_sources ${kwin4_effect_builtins_sources} diminactive/diminactive.cpp ) +kde4_add_kcfg_files(kwin4_effect_builtins_sources diminactive/diminactiveconfig.kcfgc) + # .desktop files install( FILES diminactive/diminactive.desktop @@ -20,6 +22,8 @@ set( kwin4_effect_builtins_config_sources ${kwin4_effect_builtins_config_sources diminactive/diminactive_config.ui ) +kde4_add_kcfg_files(kwin4_effect_builtins_config_sources diminactive/diminactiveconfig.kcfgc) + # .desktop files install( FILES diminactive/diminactive_config.desktop diff --git a/effects/diminactive/diminactive.cpp b/effects/diminactive/diminactive.cpp index 2a0ba45c4c..cccbc24787 100644 --- a/effects/diminactive/diminactive.cpp +++ b/effects/diminactive/diminactive.cpp @@ -20,6 +20,8 @@ along with this program. If not, see . *********************************************************************/ #include "diminactive.h" +// KConfigSkeleton +#include "diminactiveconfig.h" #include @@ -41,12 +43,12 @@ DimInactiveEffect::DimInactiveEffect() void DimInactiveEffect::reconfigure(ReconfigureFlags) { - KConfigGroup conf = EffectsHandler::effectConfig("DimInactive"); - dim_panels = conf.readEntry("DimPanels", false); - dim_desktop = conf.readEntry("DimDesktop", false); - dim_keepabove = conf.readEntry("DimKeepAbove", false); - dim_by_group = conf.readEntry("DimByGroup", true); - dim_strength = conf.readEntry("Strength", 25); + DimInactiveConfig::self()->readConfig(); + dim_panels = DimInactiveConfig::dimPanels(); + dim_desktop = DimInactiveConfig::dimDesktop(); + dim_keepabove = DimInactiveConfig::dimKeepAbove(); + dim_by_group = DimInactiveConfig::dimByGroup(); + dim_strength = DimInactiveConfig::strength(); } void DimInactiveEffect::prePaintScreen(ScreenPrePaintData& data, int time) diff --git a/effects/diminactive/diminactive.kcfg b/effects/diminactive/diminactive.kcfg new file mode 100644 index 0000000000..2b6bbba9bb --- /dev/null +++ b/effects/diminactive/diminactive.kcfg @@ -0,0 +1,24 @@ + + + + + + 25 + + + false + + + false + + + false + + + true + + + diff --git a/effects/diminactive/diminactive_config.cpp b/effects/diminactive/diminactive_config.cpp index d71bd4d0c6..3b97383ed3 100644 --- a/effects/diminactive/diminactive_config.cpp +++ b/effects/diminactive/diminactive_config.cpp @@ -19,6 +19,8 @@ along with this program. If not, see . *********************************************************************/ #include "diminactive_config.h" +// KConfigSkeleton +#include "diminactiveconfig.h" #include @@ -50,63 +52,17 @@ DimInactiveEffectConfig::DimInactiveEffectConfig(QWidget* parent, const QVariant layout->addWidget(m_ui); - connect(m_ui->spinStrength, SIGNAL(valueChanged(int)), this, SLOT(changed())); - connect(m_ui->checkPanel, SIGNAL(toggled(bool)), this, SLOT(changed())); - connect(m_ui->checkDesktop, SIGNAL(toggled(bool)), this, SLOT(changed())); - connect(m_ui->checkKeepAbove, SIGNAL(toggled(bool)), this, SLOT(changed())); - connect(m_ui->checkGroup, SIGNAL(toggled(bool)), this, SLOT(changed())); + addConfig(DimInactiveConfig::self(), m_ui); load(); } -void DimInactiveEffectConfig::load() -{ - KCModule::load(); - - KConfigGroup conf = EffectsHandler::effectConfig("DimInactive"); - - int strength = conf.readEntry("Strength", 25); - bool panel = conf.readEntry("DimPanels", false); - bool desktop = conf.readEntry("DimDesktop", false); - bool keepabove = conf.readEntry("DimKeepAbove", false); - bool group = conf.readEntry("DimByGroup", true); - m_ui->spinStrength->setValue(strength); - m_ui->checkPanel->setChecked(panel); - m_ui->checkDesktop->setChecked(desktop); - m_ui->checkKeepAbove->setChecked(keepabove); - m_ui->checkGroup->setChecked(group); - - emit changed(false); -} - void DimInactiveEffectConfig::save() { - KConfigGroup conf = EffectsHandler::effectConfig("DimInactive"); - - conf.writeEntry("Strength", m_ui->spinStrength->value()); - conf.writeEntry("DimPanels", m_ui->checkPanel->isChecked()); - conf.writeEntry("DimDesktop", m_ui->checkDesktop->isChecked()); - conf.writeEntry("DimKeepAbove", m_ui->checkKeepAbove->isChecked()); - conf.writeEntry("DimByGroup", m_ui->checkGroup->isChecked()); - - conf.sync(); - KCModule::save(); - emit changed(false); EffectsHandler::sendReloadMessage("diminactive"); } -void DimInactiveEffectConfig::defaults() -{ - m_ui->spinStrength->setValue(25); - m_ui->checkPanel->setChecked(false); - m_ui->checkDesktop->setChecked(false); - m_ui->checkKeepAbove->setChecked(false); - m_ui->checkGroup->setChecked(true); - emit changed(true); -} - - } // namespace #include "diminactive_config.moc" diff --git a/effects/diminactive/diminactive_config.h b/effects/diminactive/diminactive_config.h index 116994a13b..c83b431af9 100644 --- a/effects/diminactive/diminactive_config.h +++ b/effects/diminactive/diminactive_config.h @@ -42,8 +42,6 @@ public: explicit DimInactiveEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList()); virtual void save(); - virtual void load(); - virtual void defaults(); private: DimInactiveEffectConfigForm* m_ui; diff --git a/effects/diminactive/diminactive_config.ui b/effects/diminactive/diminactive_config.ui index dae6075009..ab6099a348 100644 --- a/effects/diminactive/diminactive_config.ui +++ b/effects/diminactive/diminactive_config.ui @@ -1,94 +1,95 @@ - + + KWin::DimInactiveEffectConfigForm - - + + 0 0 - 249 - 120 + 298 + 161 - - - - + + + + Apply effect to &panels - - - + + + Apply effect to the desk&top - - - + + + Apply effect to &keep-above windows - - - + + + Apply effect to &groups - - - + + + &Strength: - - spinStrength + + kcfg_Strength - - - + + + 120 0 - + 1 - + 100 - + 25 - + Qt::Horizontal - - - + + + 1 - + 100 - + 25 - - - + + + Qt::Vertical - + 20 0 @@ -106,43 +107,43 @@ - sliderStrength - spinStrength - checkPanel - checkDesktop - checkGroup + kcfg_sliderStrength + kcfg_Strength + kcfg_DimPanels + kcfg_DimDesktop + kcfg_DimGroup - spinStrength + kcfg_Strength valueChanged(int) - sliderStrength + kcfg_sliderStrength setValue(int) - - 193 - 52 + + 288 + 29 - - 128 - 46 + + 195 + 26 - sliderStrength + kcfg_sliderStrength valueChanged(int) - spinStrength + kcfg_Strength setValue(int) - - 69 - 45 + + 136 + 26 - - 200 - 42 + + 288 + 29 diff --git a/effects/diminactive/diminactiveconfig.kcfgc b/effects/diminactive/diminactiveconfig.kcfgc new file mode 100644 index 0000000000..0e57d63f17 --- /dev/null +++ b/effects/diminactive/diminactiveconfig.kcfgc @@ -0,0 +1,5 @@ +File=diminactive.kcfg +ClassName=DimInactiveConfig +NameSpace=KWin +Singleton=true +Mutators=true