From f1df9ee2f0c800a9517573531a8434140f1a2ab7 Mon Sep 17 00:00:00 2001 From: Alexander Jones Date: Sun, 9 Sep 2012 11:01:07 -0500 Subject: [PATCH] Use KConfigXT in Zoom Effect REVIEW: 106402 --- effects/zoom/CMakeLists.txt | 3 +++ effects/zoom/zoom.cpp | 20 +++++++++-------- effects/zoom/zoom.kcfg | 33 +++++++++++++++++++++++++++ effects/zoom/zoom_config.cpp | 42 ++++------------------------------- effects/zoom/zoom_config.h | 2 -- effects/zoom/zoom_config.ui | 30 ++++++++++++------------- effects/zoom/zoomconfig.kcfgc | 5 +++++ 7 files changed, 71 insertions(+), 64 deletions(-) create mode 100644 effects/zoom/zoom.kcfg create mode 100644 effects/zoom/zoomconfig.kcfgc diff --git a/effects/zoom/CMakeLists.txt b/effects/zoom/CMakeLists.txt index 36e11ac5d3..ca2449e2a6 100644 --- a/effects/zoom/CMakeLists.txt +++ b/effects/zoom/CMakeLists.txt @@ -6,6 +6,8 @@ set( kwin4_effect_builtins_sources ${kwin4_effect_builtins_sources} zoom/zoom.cpp ) +kde4_add_kcfg_files(kwin4_effect_builtins_sources zoom/zoomconfig.kcfgc) + # .desktop files install( FILES zoom/zoom.desktop @@ -19,6 +21,7 @@ set( kwin4_effect_builtins_config_sources ${kwin4_effect_builtins_config_sources zoom/zoom_config.cpp zoom/zoom_config.ui ) +kde4_add_kcfg_files(kwin4_effect_builtins_config_sources zoom/zoomconfig.kcfgc) # .desktop files install( FILES diff --git a/effects/zoom/zoom.cpp b/effects/zoom/zoom.cpp index f7d73aae60..587de0328d 100644 --- a/effects/zoom/zoom.cpp +++ b/effects/zoom/zoom.cpp @@ -20,6 +20,8 @@ along with this program. If not, see . *********************************************************************/ #include "zoom.h" +// KConfigSkeleton +#include "zoomconfig.h" #include #include @@ -202,15 +204,15 @@ void ZoomEffect::recreateTexture() void ZoomEffect::reconfigure(ReconfigureFlags) { - KConfigGroup conf = EffectsHandler::effectConfig("Zoom"); + ZoomConfig::self()->readConfig(); // On zoom-in and zoom-out change the zoom by the defined zoom-factor. - zoomFactor = qMax(0.1, conf.readEntry("ZoomFactor", zoomFactor)); + zoomFactor = qMax(0.1, ZoomConfig::zoomFactor()/100.0); // Visibility of the mouse-pointer. - mousePointer = MousePointerType(conf.readEntry("MousePointer", int(mousePointer))); + mousePointer = MousePointerType(ZoomConfig::mousePointer()); // Track moving of the mouse. - mouseTracking = MouseTrackingType(conf.readEntry("MouseTracking", int(mouseTracking))); + mouseTracking = MouseTrackingType(ZoomConfig::mouseTracking()); // Enable tracking of the focused location. - bool _enableFocusTracking = conf.readEntry("EnableFocusTracking", enableFocusTracking); + bool _enableFocusTracking = ZoomConfig::enableFocusTracking(); if (enableFocusTracking != _enableFocusTracking) { enableFocusTracking = _enableFocusTracking; if (QDBusConnection::sessionBus().isConnected()) { @@ -221,13 +223,13 @@ void ZoomEffect::reconfigure(ReconfigureFlags) } } // When the focus changes, move the zoom area to the focused location. - followFocus = conf.readEntry("EnableFollowFocus", followFocus); + followFocus = ZoomConfig::enableFollowFocus(); // The time in milliseconds to wait before a focus-event takes away a mouse-move. - focusDelay = qMax(0, conf.readEntry("FocusDelay", focusDelay)); + focusDelay = qMax(uint(0), ZoomConfig::focusDelay()); // The factor the zoom-area will be moved on touching an edge on push-mode or using the navigation KAction's. - moveFactor = qMax(0.1, conf.readEntry("MoveFactor", moveFactor)); + moveFactor = qMax(0.1, ZoomConfig::moveFactor()); // Load the saved zoom value. - target_zoom = conf.readEntry("InitialZoom", target_zoom); + target_zoom = ZoomConfig::initialZoom(); if (target_zoom > 1.0) zoomIn(target_zoom); } diff --git a/effects/zoom/zoom.kcfg b/effects/zoom/zoom.kcfg new file mode 100644 index 0000000000..b1df40fdba --- /dev/null +++ b/effects/zoom/zoom.kcfg @@ -0,0 +1,33 @@ + + + + + + 1.2 + + + 0 + + + 0 + + + false + + + true + + + 350 + + + 20.0 + + + 1.0 + + + diff --git a/effects/zoom/zoom_config.cpp b/effects/zoom/zoom_config.cpp index 3edd10cab0..0b4308b92a 100644 --- a/effects/zoom/zoom_config.cpp +++ b/effects/zoom/zoom_config.cpp @@ -20,6 +20,8 @@ along with this program. If not, see . *********************************************************************/ #include "zoom_config.h" +// KConfigSkeleton +#include "zoomconfig.h" #include @@ -49,12 +51,7 @@ ZoomEffectConfig::ZoomEffectConfig(QWidget* parent, const QVariantList& args) : QVBoxLayout* layout = new QVBoxLayout(this); layout->addWidget(m_ui); - connect(m_ui->zoomStepsSpinBox, SIGNAL(valueChanged(double)), this, SLOT(changed())); - connect(m_ui->mousePointerComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(changed())); - connect(m_ui->mouseTrackingComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(changed())); - connect(m_ui->focusTrackingCheckBox, SIGNAL(toggled(bool)), this, SLOT(changed())); - connect(m_ui->followFocusCheckBox, SIGNAL(toggled(bool)), this, SLOT(changed())); - connect(m_ui->editor, SIGNAL(keyChange()), this, SLOT(changed())); + addConfig(ZoomConfig::self(), m_ui); // Shortcut config. The shortcut belongs to the component "kwin"! KActionCollection *actionCollection = new KActionCollection(this, KComponentData("kwin")); @@ -120,44 +117,13 @@ ZoomEffectConfig::~ZoomEffectConfig() m_ui->editor->undoChanges(); } -void ZoomEffectConfig::load() -{ - KCModule::load(); - KConfigGroup conf = EffectsHandler::effectConfig("Zoom"); - m_ui->zoomStepsSpinBox->setValue(conf.readEntry("ZoomFactor", 1.2)); - m_ui->mousePointerComboBox->setCurrentIndex(conf.readEntry("MousePointer", 0)); - m_ui->mouseTrackingComboBox->setCurrentIndex(conf.readEntry("MouseTracking", 0)); - m_ui->focusTrackingCheckBox->setChecked(conf.readEntry("EnableFocusTracking", false)); - m_ui->followFocusCheckBox->setChecked(conf.readEntry("EnableFollowFocus", true)); - emit changed(false); -} - void ZoomEffectConfig::save() { - //KCModule::save(); - KConfigGroup conf = EffectsHandler::effectConfig("Zoom"); - conf.writeEntry("ZoomFactor", m_ui->zoomStepsSpinBox->value()); - conf.writeEntry("MousePointer", m_ui->mousePointerComboBox->currentIndex()); - conf.writeEntry("MouseTracking", m_ui->mouseTrackingComboBox->currentIndex()); - conf.writeEntry("EnableFocusTracking", m_ui->focusTrackingCheckBox->isChecked()); - conf.writeEntry("EnableFollowFocus", m_ui->followFocusCheckBox->isChecked()); m_ui->editor->save(); // undo() will restore to this state from now on - conf.sync(); - emit changed(false); + KCModule::save(); EffectsHandler::sendReloadMessage("zoom"); } -void ZoomEffectConfig::defaults() -{ - m_ui->zoomStepsSpinBox->setValue(1.25); - m_ui->mousePointerComboBox->setCurrentIndex(0); - m_ui->mouseTrackingComboBox->setCurrentIndex(0); - m_ui->focusTrackingCheckBox->setChecked(false); - m_ui->followFocusCheckBox->setChecked(true); - m_ui->editor->allDefault(); - emit changed(true); -} - } // namespace #include "zoom_config.moc" diff --git a/effects/zoom/zoom_config.h b/effects/zoom/zoom_config.h index f7b4e064ad..9b97cc28d1 100644 --- a/effects/zoom/zoom_config.h +++ b/effects/zoom/zoom_config.h @@ -46,8 +46,6 @@ public: public slots: virtual void save(); - virtual void load(); - virtual void defaults(); private: ZoomEffectConfigForm* m_ui; diff --git a/effects/zoom/zoom_config.ui b/effects/zoom/zoom_config.ui index c2c90f6e0e..1a746f750d 100644 --- a/effects/zoom/zoom_config.ui +++ b/effects/zoom/zoom_config.ui @@ -31,12 +31,12 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - zoomStepsSpinBox + kcfg_ZoomFactor - + On zoom-in and zoom-out change the zoom by the defined zoom-factor. @@ -58,7 +58,7 @@ - + @@ -71,7 +71,7 @@ - + false @@ -92,12 +92,12 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - mousePointerComboBox + kcfg_MousePointer - + Visibility of the mouse-pointer. @@ -119,7 +119,7 @@ - + Track moving of the mouse. @@ -154,7 +154,7 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - mouseTrackingComboBox + kcfg_MouseTracking @@ -184,18 +184,18 @@ - zoomStepsSpinBox - mousePointerComboBox - mouseTrackingComboBox - focusTrackingCheckBox - followFocusCheckBox + kcfg_ZoomFactor + kcfg_MousePointer + kcfg_MouseTracking + kcfg_EnableFocusTracking + kcfg_EnableFollowFocus - focusTrackingCheckBox + kcfg_EnableFocusTracking toggled(bool) - followFocusCheckBox + kcfg_EnableFollowFocus setEnabled(bool) diff --git a/effects/zoom/zoomconfig.kcfgc b/effects/zoom/zoomconfig.kcfgc new file mode 100644 index 0000000000..99795831fa --- /dev/null +++ b/effects/zoom/zoomconfig.kcfgc @@ -0,0 +1,5 @@ +File=zoom.kcfg +ClassName=ZoomConfig +NameSpace=KWin +Singleton=true +Mutators=true