diff --git a/src/apps/deskflow-gui/dialogs/ServerConfigDialog.h b/src/apps/deskflow-gui/dialogs/ServerConfigDialog.h index 7a651999f..a4ef40318 100644 --- a/src/apps/deskflow-gui/dialogs/ServerConfigDialog.h +++ b/src/apps/deskflow-gui/dialogs/ServerConfigDialog.h @@ -10,7 +10,6 @@ #include "ScreenSetupModel.h" #include "ServerConfig.h" -#include "gui/config/AppConfig.h" #include diff --git a/src/apps/deskflow-gui/main.cpp b/src/apps/deskflow-gui/main.cpp index fbfcf4fdf..610159c6c 100644 --- a/src/apps/deskflow-gui/main.cpp +++ b/src/apps/deskflow-gui/main.cpp @@ -9,7 +9,6 @@ #include "MainWindow.h" #include "common/constants.h" #include "gui/Logger.h" -#include "gui/config/AppConfig.h" #include "gui/config/ConfigScopes.h" #include "gui/constants.h" #include "gui/diagnostic.h" diff --git a/src/lib/gui/CMakeLists.txt b/src/lib/gui/CMakeLists.txt index a489026b8..2e0aab341 100644 --- a/src/lib/gui/CMakeLists.txt +++ b/src/lib/gui/CMakeLists.txt @@ -31,8 +31,6 @@ add_library(${target} STATIC string_utils.h style_utils.h styles.h - config/AppConfig.cpp - config/AppConfig.h config/ConfigScopes.cpp config/ConfigScopes.h config/IConfigScopes.h diff --git a/src/lib/gui/config/AppConfig.cpp b/src/lib/gui/config/AppConfig.cpp deleted file mode 100644 index 6716e3221..000000000 --- a/src/lib/gui/config/AppConfig.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Deskflow -- mouse and keyboard sharing utility - * SPDX-FileCopyrightText: (C) 2025 Deskflow Developers - * SPDX-FileCopyrightText: (C) 2012 Symless Ltd. - * SPDX-FileCopyrightText: (C) 2008 Volker Lanz - * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception - */ - -#include "AppConfig.h" - -#include "common/Settings.h" - -#include "ConfigScopes.h" - -using namespace deskflow::gui; - -AppConfig::AppConfig(deskflow::gui::IConfigScopes &scopes, std::shared_ptr deps) : m_Scopes(scopes), m_pDeps(deps) -{ - setLoadFromSystemScope(Settings::isSystemScope()); -} - -void AppConfig::loadScope(ConfigScopes::Scope scope) -{ - using enum ConfigScopes::Scope; - - switch (scope) { - case User: - qDebug("loading user settings scope"); - break; - - case System: - qDebug("loading system settings scope"); - break; - - default: - qFatal("invalid scope"); - } - - if (m_Scopes.activeScope() == scope) { - qDebug("already in required scope, skipping"); - return; - } - - m_Scopes.setActiveScope(scope); - - qDebug("active scope file path: %s", qPrintable(m_Scopes.activeFilePath())); - - // only signal ready if there is at least one setting in the required scope. - // this prevents the current settings from being set back to default. - if (m_Scopes.scopeContains("core", m_Scopes.activeScope())) { - m_Scopes.signalReady(); - } else { - qDebug("no screen name in scope, skipping"); - } -} - -void AppConfig::setLoadFromSystemScope(bool value) -{ - using enum ConfigScopes::Scope; - if (value) { - loadScope(System); - } else { - loadScope(User); - } -} - -bool AppConfig::isActiveScopeWritable() const -{ - return m_Scopes.isActiveScopeWritable(); -} - -bool AppConfig::isActiveScopeSystem() const -{ - return m_Scopes.activeScope() == ConfigScopes::Scope::System; -} - -/////////////////////////////////////////////////////////////////////////////// -// Begin getters -/////////////////////////////////////////////////////////////////////////////// - -IConfigScopes &AppConfig::scopes() const -{ - return m_Scopes; -} - -/////////////////////////////////////////////////////////////////////////////// -// End getters -/////////////////////////////////////////////////////////////////////////////// diff --git a/src/lib/gui/config/AppConfig.h b/src/lib/gui/config/AppConfig.h deleted file mode 100644 index 31e47131e..000000000 --- a/src/lib/gui/config/AppConfig.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Deskflow -- mouse and keyboard sharing utility - * SPDX-FileCopyrightText: (C) 2025 Deskflow Developers - * SPDX-FileCopyrightText: (C) 2012 Symless Ltd. - * SPDX-FileCopyrightText: (C) 2008 Volker Lanz - * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception - */ - -#pragma once - -#include "IConfigScopes.h" -#include "common/constants.h" -#include - -/** - * @brief Simply reads and writes app settings. - * - * Important: Maintain a clear separation of concerns and keep it simple. - * It is tempting to add logic (e.g. license checks) to this class since it - * instance is widely accessible, but that has previously led to this class - * becoming a god object. - */ -class AppConfig : public QObject -{ - Q_OBJECT - using IConfigScopes = deskflow::gui::IConfigScopes; - -public: - struct Deps - { - virtual ~Deps() = default; - }; - - explicit AppConfig(IConfigScopes &scopes, std::shared_ptr deps = std::make_shared()); - - void determineScope(); - - IConfigScopes &scopes() const; - bool isActiveScopeWritable() const; - bool isActiveScopeSystem() const; - - /// @brief Sets the user preference to load from SystemScope. - /// @param [in] value - /// True - This will set the variable and load the global scope - /// settings. False - This will set the variable and load the user - /// scope settings. - void setLoadFromSystemScope(bool value); - -private: - /// @brief This method loads config from specified scope - /// @param [in] scope which should be loaded. - void loadScope(IConfigScopes::Scope scope); - - deskflow::gui::IConfigScopes &m_Scopes; - std::shared_ptr m_pDeps; -};