Migration for Translucency Settigns

Translucency configuration values changed from [0.0,1.0] to [0,100].
This commit is contained in:
Martin Gräßlin 2012-11-09 08:38:05 +01:00
parent 509daa60a1
commit e66eb08140
2 changed files with 38 additions and 1 deletions

View file

@ -1,2 +1,2 @@
Id=Kwin-4.10_0
Id=Kwin-4.10_1
Script=kwin_update_settings_410

View file

@ -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<int>(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 =