From a1b90cdd15ae3c61a3185883289dc45eb2a07c8c Mon Sep 17 00:00:00 2001 From: Rivo Laks Date: Thu, 20 Sep 2007 20:34:24 +0000 Subject: [PATCH] Use the confirmation dialog for advanced settings dialog as well svn path=/trunk/KDE/kdebase/workspace/; revision=714888 --- kcmkwin/kwincompositing/advanced.cpp | 29 ++++++++++++++++++++++++++++ kcmkwin/kwincompositing/advanced.h | 4 ++++ 2 files changed, 33 insertions(+) diff --git a/kcmkwin/kwincompositing/advanced.cpp b/kcmkwin/kwincompositing/advanced.cpp index c9c6987542..f4ee346c74 100644 --- a/kcmkwin/kwincompositing/advanced.cpp +++ b/kcmkwin/kwincompositing/advanced.cpp @@ -15,6 +15,7 @@ License. See the file "COPYING" for the exact licensing terms. #include #include "compositingprefs.h" +#include "main.h" namespace KWin { @@ -63,6 +64,26 @@ void KWinAdvancedCompositingOptions::compositingModeChanged() ui.glGroup->setEnabled(ui.compositingType->currentIndex() == 0); } +void KWinAdvancedCompositingOptions::showConfirmDialog() +{ + ConfirmDialog confirm; + int result = confirm.exec(); + if(result != KDialog::Yes) + { + // Revert settings + KConfigGroup config(mKWinConfig, "Compositing"); + config.deleteGroup(); + QMap::const_iterator it = mPreviousConfig.constBegin(); + for(; it != mPreviousConfig.constEnd(); ++it) + { + config.writeEntry(it.key(), it.value()); + } + // Reinit KWin compositing and reload (old) settings + reinitKWinCompositing(); + load(); + } +} + void KWinAdvancedCompositingOptions::load() { KConfigGroup config(mKWinConfig, "Compositing"); @@ -83,6 +104,8 @@ void KWinAdvancedCompositingOptions::save() } KConfigGroup config(mKWinConfig, "Compositing"); + mPreviousConfig = config.entryMap(); + config.writeEntry("Backend", (ui.compositingType->currentIndex() == 0) ? "OpenGL" : "XRender"); QString glModes[] = { "TFP", "SHM", "Fallback" }; config.writeEntry("GLMode", glModes[ui.glMode->currentIndex()]); @@ -92,6 +115,12 @@ void KWinAdvancedCompositingOptions::save() enableButtonApply(false); + reinitKWinCompositing(); + showConfirmDialog(); +} + +void KWinAdvancedCompositingOptions::reinitKWinCompositing() +{ // Send signal to kwin mKWinConfig->sync(); // Send signal to all kwin instances diff --git a/kcmkwin/kwincompositing/advanced.h b/kcmkwin/kwincompositing/advanced.h index 33824d3066..8c3b63782e 100644 --- a/kcmkwin/kwincompositing/advanced.h +++ b/kcmkwin/kwincompositing/advanced.h @@ -35,11 +35,15 @@ class KWinAdvancedCompositingOptions : public KDialog void changed(); void save(); void compositingModeChanged(); + void showConfirmDialog(); + + void reinitKWinCompositing(); private: KSharedConfigPtr mKWinConfig; Ui::KWinAdvancedCompositingOptions ui; CompositingPrefs* mDefaultPrefs; + QMap mPreviousConfig; }; } // namespace