mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 17:10:23 +00:00
Taskbar: Add hotkeys for theme selector menu
This commit is contained in:
parent
420da686b8
commit
8e76265b0c
Notes:
sideshowbarker
2024-07-18 00:54:03 +09:00
Author: https://github.com/hughdavenport Commit: https://github.com/SerenityOS/serenity/commit/8e76265b0c Pull-request: https://github.com/SerenityOS/serenity/pull/22560 Reviewed-by: https://github.com/ADKaster ✅
24 changed files with 51 additions and 4 deletions
|
@ -1,3 +1,5 @@
|
|||
[Menu]
|
||||
Name=&Basalt
|
||||
[Colors]
|
||||
Accent=#ff7f00
|
||||
DesktopBackground=#171717
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
[Menu]
|
||||
Name=Chill&ychilly
|
||||
[Colors]
|
||||
DesktopBackground=#3f8077ff
|
||||
Accent=#509296ff
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
[Menu]
|
||||
Name=&Coffee
|
||||
[Colors]
|
||||
Accent=#574dbb
|
||||
DesktopBackground=#567f9d
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
[Menu]
|
||||
Name=Con&trast
|
||||
[Metrics]
|
||||
TitleButtonWidth=15
|
||||
BorderRadius=0
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
[Menu]
|
||||
Name=C&upertino
|
||||
[Colors]
|
||||
DesktopBackground=#55bff0
|
||||
Accent=#55bff0
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
[Menu]
|
||||
Name=Dar&k
|
||||
[Colors]
|
||||
Accent=#4d4d5f
|
||||
DesktopBackground=#202020
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
[Menu]
|
||||
Name=&Default
|
||||
[Colors]
|
||||
DesktopBackground=#505050
|
||||
Accent=#ab6e4a
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
[Menu]
|
||||
Name=D&esert
|
||||
[Colors]
|
||||
Accent=#84bdaa
|
||||
DesktopBackground=#a28d68
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
[Menu]
|
||||
Name=Durr&que
|
||||
[Metrics]
|
||||
TitleButtonWidth=15
|
||||
BorderRadius=0
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
[Menu]
|
||||
Name=&Faux Pas
|
||||
[Colors]
|
||||
Accent=#000000
|
||||
DesktopBackground=#505170
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
[Menu]
|
||||
Name=&Gruvbox Dark
|
||||
[Colors]
|
||||
Accent=#79740e
|
||||
DesktopBackground=#282828
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
[Menu]
|
||||
Name=&Light
|
||||
[Colors]
|
||||
Accent=#ffffff
|
||||
DesktopBackground=#0f0f0f
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
[Menu]
|
||||
Name=&Nord
|
||||
[Colors]
|
||||
Accent=#4c566a
|
||||
DesktopBackground=#3b4252
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
[Menu]
|
||||
Name=&Olive
|
||||
[Metrics]
|
||||
TitleButtonWidth=15
|
||||
BorderRadius=0
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
[Menu]
|
||||
Name=&Plum
|
||||
[Colors]
|
||||
Accent=#a084b8
|
||||
DesktopBackground=#402840
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
[Menu]
|
||||
Name=Pumpk&in
|
||||
[Metrics]
|
||||
TitleButtonWidth=15
|
||||
BorderRadius=0
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
[Menu]
|
||||
Name=Redmond &2000
|
||||
[Colors]
|
||||
Accent=#4a6eab
|
||||
DesktopBackground=#3a6ea5
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
[Menu]
|
||||
Name=&Redmond
|
||||
[Colors]
|
||||
Accent=#0000ab
|
||||
DesktopBackground=#008080
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
[Menu]
|
||||
Name=&Scarlett
|
||||
[Metrics]
|
||||
TitleButtonWidth=15
|
||||
BorderRadius=0
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
[Menu]
|
||||
Name=Sil&ver
|
||||
[Metrics]
|
||||
TitleButtonWidth=15
|
||||
BorderRadius=0
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
[Menu]
|
||||
Name=Suns&hine
|
||||
[Colors]
|
||||
Accent=#b24d7a
|
||||
DesktopBackground=#574c8f
|
||||
|
|
|
@ -204,7 +204,9 @@ ErrorOr<Vector<SystemThemeMetaData>> list_installed_system_themes()
|
|||
while (dt.has_next()) {
|
||||
auto theme_name = dt.next_path();
|
||||
auto theme_path = ByteString::formatted("/res/themes/{}", theme_name);
|
||||
TRY(system_themes.try_append({ LexicalPath::title(theme_name), theme_path }));
|
||||
auto config_file = TRY(Core::ConfigFile::open(theme_path));
|
||||
auto menu_name = config_file->read_entry("Menu", "Name", theme_name);
|
||||
TRY(system_themes.try_append({ LexicalPath::title(theme_name), menu_name, theme_path }));
|
||||
}
|
||||
quick_sort(system_themes, [](auto& a, auto& b) { return a.name < b.name; });
|
||||
return system_themes;
|
||||
|
|
|
@ -296,6 +296,7 @@ ErrorOr<Core::AnonymousBuffer> load_system_theme(ByteString const& path, Optiona
|
|||
|
||||
struct SystemThemeMetaData {
|
||||
ByteString name;
|
||||
ByteString menu_name;
|
||||
ByteString path;
|
||||
};
|
||||
|
||||
|
|
|
@ -239,9 +239,9 @@ ErrorOr<NonnullRefPtr<GUI::Menu>> build_system_menu(GUI::Window& window)
|
|||
{
|
||||
int theme_identifier = 0;
|
||||
for (auto& theme : g_themes) {
|
||||
auto action = GUI::Action::create_checkable(theme.name, [theme_identifier, &window](auto&) {
|
||||
auto action = GUI::Action::create_checkable(theme.menu_name, [theme_identifier, current_theme_name, &window](auto&) {
|
||||
auto& theme = g_themes[theme_identifier];
|
||||
dbgln("Theme switched to {} at path {}", theme.name, theme.path);
|
||||
dbgln("Theme switched from {} to {} at path {}", current_theme_name, theme.name, theme.path);
|
||||
if (window.main_widget()->palette().color_scheme_path() != ""sv)
|
||||
VERIFY(GUI::ConnectionToWindowServer::the().set_system_theme(theme.path, theme.name, false, GUI::ConnectionToWindowServer::the().get_preferred_color_scheme()));
|
||||
else
|
||||
|
@ -260,9 +260,11 @@ ErrorOr<NonnullRefPtr<GUI::Menu>> build_system_menu(GUI::Window& window)
|
|||
return;
|
||||
auto current_theme_name = GUI::ConnectionToWindowServer::the().get_system_theme();
|
||||
auto theme_overridden = GUI::ConnectionToWindowServer::the().is_system_theme_overridden();
|
||||
VERIFY(g_themes.size() == g_themes_menu->items().size());
|
||||
for (size_t index = 0; index < g_themes.size(); ++index) {
|
||||
auto* action = g_themes_menu->action_at(index);
|
||||
action->set_checked(!theme_overridden && action->text() == current_theme_name);
|
||||
auto& theme = g_themes[index];
|
||||
action->set_checked(!theme_overridden && theme.name == current_theme_name);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue