mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:57:45 +00:00
LibGUI: Add on_theme_change callback to Application
This allows an Application without a window to listen for theme changes.
This commit is contained in:
parent
84780f3ed5
commit
535e1c9152
3 changed files with 7 additions and 0 deletions
|
@ -311,6 +311,10 @@ void Application::event(Core::Event& event)
|
||||||
on_action_leave(action);
|
on_action_leave(action);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (event.type() == GUI::Event::ThemeChange) {
|
||||||
|
if (on_theme_change)
|
||||||
|
on_theme_change();
|
||||||
|
}
|
||||||
Object::event(event);
|
Object::event(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,6 +83,7 @@ public:
|
||||||
|
|
||||||
Function<void(Action&)> on_action_enter;
|
Function<void(Action&)> on_action_enter;
|
||||||
Function<void(Action&)> on_action_leave;
|
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; }
|
auto const& global_shortcut_actions(Badge<GUI::CommandPalette>) const { return m_global_shortcut_actions; }
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,8 @@ void ConnectionToWindowServer::update_system_theme(Core::AnonymousBuffer const&
|
||||||
Window::for_each_window({}, [](auto& window) {
|
Window::for_each_window({}, [](auto& window) {
|
||||||
Core::EventLoop::current().post_event(window, make<ThemeChangeEvent>());
|
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)
|
void ConnectionToWindowServer::update_system_fonts(String const& default_font_query, String const& fixed_width_font_query)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue