From 9f1fddc47ce10fbc65cdeaa70461063b9921434e Mon Sep 17 00:00:00 2001 From: dec05eba Date: Tue, 6 Aug 2024 05:57:21 +0200 Subject: Copy Config from gpu-screen-recorder-gtk, make it more modern and efficient with string_view and variant, use string_view in gsr info parsing --- include/Config.hpp | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++ include/Utils.hpp | 32 ++++++++++++++++++++ include/gui/Button.hpp | 1 - include/gui/Utils.hpp | 3 ++ 4 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 include/Config.hpp create mode 100644 include/Utils.hpp (limited to 'include') diff --git a/include/Config.hpp b/include/Config.hpp new file mode 100644 index 0000000..d7f0923 --- /dev/null +++ b/include/Config.hpp @@ -0,0 +1,81 @@ + +#pragma once + +#include "Utils.hpp" +#include + +namespace gsr { + struct ConfigHotkey { + int64_t keysym = 0; + uint32_t modifiers = 0; + }; + + struct MainConfig { + std::string record_area_option; + int32_t record_area_width = 0; + int32_t record_area_height = 0; + int32_t fps = 60; + bool merge_audio_tracks = true; + std::vector audio_input; + std::string color_range; + std::string quality; + std::string video_codec; + std::string audio_codec; + std::string framerate_mode; + bool advanced_view = false; + bool overclock = false; + bool show_recording_started_notifications = false; + bool show_recording_stopped_notifications = false; + bool show_recording_saved_notifications = true; + bool record_cursor = true; + bool hide_window_when_recording = false; + bool software_encoding_warning_shown = false; + bool restore_portal_session = true; + }; + + struct YoutubeStreamConfig { + std::string stream_key; + }; + + struct TwitchStreamConfig { + std::string stream_key; + }; + + struct CustomStreamConfig { + std::string url; + std::string container; + }; + + struct StreamingConfig { + std::string streaming_service; + YoutubeStreamConfig youtube; + TwitchStreamConfig twitch; + CustomStreamConfig custom; + ConfigHotkey start_stop_recording_hotkey; + }; + + struct RecordConfig { + std::string save_directory; + std::string container; + ConfigHotkey start_stop_recording_hotkey; + ConfigHotkey pause_unpause_recording_hotkey; + }; + + struct ReplayConfig { + std::string save_directory; + std::string container; + int32_t replay_time = 30; + ConfigHotkey start_stop_recording_hotkey; + ConfigHotkey save_recording_hotkey; + }; + + struct Config { + MainConfig main_config; + StreamingConfig streaming_config; + RecordConfig record_config; + ReplayConfig replay_config; + }; + + Config read_config(bool &config_empty); + void save_config(Config &config); +} \ No newline at end of file diff --git a/include/Utils.hpp b/include/Utils.hpp new file mode 100644 index 0000000..f917834 --- /dev/null +++ b/include/Utils.hpp @@ -0,0 +1,32 @@ +#pragma once + +#include +#include +#include +#include +#include + +namespace gsr { + struct KeyValue { + std::string_view key; + std::string_view value; + }; + + using StringSplitCallback = std::function; + + void string_split_char(std::string_view str, char delimiter, StringSplitCallback callback_func); + + // key value separated by one space + std::optional parse_key_value(std::string_view line); + + std::string get_home_dir(); + std::string get_config_dir(); + + // Whoever designed xdg-user-dirs is retarded. Why are some XDG variables environment variables + // while others are in this pseudo shell config file ~/.config/user-dirs.dirs + std::map get_xdg_variables(); + + std::string get_videos_dir(); + int create_directory_recursive(char *path); + bool file_get_content(const char *filepath, std::string &file_content); +} \ No newline at end of file diff --git a/include/gui/Button.hpp b/include/gui/Button.hpp index 0a07423..4f8b404 100644 --- a/include/gui/Button.hpp +++ b/include/gui/Button.hpp @@ -24,7 +24,6 @@ namespace gsr { private: mgl::vec2f size; mgl::Color bg_color; - bool mouse_inside = false; mgl::Text text; }; } \ No newline at end of file diff --git a/include/gui/Utils.hpp b/include/gui/Utils.hpp index fe5ee49..885bf3e 100644 --- a/include/gui/Utils.hpp +++ b/include/gui/Utils.hpp @@ -3,6 +3,9 @@ #include #include +#include +#include + namespace mgl { class Window; } -- cgit v1.2.3