Taskbar/QuickLaunchWidget: Ensure config backwards compatibility

The QuickLaunchWidget can now also parse the old config format, so that
we stay compatible with the old format. After loading, it deletes the
old config values and saves them in the new format.
This commit is contained in:
david072 2023-11-05 12:49:52 +01:00 committed by Andreas Kling
parent 620b3bd492
commit 7f501d4d8a
Notes: sideshowbarker 2024-07-17 05:01:20 +09:00
2 changed files with 16 additions and 0 deletions

View file

@ -355,6 +355,21 @@ void QuickLaunchWidget::load_entries(bool save)
entries.append(entry.release_nonnull());
}
// backwards compatibility since the group and value-format changed
auto old_keys = Config::list_keys(CONFIG_DOMAIN, OLD_CONFIG_GROUP_ENTRIES);
if (!old_keys.is_empty()) {
for (auto& name : old_keys) {
auto path = Config::read_string(CONFIG_DOMAIN, OLD_CONFIG_GROUP_ENTRIES, name);
auto entry = QuickLaunchEntry::create_from_path(path);
if (!entry)
continue;
entries.append(entry.release_nonnull());
}
Config::remove_group(CONFIG_DOMAIN, OLD_CONFIG_GROUP_ENTRIES);
}
m_entries.clear();
add_entries(move(entries), save);
}

View file

@ -123,6 +123,7 @@ protected:
private:
static constexpr StringView CONFIG_DOMAIN = "Taskbar"sv;
static constexpr StringView CONFIG_GROUP_ENTRIES = "QuickLaunch_Entries"sv;
static constexpr StringView OLD_CONFIG_GROUP_ENTRIES = "QuickLaunch"sv;
static constexpr int BUTTON_SIZE = 24;
explicit QuickLaunchWidget();