diff --git a/effects/trackmouse/CMakeLists.txt b/effects/trackmouse/CMakeLists.txt index 6002b6fdff..937c24d58b 100644 --- a/effects/trackmouse/CMakeLists.txt +++ b/effects/trackmouse/CMakeLists.txt @@ -6,6 +6,8 @@ set( kwin4_effect_builtins_sources ${kwin4_effect_builtins_sources} trackmouse/trackmouse.cpp ) +kde4_add_kcfg_files(kwin4_effect_builtins_sources trackmouse/trackmouseconfig.kcfgc) + # .desktop files install( FILES trackmouse/trackmouse.desktop @@ -26,6 +28,8 @@ set( kwin4_effect_builtins_config_sources ${kwin4_effect_builtins_config_sources trackmouse/trackmouse_config.ui ) +kde4_add_kcfg_files(kwin4_effect_builtins_config_sources trackmouse/trackmouseconfig.kcfgc) + # .desktop files install( FILES trackmouse/trackmouse_config.desktop diff --git a/effects/trackmouse/trackmouse.cpp b/effects/trackmouse/trackmouse.cpp index 9c0d863dc8..cf6575456a 100644 --- a/effects/trackmouse/trackmouse.cpp +++ b/effects/trackmouse/trackmouse.cpp @@ -21,6 +21,9 @@ along with this program. If not, see . #include "trackmouse.h" +// KConfigSkeleton +#include "trackmouseconfig.h" + #include #include @@ -32,7 +35,6 @@ along with this program. If not, see . #include #include -#include #include #include @@ -84,14 +86,14 @@ TrackMouseEffect::~TrackMouseEffect() void TrackMouseEffect::reconfigure(ReconfigureFlags) { m_modifiers = 0; - KConfigGroup conf = effects->effectConfig("TrackMouse"); - if (conf.readEntry("Shift", false)) + TrackMouseConfig::self()->readConfig(); + if (TrackMouseConfig::shift()) m_modifiers |= Qt::ShiftModifier; - if (conf.readEntry("Alt", false)) + if (TrackMouseConfig::alt()) m_modifiers |= Qt::AltModifier; - if (conf.readEntry("Control", true)) + if (TrackMouseConfig::control()) m_modifiers |= Qt::ControlModifier; - if (conf.readEntry("Meta", true)) + if (TrackMouseConfig::meta()) m_modifiers |= Qt::MetaModifier; if (m_modifiers) { diff --git a/effects/trackmouse/trackmouse.kcfg b/effects/trackmouse/trackmouse.kcfg new file mode 100644 index 0000000000..296121c5d4 --- /dev/null +++ b/effects/trackmouse/trackmouse.kcfg @@ -0,0 +1,21 @@ + + + + + + true + + + true + + + false + + + false + + + diff --git a/effects/trackmouse/trackmouse_config.cpp b/effects/trackmouse/trackmouse_config.cpp index 51c9e279ec..17140a0783 100644 --- a/effects/trackmouse/trackmouse_config.cpp +++ b/effects/trackmouse/trackmouse_config.cpp @@ -32,6 +32,9 @@ along with this program. If not, see . #include "trackmouse_config.h" +// KConfigSkeleton +#include "trackmouseconfig.h" + namespace KWin { @@ -49,12 +52,8 @@ TrackMouseEffectConfig::TrackMouseEffectConfig(QWidget* parent, const QVariantLi m_ui = new TrackMouseEffectConfigForm(this); QVBoxLayout* layout = new QVBoxLayout(this); layout->addWidget(m_ui); - connect(m_ui->alt, SIGNAL(clicked(bool)), SLOT(changed())); - connect(m_ui->control, SIGNAL(clicked(bool)), SLOT(changed())); - connect(m_ui->meta, SIGNAL(clicked(bool)), SLOT(changed())); - connect(m_ui->shift, SIGNAL(clicked(bool)), SLOT(changed())); - connect(m_ui->modifierRadio, SIGNAL(clicked(bool)), SLOT(changed())); - connect(m_ui->shortcutRadio, SIGNAL(clicked(bool)), SLOT(changed())); + + addConfig(TrackMouseConfig::self(), m_ui); m_actionCollection = new KActionCollection(this, KComponentData("kwin")); m_actionCollection->setConfigGroup("TrackMouse"); @@ -74,44 +73,36 @@ TrackMouseEffectConfig::~TrackMouseEffectConfig() { } +void TrackMouseEffectConfig::checkModifiers() +{ + const bool modifiers = m_ui->kcfg_Shift->isChecked() || m_ui->kcfg_Alt->isChecked() || + m_ui->kcfg_Control->isChecked() || m_ui->kcfg_Meta->isChecked(); + m_ui->modifierRadio->setChecked(modifiers); + m_ui->shortcutRadio->setChecked(!modifiers); +} + void TrackMouseEffectConfig::load() { KCModule::load(); if (KAction *a = qobject_cast(m_actionCollection->action("TrackMouse"))) m_ui->shortcut->setKeySequence(a->globalShortcut().primary()); - KConfigGroup conf = EffectsHandler::effectConfig("TrackMouse"); - m_ui->meta->setChecked(conf.readEntry("Meta", true)); - m_ui->control->setChecked(conf.readEntry("Control", true)); - m_ui->alt->setChecked(conf.readEntry("Alt", false)); - m_ui->shift->setChecked(conf.readEntry("Shift", false)); - const bool modifiers = m_ui->shift->isChecked() || m_ui->alt->isChecked() || - m_ui->control->isChecked() || m_ui->meta->isChecked(); - m_ui->modifierRadio->setChecked(modifiers); - m_ui->shortcutRadio->setChecked(!modifiers); + + checkModifiers(); emit changed(false); } void TrackMouseEffectConfig::save() { - KConfigGroup conf = EffectsHandler::effectConfig("TrackMouse"); - conf.writeEntry("Shift", m_ui->modifierRadio->isChecked() && m_ui->shift->isChecked()); - conf.writeEntry("Alt", m_ui->modifierRadio->isChecked() && m_ui->alt->isChecked()); - conf.writeEntry("Control", m_ui->modifierRadio->isChecked() && m_ui->control->isChecked()); - conf.writeEntry("Meta", m_ui->modifierRadio->isChecked() && m_ui->meta->isChecked()); + KCModule::save(); m_actionCollection->writeSettings(); - conf.sync(); - emit changed(false); EffectsHandler::sendReloadMessage("trackmouse"); } void TrackMouseEffectConfig::defaults() { + KCModule::defaults(); m_ui->shortcut->clearKeySequence(); - m_ui->meta->setChecked(true); - m_ui->control->setChecked(true); - m_ui->alt->setChecked(false); - m_ui->shift->setChecked(false); - emit changed(true); + checkModifiers(); } void TrackMouseEffectConfig::shortcutChanged(const QKeySequence &seq) @@ -122,7 +113,6 @@ void TrackMouseEffectConfig::shortcutChanged(const QKeySequence &seq) emit changed(true); } - } // namespace #include "trackmouse_config.moc" diff --git a/effects/trackmouse/trackmouse_config.h b/effects/trackmouse/trackmouse_config.h index 6f7bd78646..ad8b3f117a 100644 --- a/effects/trackmouse/trackmouse_config.h +++ b/effects/trackmouse/trackmouse_config.h @@ -53,6 +53,7 @@ public slots: private slots: void shortcutChanged(const QKeySequence &seq); private: + void checkModifiers(); TrackMouseEffectConfigForm* m_ui; KActionCollection* m_actionCollection; }; diff --git a/effects/trackmouse/trackmouse_config.ui b/effects/trackmouse/trackmouse_config.ui index 8e55581702..1c87ffa32e 100644 --- a/effects/trackmouse/trackmouse_config.ui +++ b/effects/trackmouse/trackmouse_config.ui @@ -6,8 +6,8 @@ 0 0 - 311 - 101 + 327 + 104 @@ -38,28 +38,28 @@ 0 - + Alt - + Ctrl - + Shift - + Meta diff --git a/effects/trackmouse/trackmouseconfig.kcfgc b/effects/trackmouse/trackmouseconfig.kcfgc new file mode 100644 index 0000000000..3aa4117496 --- /dev/null +++ b/effects/trackmouse/trackmouseconfig.kcfgc @@ -0,0 +1,5 @@ +File=trackmouse.kcfg +ClassName=TrackMouseConfig +NameSpace=KWin +Singleton=true +Mutators=true