mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:07:35 +00:00
Terminal: Settings windows can be opened multiple times
This commit is contained in:
parent
f8a02d4733
commit
6a4cb25557
6 changed files with 67 additions and 5964 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -12,3 +12,4 @@ Toolchain/Tarballs
|
||||||
Toolchain/Build
|
Toolchain/Build
|
||||||
Toolchain/Local
|
Toolchain/Local
|
||||||
.vscode
|
.vscode
|
||||||
|
compile_commands.json
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
[]
|
|
|
@ -26,7 +26,8 @@ public:
|
||||||
void apply_size_increments_to_window(GWindow&);
|
void apply_size_increments_to_window(GWindow&);
|
||||||
|
|
||||||
void set_opacity(float);
|
void set_opacity(float);
|
||||||
bool should_beep() { return m_should_beep; };
|
float opacity() { return m_opacity; };
|
||||||
|
bool should_beep() { return m_should_beep; }
|
||||||
void set_should_beep(bool sb) { m_should_beep = sb; };
|
void set_should_beep(bool sb) { m_should_beep = sb; };
|
||||||
|
|
||||||
RetainPtr<CConfigFile> config() const { return m_config; }
|
RetainPtr<CConfigFile> config() const { return m_config; }
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
#include "Terminal.h"
|
#include "Terminal.h"
|
||||||
#include <Kernel/KeyCode.h>
|
#include <Kernel/KeyCode.h>
|
||||||
#include <LibGUI/GApplication.h>
|
#include <LibGUI/GApplication.h>
|
||||||
|
#include <LibGUI/GBoxLayout.h>
|
||||||
|
#include <LibGUI/GRadioButton.h>
|
||||||
#include <LibGUI/GWidget.h>
|
#include <LibGUI/GWidget.h>
|
||||||
#include <LibGUI/GWindow.h>
|
#include <LibGUI/GWindow.h>
|
||||||
#include <LibGUI/GMenuBar.h>
|
#include <LibGUI/GMenuBar.h>
|
||||||
|
@ -78,6 +80,50 @@ static void make_shell(int ptm_fd)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GWindow* create_opacity_settings_window(Terminal& terminal, RetainPtr<CConfigFile> config)
|
||||||
|
{
|
||||||
|
auto* opacity_adjustment_window = new GWindow;
|
||||||
|
opacity_adjustment_window->set_title("Adjust opacity");
|
||||||
|
opacity_adjustment_window->set_rect(50, 50, 200, 100);
|
||||||
|
|
||||||
|
auto* slider = new GSlider(nullptr);
|
||||||
|
opacity_adjustment_window->set_main_widget(slider);
|
||||||
|
slider->set_fill_with_background_color(true);
|
||||||
|
slider->set_background_color(Color::LightGray);
|
||||||
|
|
||||||
|
slider->on_value_changed = [&terminal, &config] (int value) {
|
||||||
|
float opacity = value / 100.0;
|
||||||
|
terminal.set_opacity(opacity);
|
||||||
|
};
|
||||||
|
|
||||||
|
slider->set_range(0, 100);
|
||||||
|
slider->set_value(terminal.opacity() * 100.0);
|
||||||
|
|
||||||
|
return opacity_adjustment_window;
|
||||||
|
}
|
||||||
|
|
||||||
|
GWindow* create_beep_choice_window(Terminal& terminal, RetainPtr<CConfigFile> config)
|
||||||
|
{
|
||||||
|
auto* beep_choice_window = new GWindow;
|
||||||
|
beep_choice_window->set_title("Terminal beep settings");
|
||||||
|
beep_choice_window->set_rect(50, 50, 200, 100);
|
||||||
|
|
||||||
|
auto* radio_buttons = new GWidget;
|
||||||
|
beep_choice_window->set_main_widget(radio_buttons);
|
||||||
|
radio_buttons->set_fill_with_background_color(true);
|
||||||
|
radio_buttons->set_layout(make<GBoxLayout>(Orientation::Vertical));
|
||||||
|
radio_buttons->layout()->set_margins({ 4, 4, 4, 4 });
|
||||||
|
|
||||||
|
auto* sysbell_radio = new GRadioButton("Use (Audible) System Bell", radio_buttons);
|
||||||
|
auto* visbell_radio = new GRadioButton("Use (Visual) Terminal Bell", radio_buttons);
|
||||||
|
sysbell_radio->set_checked(terminal.should_beep());
|
||||||
|
visbell_radio->set_checked(!terminal.should_beep());
|
||||||
|
sysbell_radio->on_checked = [&terminal] (const bool res) {
|
||||||
|
terminal.set_should_beep(res);
|
||||||
|
};
|
||||||
|
return beep_choice_window;
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
GApplication app(argc, argv);
|
GApplication app(argc, argv);
|
||||||
|
@ -108,39 +154,11 @@ int main(int argc, char** argv)
|
||||||
window->set_icon_path("/res/icons/16x16/app-terminal.png");
|
window->set_icon_path("/res/icons/16x16/app-terminal.png");
|
||||||
terminal.set_should_beep(config->read_num_entry("Window", "AudibleBeep", 1) == 1);
|
terminal.set_should_beep(config->read_num_entry("Window", "AudibleBeep", 1) == 1);
|
||||||
|
|
||||||
auto* opacity_adjustment_window = new GWindow;
|
WeakPtr<GWindow> opacity_adjustment_window =
|
||||||
opacity_adjustment_window->set_title("Adjust opacity");
|
create_opacity_settings_window(terminal, config)->make_weak_ptr();
|
||||||
opacity_adjustment_window->set_rect(50, 50, 200, 100);
|
|
||||||
|
|
||||||
auto* slider = new GSlider(nullptr);
|
WeakPtr<GWindow> beep_choice_window =
|
||||||
opacity_adjustment_window->set_main_widget(slider);
|
create_beep_choice_window(terminal, config)->make_weak_ptr();
|
||||||
slider->set_fill_with_background_color(true);
|
|
||||||
slider->set_background_color(Color::LightGray);
|
|
||||||
|
|
||||||
slider->on_value_changed = [&terminal, &config] (int value) {
|
|
||||||
float opacity = value / 100.0;
|
|
||||||
terminal.set_opacity(opacity);
|
|
||||||
};
|
|
||||||
|
|
||||||
slider->set_range(0, 100);
|
|
||||||
slider->set_value(100);
|
|
||||||
|
|
||||||
auto* beep_choice_window = new GWindow;
|
|
||||||
beep_choice_window->set_title("Terminal beep settings");
|
|
||||||
beep_choice_window->set_rect(50, 50, 200, 100);
|
|
||||||
|
|
||||||
auto* radio_buttons = new GWidget;
|
|
||||||
beep_choice_window->set_main_widget(radio_buttons);
|
|
||||||
radio_buttons->set_fill_with_background_color(true);
|
|
||||||
radio_buttons->set_layout(make<GBoxLayout>(Orientation::Vertical));
|
|
||||||
radio_buttons->layout()->set_margins({ 4, 4, 4, 4 });
|
|
||||||
|
|
||||||
auto* sysbell_radio = new GRadioButton("Use (Audible) System Bell", radio_buttons);
|
|
||||||
auto* visbell_radio = new GRadioButton("Use (Visual) Terminal Bell", radio_buttons);
|
|
||||||
sysbell_radio->set_checked(terminal.should_beep());
|
|
||||||
sysbell_radio->on_checked = [&terminal] (const bool res) {
|
|
||||||
terminal.set_should_beep(res);
|
|
||||||
};
|
|
||||||
|
|
||||||
auto new_opacity = config->read_num_entry("Window", "Opacity", 255);
|
auto new_opacity = config->read_num_entry("Window", "Opacity", 255);
|
||||||
terminal.set_opacity((float)new_opacity / 255.0);
|
terminal.set_opacity((float)new_opacity / 255.0);
|
||||||
|
@ -148,12 +166,20 @@ int main(int argc, char** argv)
|
||||||
auto menubar = make<GMenuBar>();
|
auto menubar = make<GMenuBar>();
|
||||||
|
|
||||||
auto app_menu = make<GMenu>("Terminal");
|
auto app_menu = make<GMenu>("Terminal");
|
||||||
app_menu->add_action(GAction::create("Adjust opacity...", [opacity_adjustment_window] (const GAction&) {
|
app_menu->add_action(GAction::create("Adjust opacity...",
|
||||||
opacity_adjustment_window->show();
|
[&opacity_adjustment_window, &terminal, &config] (const GAction&) {
|
||||||
}));
|
if (!opacity_adjustment_window)
|
||||||
app_menu->add_action(GAction::create("Change audio output...", [beep_choice_window] (const GAction&) {
|
opacity_adjustment_window =
|
||||||
beep_choice_window->show();
|
create_opacity_settings_window(terminal, config)->make_weak_ptr();
|
||||||
}));
|
opacity_adjustment_window->show();
|
||||||
|
}));
|
||||||
|
app_menu->add_action(GAction::create("Change audio output...",
|
||||||
|
[&beep_choice_window, &terminal, &config] (const GAction&) {
|
||||||
|
if (!beep_choice_window)
|
||||||
|
beep_choice_window =
|
||||||
|
create_beep_choice_window(terminal, config)->make_weak_ptr();
|
||||||
|
beep_choice_window->show();
|
||||||
|
}));
|
||||||
app_menu->add_action(GAction::create("Quit", { Mod_Alt, Key_F4 }, [] (const GAction&) {
|
app_menu->add_action(GAction::create("Quit", { Mod_Alt, Key_F4 }, [] (const GAction&) {
|
||||||
dbgprintf("Terminal: Quit menu activated!\n");
|
dbgprintf("Terminal: Quit menu activated!\n");
|
||||||
GApplication::the().quit(0);
|
GApplication::the().quit(0);
|
||||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue