mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +00:00
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:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user