mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +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]
|
[Colors]
|
||||||
Accent=#ff7f00
|
Accent=#ff7f00
|
||||||
DesktopBackground=#171717
|
DesktopBackground=#171717
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
[Menu]
|
||||||
|
Name=Chill&ychilly
|
||||||
[Colors]
|
[Colors]
|
||||||
DesktopBackground=#3f8077ff
|
DesktopBackground=#3f8077ff
|
||||||
Accent=#509296ff
|
Accent=#509296ff
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
[Menu]
|
||||||
|
Name=&Coffee
|
||||||
[Colors]
|
[Colors]
|
||||||
Accent=#574dbb
|
Accent=#574dbb
|
||||||
DesktopBackground=#567f9d
|
DesktopBackground=#567f9d
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
[Menu]
|
||||||
|
Name=Con&trast
|
||||||
[Metrics]
|
[Metrics]
|
||||||
TitleButtonWidth=15
|
TitleButtonWidth=15
|
||||||
BorderRadius=0
|
BorderRadius=0
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
[Menu]
|
||||||
|
Name=C&upertino
|
||||||
[Colors]
|
[Colors]
|
||||||
DesktopBackground=#55bff0
|
DesktopBackground=#55bff0
|
||||||
Accent=#55bff0
|
Accent=#55bff0
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
[Menu]
|
||||||
|
Name=Dar&k
|
||||||
[Colors]
|
[Colors]
|
||||||
Accent=#4d4d5f
|
Accent=#4d4d5f
|
||||||
DesktopBackground=#202020
|
DesktopBackground=#202020
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
[Menu]
|
||||||
|
Name=&Default
|
||||||
[Colors]
|
[Colors]
|
||||||
DesktopBackground=#505050
|
DesktopBackground=#505050
|
||||||
Accent=#ab6e4a
|
Accent=#ab6e4a
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
[Menu]
|
||||||
|
Name=D&esert
|
||||||
[Colors]
|
[Colors]
|
||||||
Accent=#84bdaa
|
Accent=#84bdaa
|
||||||
DesktopBackground=#a28d68
|
DesktopBackground=#a28d68
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
[Menu]
|
||||||
|
Name=Durr&que
|
||||||
[Metrics]
|
[Metrics]
|
||||||
TitleButtonWidth=15
|
TitleButtonWidth=15
|
||||||
BorderRadius=0
|
BorderRadius=0
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
[Menu]
|
||||||
|
Name=&Faux Pas
|
||||||
[Colors]
|
[Colors]
|
||||||
Accent=#000000
|
Accent=#000000
|
||||||
DesktopBackground=#505170
|
DesktopBackground=#505170
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
[Menu]
|
||||||
|
Name=&Gruvbox Dark
|
||||||
[Colors]
|
[Colors]
|
||||||
Accent=#79740e
|
Accent=#79740e
|
||||||
DesktopBackground=#282828
|
DesktopBackground=#282828
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
[Menu]
|
||||||
|
Name=&Light
|
||||||
[Colors]
|
[Colors]
|
||||||
Accent=#ffffff
|
Accent=#ffffff
|
||||||
DesktopBackground=#0f0f0f
|
DesktopBackground=#0f0f0f
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
[Menu]
|
||||||
|
Name=&Nord
|
||||||
[Colors]
|
[Colors]
|
||||||
Accent=#4c566a
|
Accent=#4c566a
|
||||||
DesktopBackground=#3b4252
|
DesktopBackground=#3b4252
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
[Menu]
|
||||||
|
Name=&Olive
|
||||||
[Metrics]
|
[Metrics]
|
||||||
TitleButtonWidth=15
|
TitleButtonWidth=15
|
||||||
BorderRadius=0
|
BorderRadius=0
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
[Menu]
|
||||||
|
Name=&Plum
|
||||||
[Colors]
|
[Colors]
|
||||||
Accent=#a084b8
|
Accent=#a084b8
|
||||||
DesktopBackground=#402840
|
DesktopBackground=#402840
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
[Menu]
|
||||||
|
Name=Pumpk&in
|
||||||
[Metrics]
|
[Metrics]
|
||||||
TitleButtonWidth=15
|
TitleButtonWidth=15
|
||||||
BorderRadius=0
|
BorderRadius=0
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
[Menu]
|
||||||
|
Name=Redmond &2000
|
||||||
[Colors]
|
[Colors]
|
||||||
Accent=#4a6eab
|
Accent=#4a6eab
|
||||||
DesktopBackground=#3a6ea5
|
DesktopBackground=#3a6ea5
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
[Menu]
|
||||||
|
Name=&Redmond
|
||||||
[Colors]
|
[Colors]
|
||||||
Accent=#0000ab
|
Accent=#0000ab
|
||||||
DesktopBackground=#008080
|
DesktopBackground=#008080
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
[Menu]
|
||||||
|
Name=&Scarlett
|
||||||
[Metrics]
|
[Metrics]
|
||||||
TitleButtonWidth=15
|
TitleButtonWidth=15
|
||||||
BorderRadius=0
|
BorderRadius=0
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
[Menu]
|
||||||
|
Name=Sil&ver
|
||||||
[Metrics]
|
[Metrics]
|
||||||
TitleButtonWidth=15
|
TitleButtonWidth=15
|
||||||
BorderRadius=0
|
BorderRadius=0
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
[Menu]
|
||||||
|
Name=Suns&hine
|
||||||
[Colors]
|
[Colors]
|
||||||
Accent=#b24d7a
|
Accent=#b24d7a
|
||||||
DesktopBackground=#574c8f
|
DesktopBackground=#574c8f
|
||||||
|
|
|
@ -204,7 +204,9 @@ ErrorOr<Vector<SystemThemeMetaData>> list_installed_system_themes()
|
||||||
while (dt.has_next()) {
|
while (dt.has_next()) {
|
||||||
auto theme_name = dt.next_path();
|
auto theme_name = dt.next_path();
|
||||||
auto theme_path = ByteString::formatted("/res/themes/{}", theme_name);
|
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; });
|
quick_sort(system_themes, [](auto& a, auto& b) { return a.name < b.name; });
|
||||||
return system_themes;
|
return system_themes;
|
||||||
|
|
|
@ -296,6 +296,7 @@ ErrorOr<Core::AnonymousBuffer> load_system_theme(ByteString const& path, Optiona
|
||||||
|
|
||||||
struct SystemThemeMetaData {
|
struct SystemThemeMetaData {
|
||||||
ByteString name;
|
ByteString name;
|
||||||
|
ByteString menu_name;
|
||||||
ByteString path;
|
ByteString path;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -239,9 +239,9 @@ ErrorOr<NonnullRefPtr<GUI::Menu>> build_system_menu(GUI::Window& window)
|
||||||
{
|
{
|
||||||
int theme_identifier = 0;
|
int theme_identifier = 0;
|
||||||
for (auto& theme : g_themes) {
|
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];
|
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)
|
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()));
|
VERIFY(GUI::ConnectionToWindowServer::the().set_system_theme(theme.path, theme.name, false, GUI::ConnectionToWindowServer::the().get_preferred_color_scheme()));
|
||||||
else
|
else
|
||||||
|
@ -260,9 +260,11 @@ ErrorOr<NonnullRefPtr<GUI::Menu>> build_system_menu(GUI::Window& window)
|
||||||
return;
|
return;
|
||||||
auto current_theme_name = GUI::ConnectionToWindowServer::the().get_system_theme();
|
auto current_theme_name = GUI::ConnectionToWindowServer::the().get_system_theme();
|
||||||
auto theme_overridden = GUI::ConnectionToWindowServer::the().is_system_theme_overridden();
|
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) {
|
for (size_t index = 0; index < g_themes.size(); ++index) {
|
||||||
auto* action = g_themes_menu->action_at(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