From e66eb0814060bbfb9d46e971f18abb0a87efdc81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Fri, 9 Nov 2012 08:38:05 +0100 Subject: [PATCH] Migration for Translucency Settigns Translucency configuration values changed from [0.0,1.0] to [0,100]. --- data/kwin_update_410.upd | 2 +- data/update_kwin_410.cpp | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/data/kwin_update_410.upd b/data/kwin_update_410.upd index 3721a2aae4..1d643ec95e 100644 --- a/data/kwin_update_410.upd +++ b/data/kwin_update_410.upd @@ -1,2 +1,2 @@ -Id=Kwin-4.10_0 +Id=Kwin-4.10_1 Script=kwin_update_settings_410 diff --git a/data/update_kwin_410.cpp b/data/update_kwin_410.cpp index 34b6ceeabd..30e234c44d 100644 --- a/data/update_kwin_410.cpp +++ b/data/update_kwin_410.cpp @@ -101,6 +101,42 @@ void migratePlastikSettings() aurorae.sync(); } +void migrateTranslucencySetting(KConfigGroup &group, const QString &key, qreal oldDefault) +{ + if (!group.hasKey(key)) { + return; + } + const qreal value = group.readEntry(key, oldDefault); + if (value == oldDefault) { + group.deleteEntry(key); + return; + } + if (value > 1.0) { + // already migrated to new settings + return; + } + const int newValue = qBound(0, qRound(value * 100), 100); + group.writeEntry(key, newValue); +} + +void migrateTranslucencySettings(KConfig &config) +{ + if (!config.hasGroup("Effect-Translucency")) { + return; + } + KConfigGroup cg = config.group("Effect-Translucency"); + migrateTranslucencySetting(cg, "Decoration", 1.0); + migrateTranslucencySetting(cg, "MoveResize", 0.8); + migrateTranslucencySetting(cg, "Dialogs", 1.0); + migrateTranslucencySetting(cg, "Inactive", 1.0); + migrateTranslucencySetting(cg, "ComboboxPopups", 1.0); + migrateTranslucencySetting(cg, "Menus", 1.0); + migrateTranslucencySetting(cg, "DropdownMenus", 1.0); + migrateTranslucencySetting(cg, "PopupMenus", 1.0); + migrateTranslucencySetting(cg, "TornOffMenus", 1.0); + cg.sync(); +} + int main( int argc, char* argv[] ) { KAboutData about( "kwin_update_settings_4_10", "kwin", KLocalizedString(), 0 ); @@ -110,6 +146,7 @@ int main( int argc, char* argv[] ) KConfig config("kwinrc"); migratePlastikToAurorae(config); migratePlastikSettings(); + migrateTranslucencySettings(config); config.sync(); // Send signal to all kwin instances QDBusMessage message =