summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authornetworkException <git@nwex.de>2022-06-16 14:16:31 +0200
committerLinus Groh <mail@linusgroh.de>2022-06-17 19:46:30 +0100
commit535e1c91526924c3a67c2125e08986550a743b56 (patch)
treef41c2472099c13774c91a7fbb07b9ea8ea2d266a /Userland/Libraries
parent84780f3ed5bf2fe42c895337dd6ccf90ce2620e5 (diff)
downloadserenity-535e1c91526924c3a67c2125e08986550a743b56.zip
LibGUI: Add on_theme_change callback to Application
This allows an Application without a window to listen for theme changes.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibGUI/Application.cpp4
-rw-r--r--Userland/Libraries/LibGUI/Application.h1
-rw-r--r--Userland/Libraries/LibGUI/ConnectionToWindowServer.cpp2
3 files changed, 7 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGUI/Application.cpp b/Userland/Libraries/LibGUI/Application.cpp
index c5d0f670fe..ded131f1cc 100644
--- a/Userland/Libraries/LibGUI/Application.cpp
+++ b/Userland/Libraries/LibGUI/Application.cpp
@@ -311,6 +311,10 @@ void Application::event(Core::Event& event)
on_action_leave(action);
}
}
+ if (event.type() == GUI::Event::ThemeChange) {
+ if (on_theme_change)
+ on_theme_change();
+ }
Object::event(event);
}
diff --git a/Userland/Libraries/LibGUI/Application.h b/Userland/Libraries/LibGUI/Application.h
index e74fc6abca..0f224f41a6 100644
--- a/Userland/Libraries/LibGUI/Application.h
+++ b/Userland/Libraries/LibGUI/Application.h
@@ -83,6 +83,7 @@ public:
Function<void(Action&)> on_action_enter;
Function<void(Action&)> on_action_leave;
+ Function<void()> on_theme_change;
auto const& global_shortcut_actions(Badge<GUI::CommandPalette>) const { return m_global_shortcut_actions; }
diff --git a/Userland/Libraries/LibGUI/ConnectionToWindowServer.cpp b/Userland/Libraries/LibGUI/ConnectionToWindowServer.cpp
index 61e997d57c..11637bf2a1 100644
--- a/Userland/Libraries/LibGUI/ConnectionToWindowServer.cpp
+++ b/Userland/Libraries/LibGUI/ConnectionToWindowServer.cpp
@@ -67,6 +67,8 @@ void ConnectionToWindowServer::update_system_theme(Core::AnonymousBuffer const&
Window::for_each_window({}, [](auto& window) {
Core::EventLoop::current().post_event(window, make<ThemeChangeEvent>());
});
+
+ Application::the()->dispatch_event(*make<ThemeChangeEvent>());
}
void ConnectionToWindowServer::update_system_fonts(String const& default_font_query, String const& fixed_width_font_query)