summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornetworkException <git@nwex.de>2022-06-16 16:41:43 +0200
committerLinus Groh <mail@linusgroh.de>2022-06-17 19:46:30 +0100
commit695dfabc2ec2648931dba5c4d1c457aea728c43d (patch)
tree7977e37c2d9e6f5ffaf06c9ea490f4f1b8ac58c4
parent535e1c91526924c3a67c2125e08986550a743b56 (diff)
downloadserenity-695dfabc2ec2648931dba5c4d1c457aea728c43d.zip
Taskbar: Update checked state of theme menu on global theme change
Previously we would assume that the theme would only change through the taskbar menu. As the theme can also be changed in DisplaySettings, the selected theme in the taskbar menu would get out of sync. With this patch the menu will get updated every time the theme changes and the menu is not shown.
-rw-r--r--Userland/Services/Taskbar/main.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/Userland/Services/Taskbar/main.cpp b/Userland/Services/Taskbar/main.cpp
index 19720fde75..2fcc93ade0 100644
--- a/Userland/Services/Taskbar/main.cpp
+++ b/Userland/Services/Taskbar/main.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
+ * Copyright (c) 2022, Jakob-Niklas See <git@nwex.de>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -20,6 +21,7 @@
#include <LibGUI/ConnectionToWindowManagerServer.h>
#include <LibGUI/ConnectionToWindowServer.h>
#include <LibGUI/Menu.h>
+#include <LibGUI/MenuItem.h>
#include <LibGUI/Process.h>
#include <LibGfx/SystemTheme.h>
#include <LibMain/Main.h>
@@ -241,6 +243,16 @@ ErrorOr<NonnullRefPtr<GUI::Menu>> build_system_menu(WindowRefence& window_ref)
}
}
+ GUI::Application::the()->on_theme_change = [&]() {
+ if (g_themes_menu->is_visible())
+ return;
+ auto current_theme_name = GUI::ConnectionToWindowServer::the().get_system_theme();
+ for (size_t index = 0; index < g_themes.size(); ++index) {
+ auto* action = g_themes_menu->action_at(index);
+ action->set_checked(action->text() == current_theme_name);
+ }
+ };
+
system_menu->add_action(GUI::Action::create("&Settings", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-settings.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
GUI::Process::spawn_or_show_error(window_ref.get(), "/bin/Settings"sv);
}));