From a119220961d3df6d8f5f96d3a646adedb5d99554 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 29 Dec 2024 20:37:11 +0100 Subject: Add buttons to exit program and to go back to old ui for flatpak --- src/Overlay.cpp | 20 +++++++++++++++++++- src/gui/GlobalSettingsPage.cpp | 29 +++++++++++++++++++++++++++++ src/main.cpp | 10 +++++++++- 3 files changed, 57 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Overlay.cpp b/src/Overlay.cpp index 11808c6..da22a76 100644 --- a/src/Overlay.cpp +++ b/src/Overlay.cpp @@ -836,7 +836,7 @@ namespace gsr { if(!init_theme(resources_path)) { fprintf(stderr, "Error: failed to load theme\n"); - exit(1); + ::exit(1); } mgl_window *win = window->internal_window(); @@ -903,6 +903,7 @@ namespace gsr { button->add_item("Settings", "settings"); button->set_item_icon("start", &get_theme().play_texture); button->set_item_icon("save", &get_theme().save_texture); + button->set_item_icon("settings", &get_theme().settings_small_texture); button->on_click = [this](const std::string &id) { if(id == "settings") { auto replay_settings_page = std::make_unique(SettingsPage::Type::REPLAY, &gsr_info, config, &page_stack); @@ -928,6 +929,7 @@ namespace gsr { button->add_item("Settings", "settings"); button->set_item_icon("start", &get_theme().play_texture); button->set_item_icon("pause", &get_theme().pause_texture); + button->set_item_icon("settings", &get_theme().settings_small_texture); button->on_click = [this](const std::string &id) { if(id == "settings") { auto record_settings_page = std::make_unique(SettingsPage::Type::RECORD, &gsr_info, config, &page_stack); @@ -951,6 +953,7 @@ namespace gsr { button->add_item("Start", "start", "Alt+F8"); button->add_item("Settings", "settings"); button->set_item_icon("start", &get_theme().play_texture); + button->set_item_icon("settings", &get_theme().settings_small_texture); button->on_click = [this](const std::string &id) { if(id == "settings") { auto stream_settings_page = std::make_unique(SettingsPage::Type::STREAM, &gsr_info, config, &page_stack); @@ -993,6 +996,10 @@ namespace gsr { show_notification("Failed to remove GPU Screen Recorder from system startup", 3.0, mgl::Color(255, 0, 0), mgl::Color(255, 0, 0), NotificationType::NONE); } }; + settings_page->on_click_exit_program_button = [&](const char *reason) { + do_exit = true; + exit_reason = reason; + }; page_stack.push(std::move(settings_page)); }; front_page_ptr->add_widget(std::move(button)); @@ -1223,6 +1230,17 @@ namespace gsr { return visible; } + bool Overlay::should_exit(std::string &reason) const { + reason.clear(); + if(do_exit) + reason = exit_reason; + return do_exit; + } + + void Overlay::exit() { + do_exit = true; + } + void Overlay::update_notification_process_status() { if(notification_process <= 0) return; diff --git a/src/gui/GlobalSettingsPage.cpp b/src/gui/GlobalSettingsPage.cpp index 7e79c16..ca4c4ea 100644 --- a/src/gui/GlobalSettingsPage.cpp +++ b/src/gui/GlobalSettingsPage.cpp @@ -85,6 +85,34 @@ namespace gsr { return std::make_unique("Startup", std::move(list), mgl::vec2f(parent_page->get_inner_size().x, 0.0f)); } + std::unique_ptr