Synchronize effect checkboxes with the effect selector widget by using a
temporary config file for communication when active tab changes. svn path=/trunk/KDE/kdebase/workspace/; revision=714742
This commit is contained in:
parent
3074e126e7
commit
a93826681a
2 changed files with 90 additions and 18 deletions
|
@ -84,6 +84,7 @@ KWinCompositingConfig::KWinCompositingConfig(QWidget *parent, const QVariantList
|
||||||
|
|
||||||
connect(ui.advancedOptions, SIGNAL(clicked()), this, SLOT(showAdvancedOptions()));
|
connect(ui.advancedOptions, SIGNAL(clicked()), this, SLOT(showAdvancedOptions()));
|
||||||
connect(ui.useCompositing, SIGNAL(toggled(bool)), this, SLOT(compositingEnabled(bool)));
|
connect(ui.useCompositing, SIGNAL(toggled(bool)), this, SLOT(compositingEnabled(bool)));
|
||||||
|
connect(ui.tabWidget, SIGNAL(currentChanged(int)), this, SLOT(currentTabChanged(int)));
|
||||||
|
|
||||||
connect(ui.useCompositing, SIGNAL(toggled(bool)), this, SLOT(changed()));
|
connect(ui.useCompositing, SIGNAL(toggled(bool)), this, SLOT(changed()));
|
||||||
connect(ui.effectWinManagement, SIGNAL(toggled(bool)), this, SLOT(changed()));
|
connect(ui.effectWinManagement, SIGNAL(toggled(bool)), this, SLOT(changed()));
|
||||||
|
@ -94,6 +95,13 @@ KWinCompositingConfig::KWinCompositingConfig(QWidget *parent, const QVariantList
|
||||||
connect(ui.effectSelector, SIGNAL(configCommitted(const QByteArray&)),
|
connect(ui.effectSelector, SIGNAL(configCommitted(const QByteArray&)),
|
||||||
this, SLOT(reparseConfiguration(const QByteArray&)));
|
this, SLOT(reparseConfiguration(const QByteArray&)));
|
||||||
|
|
||||||
|
// Open the temporary config file
|
||||||
|
// Temporary conf file is used to syncronize effect checkboxes with effect
|
||||||
|
// selector by loading/saving effects from/to temp config when active tab
|
||||||
|
// changes.
|
||||||
|
mTmpConfigFile.open();
|
||||||
|
mTmpConfig = KSharedConfig::openConfig(mTmpConfigFile.fileName());
|
||||||
|
|
||||||
initEffectSelector();
|
initEffectSelector();
|
||||||
|
|
||||||
// Load config
|
// Load config
|
||||||
|
@ -155,25 +163,38 @@ void KWinCompositingConfig::initEffectSelector()
|
||||||
QList<KPluginInfo> effectinfos = KPluginInfo::fromServices(offers);
|
QList<KPluginInfo> effectinfos = KPluginInfo::fromServices(offers);
|
||||||
|
|
||||||
// Add them to the plugin selector
|
// Add them to the plugin selector
|
||||||
ui.effectSelector->addPlugins(effectinfos, KPluginSelector::ReadConfigFile, i18n("Appearance"), "Appearance", mKWinConfig);
|
ui.effectSelector->addPlugins(effectinfos, KPluginSelector::ReadConfigFile, i18n("Appearance"), "Appearance", mTmpConfig);
|
||||||
ui.effectSelector->addPlugins(effectinfos, KPluginSelector::ReadConfigFile, i18n("Accessibility"), "Accessibility", mKWinConfig);
|
ui.effectSelector->addPlugins(effectinfos, KPluginSelector::ReadConfigFile, i18n("Accessibility"), "Accessibility", mTmpConfig);
|
||||||
ui.effectSelector->addPlugins(effectinfos, KPluginSelector::ReadConfigFile, i18n("Window Management"), "Window Management", mKWinConfig);
|
ui.effectSelector->addPlugins(effectinfos, KPluginSelector::ReadConfigFile, i18n("Window Management"), "Window Management", mTmpConfig);
|
||||||
ui.effectSelector->addPlugins(effectinfos, KPluginSelector::ReadConfigFile, i18n("Demos"), "Demos", mKWinConfig);
|
ui.effectSelector->addPlugins(effectinfos, KPluginSelector::ReadConfigFile, i18n("Demos"), "Demos", mTmpConfig);
|
||||||
ui.effectSelector->addPlugins(effectinfos, KPluginSelector::ReadConfigFile, i18n("Tests"), "Tests", mKWinConfig);
|
ui.effectSelector->addPlugins(effectinfos, KPluginSelector::ReadConfigFile, i18n("Tests"), "Tests", mTmpConfig);
|
||||||
ui.effectSelector->addPlugins(effectinfos, KPluginSelector::ReadConfigFile, i18n("Misc"), "Misc", mKWinConfig);
|
ui.effectSelector->addPlugins(effectinfos, KPluginSelector::ReadConfigFile, i18n("Misc"), "Misc", mTmpConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KWinCompositingConfig::load()
|
void KWinCompositingConfig::currentTabChanged(int tab)
|
||||||
{
|
{
|
||||||
kDebug() ;
|
if (tab == 0)
|
||||||
mKWinConfig->reparseConfiguration();
|
{
|
||||||
|
// General tab was activated
|
||||||
|
saveEffectsTab();
|
||||||
|
loadGeneralTab();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Effects tab was activated
|
||||||
|
saveGeneralTab();
|
||||||
|
loadEffectsTab();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void KWinCompositingConfig::loadGeneralTab()
|
||||||
|
{
|
||||||
KConfigGroup config(mKWinConfig, "Compositing");
|
KConfigGroup config(mKWinConfig, "Compositing");
|
||||||
ui.useCompositing->setChecked(config.readEntry("Enabled", mDefaultPrefs.enableCompositing()));
|
ui.useCompositing->setChecked(config.readEntry("Enabled", mDefaultPrefs.enableCompositing()));
|
||||||
|
|
||||||
// Load effect settings
|
// Load effect settings
|
||||||
config.changeGroup("Plugins");
|
KConfigGroup effectconfig(mTmpConfig, "Plugins");
|
||||||
#define LOAD_EFFECT_CONFIG(effectname) config.readEntry("kwin4_effect_" effectname "Enabled", true)
|
#define LOAD_EFFECT_CONFIG(effectname) effectconfig.readEntry("kwin4_effect_" effectname "Enabled", true)
|
||||||
bool winManagementEnabled = LOAD_EFFECT_CONFIG("presentwindows");
|
bool winManagementEnabled = LOAD_EFFECT_CONFIG("presentwindows");
|
||||||
winManagementEnabled &= LOAD_EFFECT_CONFIG("boxswitch");
|
winManagementEnabled &= LOAD_EFFECT_CONFIG("boxswitch");
|
||||||
winManagementEnabled &= LOAD_EFFECT_CONFIG("desktopgrid");
|
winManagementEnabled &= LOAD_EFFECT_CONFIG("desktopgrid");
|
||||||
|
@ -181,17 +202,37 @@ void KWinCompositingConfig::load()
|
||||||
ui.effectWinManagement->setChecked(winManagementEnabled);
|
ui.effectWinManagement->setChecked(winManagementEnabled);
|
||||||
ui.effectShadows->setChecked(LOAD_EFFECT_CONFIG("shadow"));
|
ui.effectShadows->setChecked(LOAD_EFFECT_CONFIG("shadow"));
|
||||||
ui.effectAnimations->setChecked(LOAD_EFFECT_CONFIG("minimizeanimation"));
|
ui.effectAnimations->setChecked(LOAD_EFFECT_CONFIG("minimizeanimation"));
|
||||||
|
#undef LOAD_EFFECT_CONFIG
|
||||||
|
}
|
||||||
|
|
||||||
|
void KWinCompositingConfig::loadEffectsTab()
|
||||||
|
{
|
||||||
ui.effectSelector->load();
|
ui.effectSelector->load();
|
||||||
|
}
|
||||||
|
|
||||||
|
void KWinCompositingConfig::load()
|
||||||
|
{
|
||||||
|
kDebug() ;
|
||||||
|
mKWinConfig->reparseConfiguration();
|
||||||
|
|
||||||
|
// Copy Plugins group to temp config file
|
||||||
|
QMap<QString, QString> entries = mKWinConfig->entryMap("Plugins");
|
||||||
|
QMap<QString, QString>::const_iterator it = entries.constBegin();
|
||||||
|
KConfigGroup tmpconfig(mTmpConfig, "Plugins");
|
||||||
|
tmpconfig.deleteGroup();
|
||||||
|
for(; it != entries.constEnd(); ++it)
|
||||||
|
{
|
||||||
|
tmpconfig.writeEntry(it.key(), it.value());
|
||||||
|
}
|
||||||
|
|
||||||
|
loadGeneralTab();
|
||||||
|
loadEffectsTab();
|
||||||
|
|
||||||
emit changed( false );
|
emit changed( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool KWinCompositingConfig::saveGeneralTab()
|
||||||
void KWinCompositingConfig::save()
|
|
||||||
{
|
{
|
||||||
kDebug() ;
|
|
||||||
|
|
||||||
KConfigGroup config(mKWinConfig, "Compositing");
|
KConfigGroup config(mKWinConfig, "Compositing");
|
||||||
// Save current config. We'll use this for restoring in case something
|
// Save current config. We'll use this for restoring in case something
|
||||||
// goes wrong.
|
// goes wrong.
|
||||||
|
@ -203,8 +244,8 @@ void KWinCompositingConfig::save()
|
||||||
config.writeEntry("Enabled", ui.useCompositing->isChecked());
|
config.writeEntry("Enabled", ui.useCompositing->isChecked());
|
||||||
|
|
||||||
// Save effects
|
// Save effects
|
||||||
config.changeGroup("Plugins");
|
KConfigGroup effectconfig(mTmpConfig, "Plugins");
|
||||||
#define WRITE_EFFECT_CONFIG(effectname, widget) config.writeEntry("kwin4_effect_" effectname "Enabled", widget->isChecked())
|
#define WRITE_EFFECT_CONFIG(effectname, widget) effectconfig.writeEntry("kwin4_effect_" effectname "Enabled", widget->isChecked())
|
||||||
WRITE_EFFECT_CONFIG("presentwindows", ui.effectWinManagement);
|
WRITE_EFFECT_CONFIG("presentwindows", ui.effectWinManagement);
|
||||||
WRITE_EFFECT_CONFIG("boxswitch", ui.effectWinManagement);
|
WRITE_EFFECT_CONFIG("boxswitch", ui.effectWinManagement);
|
||||||
WRITE_EFFECT_CONFIG("desktopgrid", ui.effectWinManagement);
|
WRITE_EFFECT_CONFIG("desktopgrid", ui.effectWinManagement);
|
||||||
|
@ -215,7 +256,30 @@ void KWinCompositingConfig::save()
|
||||||
WRITE_EFFECT_CONFIG("minimizeanimation", ui.effectAnimations);
|
WRITE_EFFECT_CONFIG("minimizeanimation", ui.effectAnimations);
|
||||||
#undef WRITE_EFFECT_CONFIG
|
#undef WRITE_EFFECT_CONFIG
|
||||||
|
|
||||||
|
return confirm;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KWinCompositingConfig::saveEffectsTab()
|
||||||
|
{
|
||||||
ui.effectSelector->save();
|
ui.effectSelector->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
void KWinCompositingConfig::save()
|
||||||
|
{
|
||||||
|
kDebug() ;
|
||||||
|
|
||||||
|
bool confirm = saveGeneralTab();
|
||||||
|
saveEffectsTab();
|
||||||
|
|
||||||
|
// Copy Plugins group from temp config to real config
|
||||||
|
QMap<QString, QString> entries = mTmpConfig->entryMap("Plugins");
|
||||||
|
QMap<QString, QString>::const_iterator it = entries.constBegin();
|
||||||
|
KConfigGroup realconfig(mKWinConfig, "Plugins");
|
||||||
|
realconfig.deleteGroup();
|
||||||
|
for(; it != entries.constEnd(); ++it)
|
||||||
|
{
|
||||||
|
realconfig.writeEntry(it.key(), it.value());
|
||||||
|
}
|
||||||
|
|
||||||
emit changed( false );
|
emit changed( false );
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ License. See the file "COPYING" for the exact licensing terms.
|
||||||
#include <kcmodule.h>
|
#include <kcmodule.h>
|
||||||
|
|
||||||
#include <ksharedconfig.h>
|
#include <ksharedconfig.h>
|
||||||
|
#include <ktemporaryfile.h>
|
||||||
#include <kdialog.h>
|
#include <kdialog.h>
|
||||||
|
|
||||||
#include "ui_main.h"
|
#include "ui_main.h"
|
||||||
|
@ -54,12 +54,18 @@ class KWinCompositingConfig : public KCModule
|
||||||
virtual void compositingEnabled(bool enabled);
|
virtual void compositingEnabled(bool enabled);
|
||||||
virtual void showAdvancedOptions();
|
virtual void showAdvancedOptions();
|
||||||
virtual void showConfirmDialog();
|
virtual void showConfirmDialog();
|
||||||
|
void currentTabChanged(int tab);
|
||||||
|
|
||||||
virtual void load();
|
virtual void load();
|
||||||
virtual void save();
|
virtual void save();
|
||||||
virtual void defaults();
|
virtual void defaults();
|
||||||
void reparseConfiguration(const QByteArray&conf);
|
void reparseConfiguration(const QByteArray&conf);
|
||||||
|
|
||||||
|
void loadGeneralTab();
|
||||||
|
void loadEffectsTab();
|
||||||
|
bool saveGeneralTab();
|
||||||
|
void saveEffectsTab();
|
||||||
|
|
||||||
void configChanged();
|
void configChanged();
|
||||||
void initEffectSelector();
|
void initEffectSelector();
|
||||||
|
|
||||||
|
@ -69,6 +75,8 @@ class KWinCompositingConfig : public KCModule
|
||||||
CompositingPrefs mDefaultPrefs;
|
CompositingPrefs mDefaultPrefs;
|
||||||
|
|
||||||
QMap<QString, QString> mPreviousConfig;
|
QMap<QString, QString> mPreviousConfig;
|
||||||
|
KTemporaryFile mTmpConfigFile;
|
||||||
|
KSharedConfigPtr mTmpConfig;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
Loading…
Reference in a new issue