Add led indicator setting, use one setting for notifications, move it under general

This commit is contained in:
dec05eba
2025-11-07 22:05:14 +01:00
parent be07070789
commit 70df557c2b
13 changed files with 291 additions and 168 deletions

View File

@@ -60,6 +60,9 @@ namespace gsr {
bool overclock = false;
bool record_cursor = true;
bool restore_portal_session = true;
bool show_notifications = true;
bool use_led_indicator = false;
};
struct MainConfig {
@@ -93,8 +96,6 @@ namespace gsr {
struct StreamingConfig {
RecordOptions record_options;
bool show_streaming_started_notifications = true;
bool show_streaming_stopped_notifications = true;
std::string streaming_service = "twitch";
YoutubeStreamConfig youtube;
TwitchStreamConfig twitch;
@@ -106,9 +107,6 @@ namespace gsr {
struct RecordConfig {
RecordOptions record_options;
bool save_video_in_game_folder = false;
bool show_recording_started_notifications = true;
bool show_video_saved_notifications = true;
bool show_video_paused_notifications = true;
std::string save_directory;
std::string container = "mp4";
ConfigHotkey start_stop_hotkey;
@@ -120,9 +118,6 @@ namespace gsr {
std::string turn_on_replay_automatically_mode = "dont_turn_on_automatically";
bool save_video_in_game_folder = false;
bool restart_replay_on_save = false;
bool show_replay_started_notifications = true;
bool show_replay_stopped_notifications = true;
bool show_replay_saved_notifications = true;
std::string save_directory;
std::string container = "mp4";
int32_t replay_time = 60;
@@ -145,7 +140,8 @@ namespace gsr {
bool save_screenshot_in_game_folder = false;
bool save_screenshot_to_clipboard = false;
bool show_screenshot_saved_notifications = true;
bool show_notifications = true;
bool use_led_indicator = false;
std::string save_directory;
ConfigHotkey take_screenshot_hotkey;
ConfigHotkey take_screenshot_region_hotkey;

27
include/LedIndicator.hpp Normal file
View File

@@ -0,0 +1,27 @@
#pragma once
#include <X11/Xlib.h>
#include <mglpp/system/Clock.hpp>
namespace gsr {
class LedIndicator {
public:
LedIndicator(Display *dpy);
LedIndicator(const LedIndicator&) = delete;
LedIndicator& operator=(const LedIndicator&) = delete;
~LedIndicator();
void set_led(bool enabled);
void blink();
void update();
private:
void update_led(bool new_state);
private:
Display *dpy = nullptr;
Atom scroll_lock_atom = None;
bool led_indicator_on = false;
bool led_enabled = false;
bool perform_blink = false;
mgl::Clock blink_timer;
};
}

View File

@@ -11,6 +11,7 @@
#include "RegionSelector.hpp"
#include "WindowSelector.hpp"
#include "ClipboardFile.hpp"
#include "LedIndicator.hpp"
#include "CursorTracker/CursorTracker.hpp"
#include <mglpp/window/Window.hpp>
@@ -235,7 +236,7 @@ namespace gsr {
std::unique_ptr<GlobalHotkeys> global_hotkeys = nullptr;
std::unique_ptr<GlobalHotkeysJoystick> global_hotkeys_js = nullptr;
Display *x11_mapping_display = nullptr;
Display *x11_dpy = nullptr;
XEvent x11_mapping_xev;
mgl::Clock replay_save_clock;
@@ -269,5 +270,7 @@ namespace gsr {
bool hide_ui = false;
double notification_duration_multiplier = 1.0;
ClipboardFile clipboard_file;
std::unique_ptr<LedIndicator> led_indicator = nullptr;
};
}

View File

@@ -43,8 +43,9 @@ namespace gsr {
std::unique_ptr<Widget> create_file_info_section();
std::unique_ptr<CheckBox> create_save_screenshot_in_game_folder();
std::unique_ptr<CheckBox> create_save_screenshot_to_clipboard();
std::unique_ptr<Widget> create_notifications();
std::unique_ptr<Widget> create_led_indicator();
std::unique_ptr<Widget> create_general_section();
std::unique_ptr<Widget> create_notifications_section();
std::unique_ptr<Widget> create_settings();
void add_widgets();
@@ -71,7 +72,8 @@ namespace gsr {
Button *save_directory_button_ptr = nullptr;
CheckBox *save_screenshot_in_game_folder_checkbox_ptr = nullptr;
CheckBox *save_screenshot_to_clipboard_checkbox_ptr = nullptr;
CheckBox *show_screenshot_saved_notification_checkbox_ptr = nullptr;
CheckBox *show_notification_checkbox_ptr = nullptr;
CheckBox *led_indicator_checkbox_ptr = nullptr;
PageStack *page_stack = nullptr;
};

View File

@@ -112,6 +112,8 @@ namespace gsr {
std::unique_ptr<CheckBox> create_save_recording_in_game_folder();
std::unique_ptr<Label> create_estimated_record_file_size();
void update_estimated_record_file_size();
std::unique_ptr<CheckBox> create_led_indicator(const char *type);
std::unique_ptr<CheckBox> create_notifications(const char *type);
void add_replay_widgets();
void add_record_widgets();
@@ -136,7 +138,7 @@ namespace gsr {
void save_record();
void save_stream();
void view_changed(bool advanced_view, Subsection *notifications_subsection_ptr);
void view_changed(bool advanced_view);
private:
Type type;
Config &config;
@@ -179,15 +181,7 @@ namespace gsr {
CheckBox *save_replay_in_game_folder_ptr = nullptr;
CheckBox *restart_replay_on_save = nullptr;
Label *estimated_file_size_ptr = nullptr;
CheckBox *show_replay_started_notification_checkbox_ptr = nullptr;
CheckBox *show_replay_stopped_notification_checkbox_ptr = nullptr;
CheckBox *show_replay_saved_notification_checkbox_ptr = nullptr;
CheckBox *save_recording_in_game_folder_ptr = nullptr;
CheckBox *show_recording_started_notification_checkbox_ptr = nullptr;
CheckBox *show_video_saved_notification_checkbox_ptr = nullptr;
CheckBox *show_video_paused_notification_checkbox_ptr = nullptr;
CheckBox *show_streaming_started_notification_checkbox_ptr = nullptr;
CheckBox *show_streaming_stopped_notification_checkbox_ptr = nullptr;
Button *save_directory_button_ptr = nullptr;
Entry *twitch_stream_key_entry_ptr = nullptr;
Entry *youtube_stream_key_entry_ptr = nullptr;
@@ -200,6 +194,8 @@ namespace gsr {
RadioButton *turn_on_replay_automatically_mode_ptr = nullptr;
Subsection *audio_section_ptr = nullptr;
List *audio_track_section_list_ptr = nullptr;
CheckBox *led_indicator_checkbox_ptr = nullptr;
CheckBox *show_notification_checkbox_ptr = nullptr;
PageStack *page_stack = nullptr;
};