mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-01 03:57:15 +02:00
DisplaySettings: Update selected theme on change
Previously the "Theme" tab in DisplaySettings would only reflect the current theme on startup and get out of sync when a theme would get selected using the taskbar menu.
This commit is contained in:
committed by
Linus Groh
parent
82f537b847
commit
278fd28502
Notes:
sideshowbarker
2024-07-17 10:06:57 +09:00
Author: https://github.com/networkException Commit: https://github.com/SerenityOS/serenity/commit/278fd28502 Pull-request: https://github.com/SerenityOS/serenity/pull/14305 Reviewed-by: https://github.com/linusg ✅
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2022, MacDue <macdue@dueutil.tech>
|
||||
* Copyright (c) 2022, Jakob-Niklas See <git@nwex.de>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
@@ -9,6 +10,7 @@
|
||||
#include <AK/QuickSort.h>
|
||||
#include <Applications/DisplaySettings/ThemesSettingsGML.h>
|
||||
#include <LibCore/DirIterator.h>
|
||||
#include <LibGUI/Application.h>
|
||||
#include <LibGUI/ConnectionToWindowServer.h>
|
||||
#include <LibGUI/ItemListModel.h>
|
||||
#include <LibGUI/Process.h>
|
||||
@@ -54,6 +56,20 @@ ThemesSettingsWidget::ThemesSettingsWidget(bool& background_settings_changed)
|
||||
m_cursor_themes_button->on_click = [&](auto) {
|
||||
GUI::Process::spawn_or_show_error(window(), "/bin/MouseSettings", Array { "-t", "cursor-theme" });
|
||||
};
|
||||
|
||||
GUI::Application::the()->on_theme_change = [&]() {
|
||||
auto current_theme_name = current_system_theme();
|
||||
|
||||
size_t index = 0;
|
||||
for (auto& theme_meta : m_themes) {
|
||||
if (current_theme_name == theme_meta.name) {
|
||||
m_themes_combo->set_selected_index(index, GUI::AllowCallback::No);
|
||||
m_selected_theme = &m_themes.at(index);
|
||||
m_theme_preview->set_theme(m_selected_theme->path);
|
||||
}
|
||||
++index;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void ThemesSettingsWidget::apply_settings()
|
||||
|
||||
Reference in New Issue
Block a user