diff options
author | Andreas Kling <kling@serenityos.org> | 2020-12-30 13:42:16 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-12-30 13:42:16 +0100 |
commit | 2c9147154c2e3ec0e6030bd06237674e89ef9f10 (patch) | |
tree | fdfb405e29fa4e7f348714d6826c3c1d6a1dc360 /Applications | |
parent | 04e3bcfa75deaa0dc6e55241b8d8142440af5e10 (diff) | |
download | serenity-2c9147154c2e3ec0e6030bd06237674e89ef9f10.zip |
Terminal+LibVT: Add settings window to the terminal context menu
Diffstat (limited to 'Applications')
-rw-r--r-- | Applications/Terminal/main.cpp | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/Applications/Terminal/main.cpp b/Applications/Terminal/main.cpp index 5ff441da7c..7fef9821ec 100644 --- a/Applications/Terminal/main.cpp +++ b/Applications/Terminal/main.cpp @@ -178,7 +178,7 @@ static pid_t run_command(int ptm_fd, String command) static RefPtr<GUI::Window> create_settings_window(TerminalWidget& terminal) { auto window = GUI::Window::construct(); - window->set_title("Terminal Settings"); + window->set_title("Terminal settings"); window->set_resizable(false); window->resize(200, 210); window->set_modal(true); @@ -413,6 +413,25 @@ int main(int argc, char** argv) auto new_scrollback_size = config->read_num_entry("Terminal", "MaxHistorySize", terminal.max_history_size()); terminal.set_max_history_size(new_scrollback_size); + auto open_settings_action = GUI::Action::create("Settings...", Gfx::Bitmap::load_from_file("/res/icons/16x16/gear.png"), + [&](const GUI::Action&) { + if (!settings_window) { + settings_window = create_settings_window(terminal); + settings_window->on_close_request = [&] { + settings_window = nullptr; + return GUI::Window::CloseRequestDecision::Close; + }; + } + if (!settings_window->is_visible()) { + settings_window->center_within(*window); + settings_window->show(); + } + settings_window->move_to_front(); + }); + + terminal.context_menu().add_separator(); + terminal.context_menu().add_action(open_settings_action); + auto menubar = GUI::MenuBar::construct(); auto& app_menu = menubar->add_menu("Terminal"); @@ -426,18 +445,8 @@ int main(int argc, char** argv) perror("disown"); } })); - app_menu.add_action(GUI::Action::create("Settings...", Gfx::Bitmap::load_from_file("/res/icons/16x16/gear.png"), - [&](const GUI::Action&) { - if (!settings_window) { - settings_window = create_settings_window(terminal); - settings_window->on_close_request = [&] { - settings_window = nullptr; - return GUI::Window::CloseRequestDecision::Close; - }; - } - settings_window->show(); - settings_window->move_to_front(); - })); + + app_menu.add_action(open_settings_action); app_menu.add_separator(); app_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) { dbgln("Terminal: Quit menu activated!"); |