From ab4035e227ccd3b9cf81453f9387ca0dc0de1272 Mon Sep 17 00:00:00 2001 From: Brian Gianforcaro Date: Fri, 14 Jan 2022 20:40:30 -0800 Subject: TerminalSettings: Expose a CheckBox controlling scrollbar visibility --- .../Applications/TerminalSettings/TerminalSettingsMain.gml | 5 +++++ .../Applications/TerminalSettings/TerminalSettingsWidget.cpp | 11 +++++++++++ .../Applications/TerminalSettings/TerminalSettingsWidget.h | 2 ++ 3 files changed, 18 insertions(+) (limited to 'Userland') diff --git a/Userland/Applications/TerminalSettings/TerminalSettingsMain.gml b/Userland/Applications/TerminalSettings/TerminalSettingsMain.gml index 5a44a1f955..dddb7dadb6 100644 --- a/Userland/Applications/TerminalSettings/TerminalSettingsMain.gml +++ b/Userland/Applications/TerminalSettings/TerminalSettingsMain.gml @@ -53,6 +53,11 @@ margins: [16, 8, 8] } + @GUI::CheckBox { + name: "terminal_show_scrollbar" + text: "Show scrollbar" + } + @GUI::SpinBox { name: "history_size_spinbox" min: 0 diff --git a/Userland/Applications/TerminalSettings/TerminalSettingsWidget.cpp b/Userland/Applications/TerminalSettings/TerminalSettingsWidget.cpp index 83551f5589..0399efe935 100644 --- a/Userland/Applications/TerminalSettings/TerminalSettingsWidget.cpp +++ b/Userland/Applications/TerminalSettings/TerminalSettingsWidget.cpp @@ -74,6 +74,15 @@ TerminalSettingsMainWidget::TerminalSettingsMainWidget() m_max_history_size = value; Config::write_i32("Terminal", "Terminal", "MaxHistorySize", static_cast(m_max_history_size)); }; + + m_show_scrollbar = Config::read_bool("Terminal", "Terminal", "ShowScrollBar", true); + m_orignal_show_scrollbar = m_show_scrollbar; + auto& show_scrollbar_checkbox = *find_descendant_of_type_named("terminal_show_scrollbar"); + show_scrollbar_checkbox.on_checked = [&](bool show_scrollbar) { + m_show_scrollbar = show_scrollbar; + Config::write_bool("Terminal", "Terminal", "ShowScrollBar", show_scrollbar); + }; + show_scrollbar_checkbox.set_checked(m_show_scrollbar); } TerminalSettingsViewWidget::TerminalSettingsViewWidget() @@ -175,12 +184,14 @@ String TerminalSettingsMainWidget::stringify_bell(VT::TerminalWidget::BellMode b void TerminalSettingsMainWidget::apply_settings() { m_original_max_history_size = m_max_history_size; + m_orignal_show_scrollbar = m_show_scrollbar; m_original_bell_mode = m_bell_mode; write_back_settings(); } void TerminalSettingsMainWidget::write_back_settings() const { Config::write_i32("Terminal", "Terminal", "MaxHistorySize", static_cast(m_original_max_history_size)); + Config::write_bool("Terminal", "Terminal", "ShowScrollBar", m_orignal_show_scrollbar); Config::write_string("Terminal", "Window", "Bell", stringify_bell(m_original_bell_mode)); } diff --git a/Userland/Applications/TerminalSettings/TerminalSettingsWidget.h b/Userland/Applications/TerminalSettings/TerminalSettingsWidget.h index 4f97f15a7c..5b6e280fe8 100644 --- a/Userland/Applications/TerminalSettings/TerminalSettingsWidget.h +++ b/Userland/Applications/TerminalSettings/TerminalSettingsWidget.h @@ -28,9 +28,11 @@ private: VT::TerminalWidget::BellMode m_bell_mode = VT::TerminalWidget::BellMode::Disabled; size_t m_max_history_size; + bool m_show_scrollbar { true }; VT::TerminalWidget::BellMode m_original_bell_mode; size_t m_original_max_history_size; + bool m_orignal_show_scrollbar { true }; }; class TerminalSettingsViewWidget final : public GUI::SettingsWindow::Tab { -- cgit v1.2.3