mirror of
https://repo.dec05eba.com/gpu-screen-recorder-ui
synced 2026-05-07 15:19:56 +09:00
Add settings page functionality to reopen after language change
This commit is contained in:
@@ -124,6 +124,7 @@ namespace gsr {
|
|||||||
void recreate_global_hotkeys(std::string_view hotkey_option);
|
void recreate_global_hotkeys(std::string_view hotkey_option);
|
||||||
void update_led_indicator_after_settings_change();
|
void update_led_indicator_after_settings_change();
|
||||||
void recreate_frontpage_ui_components();
|
void recreate_frontpage_ui_components();
|
||||||
|
void open_settings_page();
|
||||||
void xi_setup();
|
void xi_setup();
|
||||||
void handle_xi_events();
|
void handle_xi_events();
|
||||||
void process_key_bindings(mgl::Event &event);
|
void process_key_bindings(mgl::Event &event);
|
||||||
@@ -299,6 +300,7 @@ namespace gsr {
|
|||||||
|
|
||||||
bool hide_ui = false;
|
bool hide_ui = false;
|
||||||
bool reload_ui = false;
|
bool reload_ui = false;
|
||||||
|
bool reopen_settings_after_reload = false;
|
||||||
double notification_duration_multiplier = 1.0;
|
double notification_duration_multiplier = 1.0;
|
||||||
ClipboardFile clipboard_file;
|
ClipboardFile clipboard_file;
|
||||||
|
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ namespace gsr {
|
|||||||
std::function<void(std::string_view hotkey_option)> on_keyboard_hotkey_changed;
|
std::function<void(std::string_view hotkey_option)> on_keyboard_hotkey_changed;
|
||||||
std::function<void(std::string_view hotkey_option)> on_joystick_hotkey_changed;
|
std::function<void(std::string_view hotkey_option)> on_joystick_hotkey_changed;
|
||||||
std::function<void()> on_page_closed;
|
std::function<void()> on_page_closed;
|
||||||
|
std::function<void()> on_language_changed;
|
||||||
private:
|
private:
|
||||||
void load_hotkeys();
|
void load_hotkeys();
|
||||||
|
|
||||||
|
|||||||
137
src/Overlay.cpp
137
src/Overlay.cpp
@@ -934,9 +934,14 @@ namespace gsr {
|
|||||||
remove_widgets_to_be_removed();
|
remove_widgets_to_be_removed();
|
||||||
|
|
||||||
if(reload_ui) {
|
if(reload_ui) {
|
||||||
|
const bool reopen_settings = reopen_settings_after_reload;
|
||||||
reload_ui = false;
|
reload_ui = false;
|
||||||
if(visible)
|
reopen_settings_after_reload = false;
|
||||||
|
if(visible) {
|
||||||
recreate_frontpage_ui_components();
|
recreate_frontpage_ui_components();
|
||||||
|
if(reopen_settings)
|
||||||
|
open_settings_page();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
update_notification_process_status();
|
update_notification_process_status();
|
||||||
@@ -1439,68 +1444,8 @@ namespace gsr {
|
|||||||
button->set_position((main_buttons_list_ptr->get_position() + main_buttons_size - mgl::vec2f(0.0f, settings_button_size) + mgl::vec2f(settings_button_size * 0.333f, 0.0f)).floor());
|
button->set_position((main_buttons_list_ptr->get_position() + main_buttons_size - mgl::vec2f(0.0f, settings_button_size) + mgl::vec2f(settings_button_size * 0.333f, 0.0f)).floor());
|
||||||
button->set_bg_hover_color(mgl::Color(0, 0, 0, 255));
|
button->set_bg_hover_color(mgl::Color(0, 0, 0, 255));
|
||||||
button->set_icon(&get_theme().settings_small_texture);
|
button->set_icon(&get_theme().settings_small_texture);
|
||||||
button->on_click = [&]() {
|
button->on_click = [this]() {
|
||||||
std::string language_before = config.main_config.language;
|
open_settings_page();
|
||||||
auto settings_page = std::make_unique<GlobalSettingsPage>(this, &gsr_info, config, &page_stack);
|
|
||||||
|
|
||||||
settings_page->on_startup_changed = [&](bool enable, int exit_status) {
|
|
||||||
if(exit_status == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if(exit_status == 67) {
|
|
||||||
const bool is_flatpak = getenv("FLATPAK_ID") != nullptr;
|
|
||||||
const char *startup_command = is_flatpak ? "flatpak run com.dec05eba.gpu_screen_recorder gsr-ui" : "gsr-ui launch-daemon";
|
|
||||||
show_notification(
|
|
||||||
TRF("To enable autorun: install and configure 'dex' (recommended), or manually add '%s' to your desktop autostart entries.", startup_command).c_str(),
|
|
||||||
10.0,
|
|
||||||
mgl::Color(255, 255, 255),
|
|
||||||
mgl::Color(255, 0, 0),
|
|
||||||
NotificationType::NOTICE,
|
|
||||||
nullptr,
|
|
||||||
NotificationLevel::ERROR
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(enable)
|
|
||||||
show_notification(TR("Failed to add GPU Screen Recorder to system startup"), notification_timeout_seconds, mgl::Color(255, 255, 255), mgl::Color(255, 0, 0), NotificationType::NOTICE, nullptr, NotificationLevel::ERROR);
|
|
||||||
else
|
|
||||||
show_notification(TR("Failed to remove GPU Screen Recorder from system startup"), notification_timeout_seconds, mgl::Color(255, 255, 255), mgl::Color(255, 0, 0), NotificationType::NOTICE, nullptr, NotificationLevel::ERROR);
|
|
||||||
};
|
|
||||||
|
|
||||||
settings_page->on_click_exit_program_button = [this](std::string_view reason) {
|
|
||||||
do_exit = true;
|
|
||||||
exit_reason = reason;
|
|
||||||
};
|
|
||||||
|
|
||||||
settings_page->on_keyboard_hotkey_changed = [this](std::string_view hotkey_option) {
|
|
||||||
recreate_global_hotkeys(hotkey_option);
|
|
||||||
};
|
|
||||||
|
|
||||||
settings_page->on_joystick_hotkey_changed = [this](std::string_view hotkey_option) {
|
|
||||||
global_hotkeys_js.reset();
|
|
||||||
if(hotkey_option == "enable_hotkeys")
|
|
||||||
global_hotkeys_js = register_joystick_hotkeys(this);
|
|
||||||
else if(hotkey_option == "disable_hotkeys")
|
|
||||||
global_hotkeys_js.reset();
|
|
||||||
};
|
|
||||||
|
|
||||||
settings_page->on_page_closed = [this, language_before]() {
|
|
||||||
replay_dropdown_button_ptr->set_item_description("start", config.replay_config.start_stop_hotkey.to_string(false, false));
|
|
||||||
replay_dropdown_button_ptr->set_item_description("save", config.replay_config.save_hotkey.to_string(false, false));
|
|
||||||
replay_dropdown_button_ptr->set_item_description("save_1_min", config.replay_config.save_1_min_hotkey.to_string(false, false));
|
|
||||||
replay_dropdown_button_ptr->set_item_description("save_10_min", config.replay_config.save_10_min_hotkey.to_string(false, false));
|
|
||||||
|
|
||||||
record_dropdown_button_ptr->set_item_description("start", config.record_config.start_stop_hotkey.to_string(false, false));
|
|
||||||
record_dropdown_button_ptr->set_item_description("pause", config.record_config.pause_unpause_hotkey.to_string(false, false));
|
|
||||||
|
|
||||||
stream_dropdown_button_ptr->set_item_description("start", config.streaming_config.start_stop_hotkey.to_string(false, false));
|
|
||||||
|
|
||||||
if(config.main_config.language != language_before)
|
|
||||||
reload_ui = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
page_stack.push(std::move(settings_page));
|
|
||||||
};
|
};
|
||||||
front_page_ptr->add_widget(std::move(button));
|
front_page_ptr->add_widget(std::move(button));
|
||||||
}
|
}
|
||||||
@@ -1573,12 +1518,78 @@ namespace gsr {
|
|||||||
update_ui_recording_started();
|
update_ui_recording_started();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Overlay::open_settings_page() {
|
||||||
|
auto settings_page = std::make_unique<GlobalSettingsPage>(this, &gsr_info, config, &page_stack);
|
||||||
|
|
||||||
|
settings_page->on_startup_changed = [this](bool enable, int exit_status) {
|
||||||
|
if(exit_status == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(exit_status == 67) {
|
||||||
|
const bool is_flatpak = getenv("FLATPAK_ID") != nullptr;
|
||||||
|
const char *startup_command = is_flatpak ? "flatpak run com.dec05eba.gpu_screen_recorder gsr-ui" : "gsr-ui launch-daemon";
|
||||||
|
show_notification(
|
||||||
|
TRF("To enable autorun: install and configure 'dex' (recommended), or manually add '%s' to your desktop autostart entries.", startup_command).c_str(),
|
||||||
|
10.0,
|
||||||
|
mgl::Color(255, 255, 255),
|
||||||
|
mgl::Color(255, 0, 0),
|
||||||
|
NotificationType::NOTICE,
|
||||||
|
nullptr,
|
||||||
|
NotificationLevel::ERROR
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(enable)
|
||||||
|
show_notification(TR("Failed to add GPU Screen Recorder to system startup"), notification_timeout_seconds, mgl::Color(255, 255, 255), mgl::Color(255, 0, 0), NotificationType::NOTICE, nullptr, NotificationLevel::ERROR);
|
||||||
|
else
|
||||||
|
show_notification(TR("Failed to remove GPU Screen Recorder from system startup"), notification_timeout_seconds, mgl::Color(255, 255, 255), mgl::Color(255, 0, 0), NotificationType::NOTICE, nullptr, NotificationLevel::ERROR);
|
||||||
|
};
|
||||||
|
|
||||||
|
settings_page->on_click_exit_program_button = [this](std::string_view reason) {
|
||||||
|
do_exit = true;
|
||||||
|
exit_reason = reason;
|
||||||
|
};
|
||||||
|
|
||||||
|
settings_page->on_keyboard_hotkey_changed = [this](std::string_view hotkey_option) {
|
||||||
|
recreate_global_hotkeys(hotkey_option);
|
||||||
|
};
|
||||||
|
|
||||||
|
settings_page->on_joystick_hotkey_changed = [this](std::string_view hotkey_option) {
|
||||||
|
global_hotkeys_js.reset();
|
||||||
|
if(hotkey_option == "enable_hotkeys")
|
||||||
|
global_hotkeys_js = register_joystick_hotkeys(this);
|
||||||
|
else if(hotkey_option == "disable_hotkeys")
|
||||||
|
global_hotkeys_js.reset();
|
||||||
|
};
|
||||||
|
|
||||||
|
settings_page->on_page_closed = [this]() {
|
||||||
|
replay_dropdown_button_ptr->set_item_description("start", config.replay_config.start_stop_hotkey.to_string(false, false));
|
||||||
|
replay_dropdown_button_ptr->set_item_description("save", config.replay_config.save_hotkey.to_string(false, false));
|
||||||
|
replay_dropdown_button_ptr->set_item_description("save_1_min", config.replay_config.save_1_min_hotkey.to_string(false, false));
|
||||||
|
replay_dropdown_button_ptr->set_item_description("save_10_min", config.replay_config.save_10_min_hotkey.to_string(false, false));
|
||||||
|
|
||||||
|
record_dropdown_button_ptr->set_item_description("start", config.record_config.start_stop_hotkey.to_string(false, false));
|
||||||
|
record_dropdown_button_ptr->set_item_description("pause", config.record_config.pause_unpause_hotkey.to_string(false, false));
|
||||||
|
|
||||||
|
stream_dropdown_button_ptr->set_item_description("start", config.streaming_config.start_stop_hotkey.to_string(false, false));
|
||||||
|
};
|
||||||
|
|
||||||
|
settings_page->on_language_changed = [this]() {
|
||||||
|
reload_ui = true;
|
||||||
|
reopen_settings_after_reload = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
page_stack.push(std::move(settings_page));
|
||||||
|
}
|
||||||
|
|
||||||
void Overlay::hide() {
|
void Overlay::hide() {
|
||||||
if(!visible)
|
if(!visible)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
hide_ui = false;
|
hide_ui = false;
|
||||||
reload_ui = false;
|
reload_ui = false;
|
||||||
|
reopen_settings_after_reload = false;
|
||||||
|
|
||||||
mgl_context *context = mgl_get_context();
|
mgl_context *context = mgl_get_context();
|
||||||
Display *display = (Display*)context->connection;
|
Display *display = (Display*)context->connection;
|
||||||
|
|||||||
@@ -534,8 +534,11 @@ namespace gsr {
|
|||||||
combo_box->add_item("日本語", "ja");
|
combo_box->add_item("日本語", "ja");
|
||||||
combo_box->add_item("Русский", "ru");
|
combo_box->add_item("Русский", "ru");
|
||||||
combo_box->add_item("Українська", "uk");
|
combo_box->add_item("Українська", "uk");
|
||||||
combo_box->on_selection_changed = [](std::string_view, std::string_view id) {
|
combo_box->on_selection_changed = [this](std::string_view, std::string_view id) {
|
||||||
Translation::instance().load_language(id);
|
Translation::instance().load_language(id);
|
||||||
|
config.main_config.language = std::string(id);
|
||||||
|
if(on_language_changed)
|
||||||
|
on_language_changed();
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
list->add_widget(std::move(combo_box));
|
list->add_widget(std::move(combo_box));
|
||||||
|
|||||||
Reference in New Issue
Block a user