mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +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:
parent
620b3bd492
commit
7f501d4d8a
Notes:
sideshowbarker
2024-07-17 05:01:20 +09:00
Author: https://github.com/david072 Commit: https://github.com/SerenityOS/serenity/commit/7f501d4d8a Pull-request: https://github.com/SerenityOS/serenity/pull/21797
2 changed files with 16 additions and 0 deletions
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue