diff --git a/effects/coverswitch/CMakeLists.txt b/effects/coverswitch/CMakeLists.txt index 9a264915f6..e4a0233779 100644 --- a/effects/coverswitch/CMakeLists.txt +++ b/effects/coverswitch/CMakeLists.txt @@ -6,6 +6,8 @@ set( kwin4_effect_builtins_sources ${kwin4_effect_builtins_sources} coverswitch/coverswitch.cpp ) +kde4_add_kcfg_files(kwin4_effect_builtins_sources coverswitch/coverswitchconfig.kcfgc) + # .desktop files install( FILES coverswitch/coverswitch.desktop @@ -24,6 +26,7 @@ set( kwin4_effect_builtins_config_sources ${kwin4_effect_builtins_config_sources coverswitch/coverswitch_config.cpp coverswitch/coverswitch_config.ui ) +kde4_add_kcfg_files(kwin4_effect_builtins_config_sources coverswitch/coverswitchconfig.kcfgc) # .desktop files install( FILES diff --git a/effects/coverswitch/coverswitch.cpp b/effects/coverswitch/coverswitch.cpp index aab0ea5f15..1792165e04 100644 --- a/effects/coverswitch/coverswitch.cpp +++ b/effects/coverswitch/coverswitch.cpp @@ -18,6 +18,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . *********************************************************************/ #include "coverswitch.h" +// KConfigSkeleton +#include "coverswitchconfig.h" #include #include @@ -26,7 +28,6 @@ along with this program. If not, see . #include #include #include -#include #include #include #include @@ -89,27 +90,30 @@ bool CoverSwitchEffect::supported() void CoverSwitchEffect::reconfigure(ReconfigureFlags) { - KConfigGroup conf = effects->effectConfig("CoverSwitch"); - animationDuration = animationTime(conf, "Duration", 200); - animateSwitch = conf.readEntry("AnimateSwitch", true); - animateStart = conf.readEntry("AnimateStart", true); - animateStop = conf.readEntry("AnimateStop", true); - reflection = conf.readEntry("Reflection", true); - windowTitle = conf.readEntry("WindowTitle", true); - zPosition = conf.readEntry("ZPosition", 900.0); - thumbnails = conf.readEntry("Thumbnails", true); - dynamicThumbnails = conf.readEntry("DynamicThumbnails", true); - thumbnailWindows = conf.readEntry("ThumbnailWindows", 8); + CoverSwitchConfig::self()->readConfig(); + animationDuration = animationTime(CoverSwitchConfig::duration()); + animateSwitch = CoverSwitchConfig::animateSwitch(); + animateStart = CoverSwitchConfig::animateStart(); + animateStop = CoverSwitchConfig::animateStop(); + reflection = CoverSwitchConfig::reflection(); + windowTitle = CoverSwitchConfig::windowTitle(); + zPosition = CoverSwitchConfig::zPosition(); + thumbnails = CoverSwitchConfig::thumbnails(); + dynamicThumbnails = CoverSwitchConfig::dynamicThumbnails(); + thumbnailWindows = CoverSwitchConfig::thumbnailWindows(); timeLine.setCurveShape(QTimeLine::EaseInOutCurve); timeLine.setDuration(animationDuration); - primaryTabBox = conf.readEntry("TabBox", false); - secondaryTabBox = conf.readEntry("TabBoxAlternative", false); - QColor tmp = conf.readEntry("MirrorFrontColor", QColor(0, 0, 0)); + + // Defined outside the ui + primaryTabBox = CoverSwitchConfig::tabBox(); + secondaryTabBox = CoverSwitchConfig::tabBoxAlternative(); + + QColor tmp = CoverSwitchConfig::mirrorFrontColor(); mirrorColor[0][0] = tmp.redF(); mirrorColor[0][1] = tmp.greenF(); mirrorColor[0][2] = tmp.blueF(); mirrorColor[0][3] = 1.0; - tmp = conf.readEntry("MirrorRearColor", QColor(0, 0, 0)); + tmp = CoverSwitchConfig::mirrorRearColor(); mirrorColor[1][0] = tmp.redF(); mirrorColor[1][1] = tmp.greenF(); mirrorColor[1][2] = tmp.blueF(); diff --git a/effects/coverswitch/coverswitch.kcfg b/effects/coverswitch/coverswitch.kcfg new file mode 100644 index 0000000000..17011d9643 --- /dev/null +++ b/effects/coverswitch/coverswitch.kcfg @@ -0,0 +1,51 @@ + + + + + + 0 + + + true + + + true + + + true + + + true + + + QColor(0, 0, 0) + + + QColor(0, 0, 0) + + + true + + + true + + + true + + + 8 + + + 900 + + + false + + + false + + + diff --git a/effects/coverswitch/coverswitch_config.cpp b/effects/coverswitch/coverswitch_config.cpp index d5d48113b8..3e996e0523 100644 --- a/effects/coverswitch/coverswitch_config.cpp +++ b/effects/coverswitch/coverswitch_config.cpp @@ -18,9 +18,10 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . *********************************************************************/ #include "coverswitch_config.h" -#include +// KConfigSkeleton +#include "coverswitchconfig.h" -#include +#include #include @@ -43,98 +44,27 @@ CoverSwitchEffectConfig::CoverSwitchEffectConfig(QWidget* parent, const QVariant layout->addWidget(m_ui); - connect(m_ui->checkAnimateSwitch, SIGNAL(stateChanged(int)), this, SLOT(changed())); - connect(m_ui->checkAnimateStart, SIGNAL(stateChanged(int)), this, SLOT(changed())); - connect(m_ui->checkAnimateStop, SIGNAL(stateChanged(int)), this, SLOT(changed())); - connect(m_ui->checkReflection, SIGNAL(stateChanged(int)), this, SLOT(changed())); - connect(m_ui->colorFront, SIGNAL(changed(QColor)), this, SLOT(changed())); - connect(m_ui->colorRear, SIGNAL(changed(QColor)), this, SLOT(changed())); - connect(m_ui->checkWindowTitle, SIGNAL(stateChanged(int)), this, SLOT(changed())); - connect(m_ui->checkThumbnails, SIGNAL(stateChanged(int)), this, SLOT(changed())); - connect(m_ui->checkDynamicThumbnails, SIGNAL(stateChanged(int)), this, SLOT(changed())); - connect(m_ui->spinThumbnailWindows, SIGNAL(valueChanged(int)), this, SLOT(changed())); - connect(m_ui->spinDuration, SIGNAL(valueChanged(int)), this, SLOT(changed())); - connect(m_ui->zPositionSlider, SIGNAL(valueChanged(int)), this, SLOT(changed())); + connect(m_ui->kcfg_Thumbnails, SIGNAL(stateChanged(int)), this, SLOT(thumbnailsChanged())); + connect(m_ui->kcfg_DynamicThumbnails, SIGNAL(stateChanged(int)), this, SLOT(thumbnailsChanged())); - connect(m_ui->checkThumbnails, SIGNAL(stateChanged(int)), this, SLOT(thumbnailsChanged())); - connect(m_ui->checkDynamicThumbnails, SIGNAL(stateChanged(int)), this, SLOT(thumbnailsChanged())); - - load(); -} - -void CoverSwitchEffectConfig::load() -{ - KCModule::load(); - - KConfigGroup conf = EffectsHandler::effectConfig("CoverSwitch"); - - m_ui->spinDuration->setValue(conf.readEntry("Duration", 0)); - m_ui->spinDuration->setSuffix(ki18np(" millisecond", " milliseconds")); - m_ui->checkAnimateSwitch->setChecked(conf.readEntry("AnimateSwitch", true)); - m_ui->checkAnimateStart->setChecked(conf.readEntry("AnimateStart", true)); - m_ui->checkAnimateStop->setChecked(conf.readEntry("AnimateStop", true)); - m_ui->checkReflection->setChecked(conf.readEntry("Reflection", true)); - m_ui->colorFront->setColor(conf.readEntry("MirrorFrontColor", QColor(0, 0, 0))); - m_ui->colorRear->setColor(conf.readEntry("MirrorRearColor", QColor(0, 0, 0))); - m_ui->checkWindowTitle->setChecked(conf.readEntry("WindowTitle", true)); - m_ui->checkThumbnails->setChecked(conf.readEntry("Thumbnails", true)); - m_ui->checkDynamicThumbnails->setChecked(conf.readEntry("DynamicThumbnails", true)); - m_ui->spinThumbnailWindows->setValue(conf.readEntry("ThumbnailWindows", 8)); - m_ui->zPositionSlider->setValue(conf.readEntry("ZPosition", 900)); - - thumbnailsChanged(); - - emit changed(false); + addConfig(CoverSwitchConfig::self(), m_ui); } void CoverSwitchEffectConfig::save() { - KConfigGroup conf = EffectsHandler::effectConfig("CoverSwitch"); - - conf.writeEntry("Duration", m_ui->spinDuration->value()); - conf.writeEntry("AnimateSwitch", m_ui->checkAnimateSwitch->isChecked()); - conf.writeEntry("AnimateStart", m_ui->checkAnimateStart->isChecked()); - conf.writeEntry("AnimateStop", m_ui->checkAnimateStop->isChecked()); - conf.writeEntry("Reflection", m_ui->checkReflection->isChecked()); - conf.writeEntry("MirrorFrontColor", m_ui->colorFront->color()); - conf.writeEntry("MirrorRearColor", m_ui->colorRear->color()); - conf.writeEntry("WindowTitle", m_ui->checkWindowTitle->isChecked()); - conf.writeEntry("Thumbnails", m_ui->checkThumbnails->isChecked()); - conf.writeEntry("DynamicThumbnails", m_ui->checkDynamicThumbnails->isChecked()); - conf.writeEntry("ThumbnailWindows", m_ui->spinThumbnailWindows->value()); - conf.writeEntry("ZPosition", m_ui->zPositionSlider->value()); - - conf.sync(); - - emit changed(false); + KCModule::save(); EffectsHandler::sendReloadMessage("coverswitch"); } -void CoverSwitchEffectConfig::defaults() -{ - m_ui->spinDuration->setValue(0); - m_ui->checkAnimateSwitch->setCheckState(Qt::Checked); - m_ui->checkAnimateStart->setCheckState(Qt::Checked); - m_ui->checkAnimateStop->setCheckState(Qt::Checked); - m_ui->checkReflection->setCheckState(Qt::Checked); - m_ui->colorFront->setColor(QColor(0, 0, 0)); - m_ui->colorRear->setColor(QColor(0, 0, 0)); - m_ui->checkWindowTitle->setCheckState(Qt::Checked); - m_ui->checkThumbnails->setCheckState(Qt::Checked); - m_ui->checkDynamicThumbnails->setCheckState(Qt::Checked); - m_ui->spinThumbnailWindows->setValue(8); - m_ui->zPositionSlider->setValue(900); - emit changed(true); -} - void CoverSwitchEffectConfig::thumbnailsChanged() { - bool enabled = m_ui->checkThumbnails->isChecked() && m_ui->checkDynamicThumbnails->isChecked(); - m_ui->checkDynamicThumbnails->setEnabled(m_ui->checkThumbnails->isChecked()); - m_ui->spinThumbnailWindows->setEnabled(enabled); + bool enabled = m_ui->kcfg_Thumbnails->isChecked() && m_ui->kcfg_DynamicThumbnails->isChecked(); + m_ui->kcfg_DynamicThumbnails->setEnabled(m_ui->kcfg_Thumbnails->isChecked()); + m_ui->kcfg_ThumbnailWindows->setEnabled(enabled); m_ui->labelThumbnailWindows->setEnabled(enabled); } + } // namespace #include "coverswitch_config.moc" diff --git a/effects/coverswitch/coverswitch_config.h b/effects/coverswitch/coverswitch_config.h index 72a91693d8..08f205444d 100644 --- a/effects/coverswitch/coverswitch_config.h +++ b/effects/coverswitch/coverswitch_config.h @@ -44,8 +44,6 @@ public: public slots: virtual void save(); - virtual void load(); - virtual void defaults(); private slots: void thumbnailsChanged(); diff --git a/effects/coverswitch/coverswitch_config.ui b/effects/coverswitch/coverswitch_config.ui index afbe9d4f96..7386885d01 100644 --- a/effects/coverswitch/coverswitch_config.ui +++ b/effects/coverswitch/coverswitch_config.ui @@ -7,12 +7,12 @@ 0 0 453 - 264 + 270 - + Display window &titles @@ -34,7 +34,7 @@ - + Define how far away the windows should appear @@ -111,21 +111,21 @@ - + Animate switch - + Animation on tab box open - + Animation on tab box close @@ -142,12 +142,12 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - spinDuration + kcfg_Duration - + 0 @@ -157,6 +157,9 @@ Default + + milliseconds + 9999 @@ -175,14 +178,14 @@ - + Use additional thumbnail bar - + Only show thumbnail bar if there are at least specified number of windows @@ -202,12 +205,12 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - spinThumbnailWindows + kcfg_ThumbnailWindows - + @@ -219,7 +222,7 @@ - + Reflections @@ -238,7 +241,7 @@ - + @@ -248,7 +251,7 @@ - + @@ -286,9 +289,9 @@ - checkReflection + kcfg_Reflection toggled(bool) - colorFront + kcfg_MirrorFrontColor setEnabled(bool) @@ -302,9 +305,9 @@ - checkReflection + kcfg_Reflection toggled(bool) - colorRear + kcfg_MirrorRearColor setEnabled(bool) @@ -318,7 +321,7 @@ - checkReflection + kcfg_Reflection toggled(bool) label_2 setEnabled(bool) @@ -334,7 +337,7 @@ - checkReflection + kcfg_Reflection toggled(bool) label setEnabled(bool) @@ -350,9 +353,9 @@ - checkThumbnails + kcfg_Thumbnails toggled(bool) - checkDynamicThumbnails + kcfg_DynamicThumbnails setEnabled(bool) @@ -366,7 +369,7 @@ - checkThumbnails + kcfg_Thumbnails toggled(bool) labelThumbnailWindows setEnabled(bool) @@ -382,9 +385,9 @@ - checkThumbnails + kcfg_Thumbnails toggled(bool) - spinThumbnailWindows + kcfg_ThumbnailWindows setEnabled(bool) diff --git a/effects/coverswitch/coverswitchconfig.kcfgc b/effects/coverswitch/coverswitchconfig.kcfgc new file mode 100644 index 0000000000..c23d13a339 --- /dev/null +++ b/effects/coverswitch/coverswitchconfig.kcfgc @@ -0,0 +1,5 @@ +File=coverswitch.kcfg +ClassName=CoverSwitchConfig +NameSpace=KWin +Singleton=true +Mutators=true