From f3565fdd77fb480575feec5de252466b093daf86 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 8 Dec 2024 14:32:11 +0100 Subject: Query capture options when opening settings and validate capture options when starting recording --- src/gui/SettingsPage.cpp | 140 ++++++++++++++++++++++++----------------------- 1 file changed, 71 insertions(+), 69 deletions(-) (limited to 'src/gui') diff --git a/src/gui/SettingsPage.cpp b/src/gui/SettingsPage.cpp index 79f6c52..39ac4df 100644 --- a/src/gui/SettingsPage.cpp +++ b/src/gui/SettingsPage.cpp @@ -22,15 +22,17 @@ namespace gsr { APPLICATION_CUSTOM }; - SettingsPage::SettingsPage(Type type, const GsrInfo &gsr_info, Config &config, PageStack *page_stack) : + SettingsPage::SettingsPage(Type type, const GsrInfo *gsr_info, Config &config, PageStack *page_stack) : StaticPage(mgl::vec2f(get_theme().window_width, get_theme().window_height).floor()), type(type), config(config), + gsr_info(gsr_info), page_stack(page_stack), settings_title_text("Settings", get_theme().title_font) { audio_devices = get_audio_devices(); application_audio = get_application_audio(); + capture_options = get_supported_capture_options(*gsr_info); auto content_page = std::make_unique(); content_page->add_button("Back", "back", get_color_theme().page_bg_color); @@ -41,9 +43,9 @@ namespace gsr { content_page_ptr = content_page.get(); add_widget(std::move(content_page)); - add_widgets(gsr_info); - add_page_specific_widgets(gsr_info); - load(gsr_info); + add_widgets(); + add_page_specific_widgets(); + load(); } std::unique_ptr SettingsPage::create_view_radio_button() { @@ -55,31 +57,31 @@ namespace gsr { return view_radio_button; } - std::unique_ptr SettingsPage::create_record_area_box(const GsrInfo &gsr_info) { + std::unique_ptr SettingsPage::create_record_area_box() { auto record_area_box = std::make_unique(&get_theme().body_font); // TODO: Show options not supported but disable them // TODO: Enable this - //if(gsr_info.supported_capture_options.window) + //if(capture_options.window) // record_area_box->add_item("Window", "window"); - if(gsr_info.supported_capture_options.focused) + if(capture_options.focused) record_area_box->add_item("Follow focused window", "focused"); - if(gsr_info.supported_capture_options.screen) + if(capture_options.screen) record_area_box->add_item("All monitors", "screen"); - for(const auto &monitor : gsr_info.supported_capture_options.monitors) { + for(const auto &monitor : capture_options.monitors) { char name[256]; snprintf(name, sizeof(name), "Monitor %s (%dx%d)", monitor.name.c_str(), monitor.size.x, monitor.size.y); record_area_box->add_item(name, monitor.name); } - if(gsr_info.supported_capture_options.portal) + if(capture_options.portal) record_area_box->add_item("Desktop portal", "portal"); record_area_box_ptr = record_area_box.get(); return record_area_box; } - std::unique_ptr SettingsPage::create_record_area(const GsrInfo &gsr_info) { + std::unique_ptr SettingsPage::create_record_area() { auto record_area_list = std::make_unique(List::Orientation::VERTICAL); record_area_list->add_widget(std::make_unique