From 0ca1edbfe87594b903c57fd4dc0c205963524d1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Wed, 1 Oct 2008 15:21:21 +0000 Subject: [PATCH] Read default values from .desktop files when finding out whether an effect is enabled, otherwise the effect-for-alt+tab combo resets to no effect when the dialog is used the first time. svn path=/trunk/KDE/kdebase/workspace/; revision=866648 --- kcmkwin/kwincompositing/main.cpp | 22 ++++++++++++++++------ kcmkwin/kwincompositing/main.h | 2 ++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/kcmkwin/kwincompositing/main.cpp b/kcmkwin/kwincompositing/main.cpp index 1ed4a10444..ba2c4a0c87 100644 --- a/kcmkwin/kwincompositing/main.cpp +++ b/kcmkwin/kwincompositing/main.cpp @@ -286,25 +286,35 @@ void KWinCompositingConfig::loadGeneralTab() #undef LOAD_EFFECT_CONFIG // window switching - if( effectconfig.readEntry("kwin4_effect_boxswitchEnabled", false) ) + if( effectEnabled( "boxswitch", effectconfig )) ui.windowSwitchingCombo->setCurrentIndex( 1 ); - if( effectconfig.readEntry("kwin4_effect_coverswitchEnabled", false) ) + if( effectEnabled( "coverswitch", effectconfig )) ui.windowSwitchingCombo->setCurrentIndex( 3 ); - if( effectconfig.readEntry("kwin4_effect_flipswitchEnabled", false) ) + if( effectEnabled( "flipswitch", effectconfig )) ui.windowSwitchingCombo->setCurrentIndex( 4 ); KConfigGroup presentwindowsconfig(mKWinConfig, "Effect-PresentWindows"); - if( effectconfig.readEntry("kwin4_effect_presentwindowsEnabled", false) && presentwindowsconfig.readEntry("TabBox", false) ) + if( effectEnabled( "presentwindows", effectconfig ) && presentwindowsconfig.readEntry("TabBox", false) ) ui.windowSwitchingCombo->setCurrentIndex( 2 ); // desktop switching - if( effectconfig.readEntry("kwin4_effect_slideEnabled", false) ) + if( effectEnabled( "slide", effectconfig )) ui.desktopSwitchingCombo->setCurrentIndex( 1 ); KConfigGroup cubeconfig(mKWinConfig, "Effect-Cube"); - if( effectconfig.readEntry("kwin4_effect_cubeEnabled", false) && cubeconfig.readEntry("AnimateDesktopChange", false) ) + if( effectEnabled( "cube", effectconfig ) && cubeconfig.readEntry("AnimateDesktopChange", false)) ui.desktopSwitchingCombo->setCurrentIndex( 2 ); } +bool KWinCompositingConfig::effectEnabled( const QString& effect, const KConfigGroup& cfg ) const +{ + KService::List services = KServiceTypeTrader::self()->query( + "KWin/Effect", "[X-KDE-PluginInfo-Name] == 'kwin4_effect_" + effect + "'"); + if( services.isEmpty()) + return false; + QVariant v = services.first()->property("X-KDE-PluginInfo-EnabledByDefault"); + return cfg.readEntry("kwin4_effect_" + effect + "Enabled", v.toBool()); +} + void KWinCompositingConfig::loadEffectsTab() { ui.effectSelector->load(); diff --git a/kcmkwin/kwincompositing/main.h b/kcmkwin/kwincompositing/main.h index 8014ba7cbb..4e3ebfe650 100644 --- a/kcmkwin/kwincompositing/main.h +++ b/kcmkwin/kwincompositing/main.h @@ -72,6 +72,8 @@ class KWinCompositingConfig : public KCModule void initEffectSelector(); private: + bool effectEnabled( const QString& effect, const KConfigGroup& cfg ) const; + KSharedConfigPtr mKWinConfig; Ui::KWinCompositingConfig ui; CompositingPrefs mDefaultPrefs;