aboutsummaryrefslogtreecommitdiff
path: root/src/gui/GlobalSettingsPage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/GlobalSettingsPage.cpp')
-rw-r--r--src/gui/GlobalSettingsPage.cpp41
1 files changed, 36 insertions, 5 deletions
diff --git a/src/gui/GlobalSettingsPage.cpp b/src/gui/GlobalSettingsPage.cpp
index ca4c4ea..d3d440d 100644
--- a/src/gui/GlobalSettingsPage.cpp
+++ b/src/gui/GlobalSettingsPage.cpp
@@ -55,6 +55,7 @@ namespace gsr {
get_color_theme().tint_color = mgl::Color(118, 185, 0);
else if(id == "intel")
get_color_theme().tint_color = mgl::Color(8, 109, 183);
+ return true;
};
list->add_widget(std::move(tint_color_radio_button));
return std::make_unique<Subsection>("Appearance", std::move(list), mgl::vec2f(parent_page->get_inner_size().x, 0.0f));
@@ -62,10 +63,11 @@ namespace gsr {
std::unique_ptr<Subsection> GlobalSettingsPage::create_startup_subsection(ScrollablePage *parent_page) {
auto list = std::make_unique<List>(List::Orientation::VERTICAL);
- auto startup_radio_button = std::make_unique<RadioButton>(&get_theme().body_font, RadioButton::Orientation::VERTICAL);
+ list->add_widget(std::make_unique<Label>(&get_theme().body_font, "Start program on system startup?", get_color_theme().text_color));
+ auto startup_radio_button = std::make_unique<RadioButton>(&get_theme().body_font, RadioButton::Orientation::HORIZONTAL);
startup_radio_button_ptr = startup_radio_button.get();
- startup_radio_button->add_item("Don't start this program on system startup", "dont_start_on_system_startup");
- startup_radio_button->add_item("Start this program on system startup", "start_on_system_startup");
+ startup_radio_button->add_item("Yes", "start_on_system_startup");
+ startup_radio_button->add_item("No", "dont_start_on_system_startup");
startup_radio_button->on_selection_changed = [&](const std::string&, const std::string &id) {
bool enable = false;
if(id == "dont_start_on_system_startup")
@@ -73,18 +75,44 @@ namespace gsr {
else if(id == "start_on_system_startup")
enable = true;
else
- return;
+ return false;
const char *args[] = { "systemctl", enable ? "enable" : "disable", "--user", "gpu-screen-recorder-ui", nullptr };
std::string stdout_str;
const int exit_status = exec_program_on_host_get_stdout(args, stdout_str);
if(on_startup_changed)
on_startup_changed(enable, exit_status);
+ return exit_status == 0;
};
list->add_widget(std::move(startup_radio_button));
return std::make_unique<Subsection>("Startup", std::move(list), mgl::vec2f(parent_page->get_inner_size().x, 0.0f));
}
+ std::unique_ptr<Subsection> GlobalSettingsPage::create_hotkey_subsection(ScrollablePage *parent_page) {
+ const bool inside_flatpak = getenv("FLATPAK_ID") != NULL;
+
+ auto enable_hotkeys_radio_button = std::make_unique<RadioButton>(&get_theme().body_font, RadioButton::Orientation::VERTICAL);
+ enable_hotkeys_radio_button_ptr = enable_hotkeys_radio_button.get();
+ enable_hotkeys_radio_button->add_item("Enable hotkeys", "enable_hotkeys");
+ if(!inside_flatpak)
+ enable_hotkeys_radio_button->add_item("Disable hotkeys", "disable_hotkeys");
+ enable_hotkeys_radio_button->add_item("Only grab virtual devices (supports input remapping software)", "enable_hotkeys_virtual_devices");
+ 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");
+ else if(id == "enable_hotkeys_virtual_devices")
+ on_click_exit_program_button("restart");
+
+ return true;
+ };
+ return std::make_unique<Subsection>("Hotkeys", std::move(enable_hotkeys_radio_button), mgl::vec2f(parent_page->get_inner_size().x, 0.0f));
+ }
+
std::unique_ptr<Button> GlobalSettingsPage::create_exit_program_button() {
auto exit_program_button = std::make_unique<Button>(&get_theme().body_font, "Exit program", mgl::vec2f(0.0f, 0.0f), mgl::Color(0, 0, 0, 120));
exit_program_button->on_click = [&]() {
@@ -105,7 +133,6 @@ namespace gsr {
std::unique_ptr<Subsection> GlobalSettingsPage::create_application_options_subsection(ScrollablePage *parent_page) {
const bool inside_flatpak = getenv("FLATPAK_ID") != NULL;
-
auto list = std::make_unique<List>(List::Orientation::HORIZONTAL);
list->add_widget(create_exit_program_button());
if(inside_flatpak)
@@ -120,6 +147,7 @@ namespace gsr {
settings_list->set_spacing(0.018f);
settings_list->add_widget(create_appearance_subsection(scrollable_page.get()));
settings_list->add_widget(create_startup_subsection(scrollable_page.get()));
+ settings_list->add_widget(create_hotkey_subsection(scrollable_page.get()));
settings_list->add_widget(create_application_options_subsection(scrollable_page.get()));
scrollable_page->add_widget(std::move(settings_list));
@@ -140,10 +168,13 @@ namespace gsr {
std::string stdout_str;
const int exit_status = exec_program_on_host_get_stdout(args, stdout_str);
startup_radio_button_ptr->set_selected_item(exit_status == 0 ? "start_on_system_startup" : "dont_start_on_system_startup", false, false);
+
+ enable_hotkeys_radio_button_ptr->set_selected_item(config.main_config.hotkeys_enable_option, false, false);
}
void GlobalSettingsPage::save() {
config.main_config.tint_color = tint_color_radio_button_ptr->get_selected_id();
+ config.main_config.hotkeys_enable_option = enable_hotkeys_radio_button_ptr->get_selected_id();
save_config(config);
}
} \ No newline at end of file