From e5b745d696c3ea14bfa9f51f75825befaa94a924 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Thu, 26 Dec 2024 15:22:57 +0100 Subject: Mention that recording has to be restarted to apply changes. Fix stuck in repeat state if pressed while gsr-global-hotkey starts --- src/Config.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'src/Config.cpp') diff --git a/src/Config.cpp b/src/Config.cpp index 4deaaf4..a9c8843 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #define FORMAT_I32 "%" PRIi32 #define FORMAT_I64 "%" PRIi64 @@ -13,6 +14,14 @@ #define CONFIG_FILE_VERSION 1 namespace gsr { + bool ConfigHotkey::operator==(const ConfigHotkey &other) const { + return keysym == other.keysym && modifiers == other.modifiers; + } + + bool ConfigHotkey::operator!=(const ConfigHotkey &other) const { + return !operator==(other); + } + Config::Config(const SupportedCaptureOptions &capture_options) { const std::string default_save_directory = get_videos_dir(); @@ -141,6 +150,38 @@ namespace gsr { }; } + bool Config::operator==(const Config &other) { + const auto config_options = get_config_options(*this); + const auto config_options_other = get_config_options(const_cast(other)); + for(auto it : config_options) { + auto it_other = config_options_other.find(it.first); + if(it_other == config_options_other.end() || it_other->second.index() != it.second.index()) + return false; + + if(std::holds_alternative(it.second)) { + if(*std::get(it.second) != *std::get(it_other->second)) + return false; + } else if(std::holds_alternative(it.second)) { + if(*std::get(it.second) != *std::get(it_other->second)) + return false; + } else if(std::holds_alternative(it.second)) { + if(*std::get(it.second) != *std::get(it_other->second)) + return false; + } else if(std::holds_alternative(it.second)) { + if(*std::get(it.second) != *std::get(it_other->second)) + return false; + } else if(std::holds_alternative*>(it.second)) { + if(*std::get*>(it.second) != *std::get*>(it_other->second)) + return false; + } + } + return true; + } + + bool Config::operator!=(const Config &other) { + return !operator==(other); + } + std::optional read_config(const SupportedCaptureOptions &capture_options) { std::optional config; -- cgit v1.2.3