From 6c03137610ff70623a22e786a072e89bee4e33e8 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 3 Jan 2025 22:35:49 +0100 Subject: Add option to disable hotkeys, add gsr-ui-cli tool to control gsr-ui remotely --- src/Config.cpp | 1 + src/Overlay.cpp | 5 ++++ src/gui/GlobalSettingsPage.cpp | 26 +++++++++++++++- src/main.cpp | 68 +++++++++++++++++++++++++++++++++--------- 4 files changed, 85 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/Config.cpp b/src/Config.cpp index a9c8843..88ba11a 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -58,6 +58,7 @@ namespace gsr { return { {"main.config_file_version", &config.main_config.config_file_version}, {"main.software_encoding_warning_shown", &config.main_config.software_encoding_warning_shown}, + {"main.enable_hotkeys", &config.main_config.enable_hotkeys}, {"main.tint_color", &config.main_config.tint_color}, {"streaming.record_options.record_area_option", &config.streaming_config.record_options.record_area_option}, diff --git a/src/Overlay.cpp b/src/Overlay.cpp index b36dc37..d17c4cc 100644 --- a/src/Overlay.cpp +++ b/src/Overlay.cpp @@ -487,6 +487,7 @@ namespace gsr { } close_gpu_screen_recorder_output(); + deinit_color_theme(); } void Overlay::xi_setup() { @@ -1261,6 +1262,10 @@ namespace gsr { do_exit = true; } + const Config& Overlay::get_config() const { + return config; + } + void Overlay::update_notification_process_status() { if(notification_process <= 0) return; diff --git a/src/gui/GlobalSettingsPage.cpp b/src/gui/GlobalSettingsPage.cpp index 7c8b902..5153981 100644 --- a/src/gui/GlobalSettingsPage.cpp +++ b/src/gui/GlobalSettingsPage.cpp @@ -88,6 +88,27 @@ namespace gsr { return std::make_unique("Startup", std::move(list), mgl::vec2f(parent_page->get_inner_size().x, 0.0f)); } + std::unique_ptr GlobalSettingsPage::create_hotkey_subsection(ScrollablePage *parent_page) { + auto list = std::make_unique(List::Orientation::VERTICAL); + auto enable_hotkeys_radio_button = std::make_unique(&get_theme().body_font, RadioButton::Orientation::HORIZONTAL); + enable_hotkeys_radio_button_ptr = enable_hotkeys_radio_button.get(); + enable_hotkeys_radio_button->add_item("Enable hotkeys and restart", "enable_hotkeys"); + enable_hotkeys_radio_button->add_item("Disable hotkeys and restart", "disable_hotkeys"); + enable_hotkeys_radio_button->on_selection_changed = [&](const std::string&, const std::string &id) { + if(!on_click_exit_program_button) + return true; + + if(id == "enable_hotkeys") + on_click_exit_program_button("restart"); + else if(id == "disable_hotkeys") + on_click_exit_program_button("restart"); + + return true; + }; + list->add_widget(std::move(enable_hotkeys_radio_button)); + return std::make_unique("Hotkeys", std::move(list), mgl::vec2f(parent_page->get_inner_size().x, 0.0f)); + } + std::unique_ptr