mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 19:57:36 +00:00
Terminal+LibVT: Get the color scheme from the system theme
This commit is contained in:
parent
8eb402f8e5
commit
800c292be8
5 changed files with 38 additions and 107 deletions
|
@ -72,19 +72,15 @@ public:
|
|||
{
|
||||
VERIFY(domain == "Terminal");
|
||||
|
||||
if (group == "Window") {
|
||||
if (key == "Bell") {
|
||||
auto bell_mode = VT::TerminalWidget::BellMode::Visible;
|
||||
if (value == "AudibleBeep")
|
||||
bell_mode = VT::TerminalWidget::BellMode::AudibleBeep;
|
||||
if (value == "Visible")
|
||||
bell_mode = VT::TerminalWidget::BellMode::Visible;
|
||||
if (value == "Disabled")
|
||||
bell_mode = VT::TerminalWidget::BellMode::Disabled;
|
||||
m_parent_terminal.set_bell_mode(bell_mode);
|
||||
} else if (key == "ColorScheme") {
|
||||
m_parent_terminal.set_color_scheme(value);
|
||||
}
|
||||
if (group == "Window" && key == "Bell") {
|
||||
auto bell_mode = VT::TerminalWidget::BellMode::Visible;
|
||||
if (value == "AudibleBeep")
|
||||
bell_mode = VT::TerminalWidget::BellMode::AudibleBeep;
|
||||
if (value == "Visible")
|
||||
bell_mode = VT::TerminalWidget::BellMode::Visible;
|
||||
if (value == "Disabled")
|
||||
bell_mode = VT::TerminalWidget::BellMode::Disabled;
|
||||
m_parent_terminal.set_bell_mode(bell_mode);
|
||||
} else if (group == "Text" && key == "Font") {
|
||||
auto font = Gfx::FontDatabase::the().get_by_name(value);
|
||||
if (font.is_null())
|
||||
|
|
|
@ -85,17 +85,4 @@
|
|||
text: "Blinking cursor"
|
||||
}
|
||||
}
|
||||
|
||||
@GUI::GroupBox {
|
||||
title: "Color Scheme"
|
||||
preferred_height: "fit"
|
||||
layout: @GUI::VerticalBoxLayout {
|
||||
margins: [16, 8, 8]
|
||||
spacing: 16
|
||||
}
|
||||
|
||||
@GUI::ComboBox {
|
||||
name: "color_scheme_combo"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,30 +114,6 @@ TerminalSettingsViewWidget::TerminalSettingsViewWidget()
|
|||
set_modified(true);
|
||||
};
|
||||
|
||||
m_color_scheme = Config::read_string("Terminal"sv, "Window"sv, "ColorScheme"sv);
|
||||
m_original_color_scheme = m_color_scheme;
|
||||
// The settings window takes a reference to this vector, so it needs to outlive this scope.
|
||||
// As long as we ensure that only one settings window may be open at a time (which we do),
|
||||
// this should cause no problems.
|
||||
static Vector<DeprecatedString> color_scheme_names;
|
||||
color_scheme_names.clear();
|
||||
Core::DirIterator iterator("/res/color-schemes", Core::DirIterator::SkipParentAndBaseDir);
|
||||
while (iterator.has_next()) {
|
||||
auto path = iterator.next_path();
|
||||
color_scheme_names.append(path.replace(".ini"sv, ""sv, ReplaceMode::FirstOnly));
|
||||
}
|
||||
quick_sort(color_scheme_names);
|
||||
auto& color_scheme_combo = *find_descendant_of_type_named<GUI::ComboBox>("color_scheme_combo");
|
||||
color_scheme_combo.set_only_allow_values_from_model(true);
|
||||
color_scheme_combo.set_model(*GUI::ItemListModel<DeprecatedString>::create(color_scheme_names));
|
||||
color_scheme_combo.set_selected_index(color_scheme_names.find_first_index(m_color_scheme).value());
|
||||
color_scheme_combo.set_enabled(color_scheme_names.size() > 1);
|
||||
color_scheme_combo.on_change = [&](auto&, const GUI::ModelIndex& index) {
|
||||
m_color_scheme = index.data().as_string();
|
||||
Config::write_string("Terminal"sv, "Window"sv, "ColorScheme"sv, m_color_scheme);
|
||||
set_modified(true);
|
||||
};
|
||||
|
||||
auto& font_button = *find_descendant_of_type_named<GUI::Button>("terminal_font_button");
|
||||
auto& font_text = *find_descendant_of_type_named<GUI::Label>("terminal_font_label");
|
||||
auto font_name = Config::read_string("Terminal"sv, "Text"sv, "Font"sv);
|
||||
|
@ -281,7 +257,6 @@ void TerminalSettingsViewWidget::apply_settings()
|
|||
{
|
||||
m_original_opacity = m_opacity;
|
||||
m_original_font = m_font;
|
||||
m_original_color_scheme = m_color_scheme;
|
||||
m_original_cursor_shape = m_cursor_shape;
|
||||
m_original_cursor_is_blinking_set = m_cursor_is_blinking_set;
|
||||
write_back_settings();
|
||||
|
@ -291,7 +266,6 @@ void TerminalSettingsViewWidget::write_back_settings() const
|
|||
{
|
||||
Config::write_i32("Terminal"sv, "Window"sv, "Opacity"sv, static_cast<i32>(m_original_opacity));
|
||||
Config::write_string("Terminal"sv, "Text"sv, "Font"sv, m_original_font->qualified_name());
|
||||
Config::write_string("Terminal"sv, "Window"sv, "ColorScheme"sv, m_original_color_scheme);
|
||||
Config::write_string("Terminal"sv, "Cursor"sv, "Shape"sv, VT::TerminalWidget::stringify_cursor_shape(m_original_cursor_shape));
|
||||
Config::write_bool("Terminal"sv, "Cursor"sv, "Blinking"sv, m_original_cursor_is_blinking_set);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue