mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:47:35 +00:00
DisplaySettings: Add an Effects tab
Effects tab provides the UI for setting SystemEffects. DisplaySettings is getting a bit crowded and might need a re-org at some point, but this seems like a good home for effects while the settings mature.
This commit is contained in:
parent
8b5280b5dd
commit
1d445356b6
5 changed files with 322 additions and 1 deletions
|
@ -4,10 +4,11 @@ serenity_component(
|
||||||
TARGETS DisplaySettings
|
TARGETS DisplaySettings
|
||||||
)
|
)
|
||||||
|
|
||||||
compile_gml(MonitorSettings.gml MonitorSettingsGML.h monitor_settings_window_gml)
|
|
||||||
compile_gml(BackgroundSettings.gml BackgroundSettingsGML.h background_settings_gml)
|
compile_gml(BackgroundSettings.gml BackgroundSettingsGML.h background_settings_gml)
|
||||||
compile_gml(DesktopSettings.gml DesktopSettingsGML.h desktop_settings_gml)
|
compile_gml(DesktopSettings.gml DesktopSettingsGML.h desktop_settings_gml)
|
||||||
|
compile_gml(EffectsSettings.gml EffectsSettingsGML.h effects_settings_gml)
|
||||||
compile_gml(FontSettings.gml FontSettingsGML.h font_settings_gml)
|
compile_gml(FontSettings.gml FontSettingsGML.h font_settings_gml)
|
||||||
|
compile_gml(MonitorSettings.gml MonitorSettingsGML.h monitor_settings_window_gml)
|
||||||
compile_gml(ThemesSettings.gml ThemesSettingsGML.h themes_settings_gml)
|
compile_gml(ThemesSettings.gml ThemesSettingsGML.h themes_settings_gml)
|
||||||
|
|
||||||
set(SOURCES
|
set(SOURCES
|
||||||
|
@ -15,6 +16,8 @@ set(SOURCES
|
||||||
BackgroundSettingsWidget.cpp
|
BackgroundSettingsWidget.cpp
|
||||||
DesktopSettingsWidget.cpp
|
DesktopSettingsWidget.cpp
|
||||||
DesktopSettingsGML.h
|
DesktopSettingsGML.h
|
||||||
|
EffectsSettingsGML.h
|
||||||
|
EffectsSettingsWidget.cpp
|
||||||
FontSettingsGML.h
|
FontSettingsGML.h
|
||||||
FontSettingsWidget.cpp
|
FontSettingsWidget.cpp
|
||||||
MonitorSettingsWidget.cpp
|
MonitorSettingsWidget.cpp
|
||||||
|
|
151
Userland/Applications/DisplaySettings/EffectsSettings.gml
Normal file
151
Userland/Applications/DisplaySettings/EffectsSettings.gml
Normal file
|
@ -0,0 +1,151 @@
|
||||||
|
@GUI::Widget {
|
||||||
|
fill_with_background_color: true
|
||||||
|
layout: @GUI::VerticalBoxLayout {
|
||||||
|
margins: [8]
|
||||||
|
spacing: 8
|
||||||
|
}
|
||||||
|
|
||||||
|
@GUI::GroupBox {
|
||||||
|
preferred_height: "shrink"
|
||||||
|
title: "Animations"
|
||||||
|
layout: @GUI::VerticalBoxLayout {
|
||||||
|
margins: [8]
|
||||||
|
spacing: 2
|
||||||
|
}
|
||||||
|
|
||||||
|
@GUI::Widget {
|
||||||
|
layout: @GUI::HorizontalBoxLayout {
|
||||||
|
spacing: 16
|
||||||
|
}
|
||||||
|
|
||||||
|
@GUI::Widget {
|
||||||
|
fixed_width: 32
|
||||||
|
layout: @GUI::VerticalBoxLayout {}
|
||||||
|
|
||||||
|
@GUI::ImageWidget {
|
||||||
|
bitmap: "/res/icons/32x32/animation-effects.png"
|
||||||
|
}
|
||||||
|
|
||||||
|
@GUI::Layout::Spacer {}
|
||||||
|
}
|
||||||
|
|
||||||
|
@GUI::Widget {
|
||||||
|
layout: @GUI::VerticalBoxLayout {
|
||||||
|
margins: [4, 0, 0, 0]
|
||||||
|
}
|
||||||
|
|
||||||
|
@GUI::CheckBox {
|
||||||
|
name: "animate_menus_checkbox"
|
||||||
|
text: "Fade menus on activation"
|
||||||
|
}
|
||||||
|
|
||||||
|
@GUI::CheckBox {
|
||||||
|
name: "flash_menus_checkbox"
|
||||||
|
text: "Flash menus activated by keyboard shortcuts"
|
||||||
|
}
|
||||||
|
|
||||||
|
@GUI::CheckBox {
|
||||||
|
name: "animate_windows_checkbox"
|
||||||
|
text: "Animate windows when minimizing and maximizing"
|
||||||
|
}
|
||||||
|
|
||||||
|
@GUI::CheckBox {
|
||||||
|
name: "smooth_scrolling_checkbox"
|
||||||
|
text: "Use smooth scrolling"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@GUI::GroupBox {
|
||||||
|
preferred_height: "shrink"
|
||||||
|
title: "Appearance"
|
||||||
|
layout: @GUI::VerticalBoxLayout {
|
||||||
|
margins: [8]
|
||||||
|
spacing: 2
|
||||||
|
}
|
||||||
|
|
||||||
|
@GUI::Widget {
|
||||||
|
layout: @GUI::HorizontalBoxLayout {
|
||||||
|
spacing: 16
|
||||||
|
}
|
||||||
|
|
||||||
|
@GUI::Widget {
|
||||||
|
fixed_width: 32
|
||||||
|
layout: @GUI::VerticalBoxLayout {}
|
||||||
|
|
||||||
|
@GUI::ImageWidget {
|
||||||
|
bitmap: "/res/icons/32x32/theming-effects.png"
|
||||||
|
}
|
||||||
|
|
||||||
|
@GUI::Layout::Spacer {}
|
||||||
|
}
|
||||||
|
|
||||||
|
@GUI::Widget {
|
||||||
|
layout: @GUI::VerticalBoxLayout {
|
||||||
|
margins: [4, 0, 0, 0]
|
||||||
|
}
|
||||||
|
|
||||||
|
@GUI::CheckBox {
|
||||||
|
name: "tab_accents_checkbox"
|
||||||
|
text: "Show accents on tabs"
|
||||||
|
}
|
||||||
|
|
||||||
|
@GUI::CheckBox {
|
||||||
|
name: "splitter_knurls_checkbox"
|
||||||
|
text: "Show knurls on splitters"
|
||||||
|
}
|
||||||
|
|
||||||
|
@GUI::Widget {
|
||||||
|
fixed_height: 4
|
||||||
|
}
|
||||||
|
|
||||||
|
@GUI::Widget {
|
||||||
|
layout: @GUI::HorizontalBoxLayout {}
|
||||||
|
|
||||||
|
@GUI::Label {
|
||||||
|
text: "Show window geometry:"
|
||||||
|
autosize: true
|
||||||
|
}
|
||||||
|
|
||||||
|
@GUI::Layout::Spacer {}
|
||||||
|
|
||||||
|
@GUI::ComboBox {
|
||||||
|
name: "geometry_combobox"
|
||||||
|
fixed_width: 130
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@GUI::Widget {
|
||||||
|
fixed_height: 4
|
||||||
|
}
|
||||||
|
|
||||||
|
@GUI::Widget {
|
||||||
|
layout: @GUI::HorizontalBoxLayout {}
|
||||||
|
|
||||||
|
@GUI::Label {
|
||||||
|
text: "Shadows"
|
||||||
|
autosize: true
|
||||||
|
}
|
||||||
|
|
||||||
|
@GUI::HorizontalSeparator {}
|
||||||
|
}
|
||||||
|
|
||||||
|
@GUI::CheckBox {
|
||||||
|
name: "menu_shadow_checkbox"
|
||||||
|
text: "Show menu shadow"
|
||||||
|
}
|
||||||
|
|
||||||
|
@GUI::CheckBox {
|
||||||
|
name: "window_shadow_checkbox"
|
||||||
|
text: "Show window shadow"
|
||||||
|
}
|
||||||
|
|
||||||
|
@GUI::CheckBox {
|
||||||
|
name: "tooltip_shadow_checkbox"
|
||||||
|
text: "Show tooltip shadow"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
129
Userland/Applications/DisplaySettings/EffectsSettingsWidget.cpp
Normal file
129
Userland/Applications/DisplaySettings/EffectsSettingsWidget.cpp
Normal file
|
@ -0,0 +1,129 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022, the SerenityOS developers.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "EffectsSettingsWidget.h"
|
||||||
|
#include <Applications/DisplaySettings/EffectsSettingsGML.h>
|
||||||
|
#include <LibCore/ConfigFile.h>
|
||||||
|
#include <LibGUI/CheckBox.h>
|
||||||
|
#include <LibGUI/ComboBox.h>
|
||||||
|
#include <LibGUI/ConnectionToWindowServer.h>
|
||||||
|
#include <LibGUI/ItemListModel.h>
|
||||||
|
|
||||||
|
namespace GUI {
|
||||||
|
|
||||||
|
namespace DisplaySettings {
|
||||||
|
|
||||||
|
EffectsSettingsWidget::EffectsSettingsWidget()
|
||||||
|
{
|
||||||
|
load_from_gml(effects_settings_gml);
|
||||||
|
|
||||||
|
m_geometry_combobox = find_descendant_of_type_named<ComboBox>("geometry_combobox");
|
||||||
|
m_geometry_combobox->set_only_allow_values_from_model(true);
|
||||||
|
m_geometry_combobox->on_change = [this](auto&, auto&) {
|
||||||
|
m_system_effects.set_geometry(static_cast<ShowGeometry>(m_geometry_combobox->selected_index()));
|
||||||
|
set_modified(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (auto result = load_settings(); result.is_error()) {
|
||||||
|
warnln("Failed to load [Effects] from WindowServer.ini");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto& animate_menus = *find_descendant_of_type_named<GUI::CheckBox>("animate_menus_checkbox");
|
||||||
|
animate_menus.set_checked(m_system_effects.animate_menus());
|
||||||
|
animate_menus.on_checked = [this](bool checked) {
|
||||||
|
m_system_effects.effects().at(Effects::AnimateMenus) = checked;
|
||||||
|
set_modified(true);
|
||||||
|
};
|
||||||
|
auto& flash_menus = *find_descendant_of_type_named<GUI::CheckBox>("flash_menus_checkbox");
|
||||||
|
flash_menus.set_checked(m_system_effects.flash_menus());
|
||||||
|
flash_menus.on_checked = [this](bool checked) {
|
||||||
|
m_system_effects.effects().at(Effects::FlashMenus) = checked;
|
||||||
|
set_modified(true);
|
||||||
|
};
|
||||||
|
auto& animate_windows = *find_descendant_of_type_named<GUI::CheckBox>("animate_windows_checkbox");
|
||||||
|
animate_windows.set_checked(m_system_effects.animate_windows());
|
||||||
|
animate_windows.on_checked = [this](bool checked) {
|
||||||
|
m_system_effects.effects().at(Effects::AnimateWindows) = checked;
|
||||||
|
set_modified(true);
|
||||||
|
};
|
||||||
|
auto& smooth_scrolling = *find_descendant_of_type_named<GUI::CheckBox>("smooth_scrolling_checkbox");
|
||||||
|
smooth_scrolling.set_checked(m_system_effects.smooth_scrolling());
|
||||||
|
smooth_scrolling.on_checked = [this](bool checked) {
|
||||||
|
m_system_effects.effects().at(Effects::SmoothScrolling) = checked;
|
||||||
|
set_modified(true);
|
||||||
|
};
|
||||||
|
auto& tab_accents = *find_descendant_of_type_named<GUI::CheckBox>("tab_accents_checkbox");
|
||||||
|
tab_accents.set_checked(m_system_effects.tab_accents());
|
||||||
|
tab_accents.on_checked = [this](bool checked) {
|
||||||
|
m_system_effects.effects().at(Effects::TabAccents) = checked;
|
||||||
|
set_modified(true);
|
||||||
|
};
|
||||||
|
auto& splitter_knurls = *find_descendant_of_type_named<GUI::CheckBox>("splitter_knurls_checkbox");
|
||||||
|
splitter_knurls.set_checked(m_system_effects.splitter_knurls());
|
||||||
|
splitter_knurls.on_checked = [this](bool checked) {
|
||||||
|
m_system_effects.effects().at(Effects::SplitterKnurls) = checked;
|
||||||
|
set_modified(true);
|
||||||
|
};
|
||||||
|
auto& menu_shadow = *find_descendant_of_type_named<GUI::CheckBox>("menu_shadow_checkbox");
|
||||||
|
menu_shadow.set_checked(m_system_effects.menu_shadow());
|
||||||
|
menu_shadow.on_checked = [this](bool checked) {
|
||||||
|
m_system_effects.effects().at(Effects::MenuShadow) = checked;
|
||||||
|
set_modified(true);
|
||||||
|
};
|
||||||
|
auto& window_shadow = *find_descendant_of_type_named<GUI::CheckBox>("window_shadow_checkbox");
|
||||||
|
window_shadow.set_checked(m_system_effects.window_shadow());
|
||||||
|
window_shadow.on_checked = [this](bool checked) {
|
||||||
|
m_system_effects.effects().at(Effects::WindowShadow) = checked;
|
||||||
|
set_modified(true);
|
||||||
|
};
|
||||||
|
auto& tooltip_shadow = *find_descendant_of_type_named<GUI::CheckBox>("tooltip_shadow_checkbox");
|
||||||
|
tooltip_shadow.set_checked(m_system_effects.tooltip_shadow());
|
||||||
|
tooltip_shadow.on_checked = [this](bool checked) {
|
||||||
|
m_system_effects.effects().at(Effects::TooltipShadow) = checked;
|
||||||
|
set_modified(true);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
ErrorOr<void> EffectsSettingsWidget::load_settings()
|
||||||
|
{
|
||||||
|
auto ws_config = TRY(Core::ConfigFile::open("/etc/WindowServer.ini"));
|
||||||
|
Vector<bool> effects = {
|
||||||
|
ws_config->read_bool_entry("Effects", "AnimateMenus", true),
|
||||||
|
ws_config->read_bool_entry("Effects", "FlashMenus", true),
|
||||||
|
ws_config->read_bool_entry("Effects", "AnimateWindows", true),
|
||||||
|
ws_config->read_bool_entry("Effects", "SmoothScrolling", true),
|
||||||
|
ws_config->read_bool_entry("Effects", "TabAccents", true),
|
||||||
|
ws_config->read_bool_entry("Effects", "SplitterKnurls", true),
|
||||||
|
ws_config->read_bool_entry("Effects", "MenuShadow", true),
|
||||||
|
ws_config->read_bool_entry("Effects", "WindowShadow", true),
|
||||||
|
ws_config->read_bool_entry("Effects", "TooltipShadow", true),
|
||||||
|
};
|
||||||
|
auto geometry = WindowServer::ShowGeometryTools::string_to_enum(ws_config->read_entry("Effects", "ShowGeometry", "OnMoveAndResize"));
|
||||||
|
m_system_effects = { effects, geometry };
|
||||||
|
|
||||||
|
static constexpr Array list = {
|
||||||
|
"On Move and Resize"sv,
|
||||||
|
"On Move only"sv,
|
||||||
|
"On Resize only"sv,
|
||||||
|
"Never"sv
|
||||||
|
};
|
||||||
|
for (size_t i = 0; i < list.size(); ++i)
|
||||||
|
TRY(m_geometry_list.try_append(list[i]));
|
||||||
|
m_geometry_combobox->set_model(ItemListModel<String>::create(m_geometry_list));
|
||||||
|
m_geometry_combobox->set_selected_index(m_system_effects.geometry());
|
||||||
|
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
void EffectsSettingsWidget::apply_settings()
|
||||||
|
{
|
||||||
|
ConnectionToWindowServer::the().async_set_system_effects(m_system_effects.effects(), m_system_effects.geometry());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022, the SerenityOS developers.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <LibGUI/SettingsWindow.h>
|
||||||
|
#include <LibGUI/SystemEffects.h>
|
||||||
|
|
||||||
|
namespace GUI {
|
||||||
|
|
||||||
|
namespace DisplaySettings {
|
||||||
|
|
||||||
|
class EffectsSettingsWidget final : public SettingsWindow::Tab {
|
||||||
|
C_OBJECT(EffectsSettingsWidget);
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual ~EffectsSettingsWidget() override = default;
|
||||||
|
|
||||||
|
virtual void apply_settings() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
EffectsSettingsWidget();
|
||||||
|
|
||||||
|
ErrorOr<void> load_settings();
|
||||||
|
|
||||||
|
SystemEffects m_system_effects;
|
||||||
|
Vector<String> m_geometry_list;
|
||||||
|
RefPtr<ComboBox> m_geometry_combobox;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
#include "BackgroundSettingsWidget.h"
|
#include "BackgroundSettingsWidget.h"
|
||||||
#include "DesktopSettingsWidget.h"
|
#include "DesktopSettingsWidget.h"
|
||||||
|
#include "EffectsSettingsWidget.h"
|
||||||
#include "FontSettingsWidget.h"
|
#include "FontSettingsWidget.h"
|
||||||
#include "MonitorSettingsWidget.h"
|
#include "MonitorSettingsWidget.h"
|
||||||
#include "ThemesSettingsWidget.h"
|
#include "ThemesSettingsWidget.h"
|
||||||
|
@ -41,6 +42,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
(void)TRY(window->add_tab<DisplaySettings::FontSettingsWidget>("Fonts"sv, "fonts"sv));
|
(void)TRY(window->add_tab<DisplaySettings::FontSettingsWidget>("Fonts"sv, "fonts"sv));
|
||||||
(void)TRY(window->add_tab<DisplaySettings::MonitorSettingsWidget>("Monitor"sv, "monitor"sv));
|
(void)TRY(window->add_tab<DisplaySettings::MonitorSettingsWidget>("Monitor"sv, "monitor"sv));
|
||||||
(void)TRY(window->add_tab<DisplaySettings::DesktopSettingsWidget>("Workspaces"sv, "workspaces"sv));
|
(void)TRY(window->add_tab<DisplaySettings::DesktopSettingsWidget>("Workspaces"sv, "workspaces"sv));
|
||||||
|
(void)TRY(window->add_tab<GUI::DisplaySettings::EffectsSettingsWidget>("Effects"sv, "effects"sv));
|
||||||
window->set_active_tab(selected_tab);
|
window->set_active_tab(selected_tab);
|
||||||
|
|
||||||
window->set_icon(app_icon.bitmap_for_size(16));
|
window->set_icon(app_icon.bitmap_for_size(16));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue