chore: remove lib/gui/config/AppConfig class
This commit is contained in:
parent
9e74100960
commit
55f513941b
5 changed files with 0 additions and 148 deletions
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
#include "ScreenSetupModel.h"
|
#include "ScreenSetupModel.h"
|
||||||
#include "ServerConfig.h"
|
#include "ServerConfig.h"
|
||||||
#include "gui/config/AppConfig.h"
|
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
#include "common/constants.h"
|
#include "common/constants.h"
|
||||||
#include "gui/Logger.h"
|
#include "gui/Logger.h"
|
||||||
#include "gui/config/AppConfig.h"
|
|
||||||
#include "gui/config/ConfigScopes.h"
|
#include "gui/config/ConfigScopes.h"
|
||||||
#include "gui/constants.h"
|
#include "gui/constants.h"
|
||||||
#include "gui/diagnostic.h"
|
#include "gui/diagnostic.h"
|
||||||
|
|
|
||||||
|
|
@ -31,8 +31,6 @@ add_library(${target} STATIC
|
||||||
string_utils.h
|
string_utils.h
|
||||||
style_utils.h
|
style_utils.h
|
||||||
styles.h
|
styles.h
|
||||||
config/AppConfig.cpp
|
|
||||||
config/AppConfig.h
|
|
||||||
config/ConfigScopes.cpp
|
config/ConfigScopes.cpp
|
||||||
config/ConfigScopes.h
|
config/ConfigScopes.h
|
||||||
config/IConfigScopes.h
|
config/IConfigScopes.h
|
||||||
|
|
|
||||||
|
|
@ -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 <vl@fidra.de>
|
|
||||||
* 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> 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
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
@ -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 <vl@fidra.de>
|
|
||||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "IConfigScopes.h"
|
|
||||||
#include "common/constants.h"
|
|
||||||
#include <QObject>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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> deps = std::make_shared<Deps>());
|
|
||||||
|
|
||||||
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<Deps> m_pDeps;
|
|
||||||
};
|
|
||||||
Loading…
Reference in a new issue