summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornetworkException <git@nwex.de>2022-06-16 20:11:56 +0200
committerLinus Groh <mail@linusgroh.de>2022-06-17 19:46:30 +0100
commit278fd28502c6ced57df029559658951cbd2cbaec (patch)
tree6b7dea02e4ea1a6a53f906557258bdb673653bec
parent82f537b847aea9f98a2d79de55a4409b7107d3ef (diff)
downloadserenity-278fd28502c6ced57df029559658951cbd2cbaec.zip
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.
-rw-r--r--Userland/Applications/DisplaySettings/ThemesSettingsWidget.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/Userland/Applications/DisplaySettings/ThemesSettingsWidget.cpp b/Userland/Applications/DisplaySettings/ThemesSettingsWidget.cpp
index 2b7518e549..6a0bd8714b 100644
--- a/Userland/Applications/DisplaySettings/ThemesSettingsWidget.cpp
+++ b/Userland/Applications/DisplaySettings/ThemesSettingsWidget.cpp
@@ -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()