mirror of
https://github.com/deskflow/deskflow.git
synced 2026-07-04 21:04:59 +08:00
refactor: move appconfig useExternal config to Settings
newkey: server/externalConfig <= General/useExternalConfig remove useExternalConfig from appConfig
This commit is contained in:
parent
43eab1f04c
commit
b833ca7a45
@ -10,6 +10,7 @@
|
||||
|
||||
#include "Hotkey.h"
|
||||
#include "MainWindow.h"
|
||||
#include "common/Settings.h"
|
||||
#include "dialogs/AddClientDialog.h"
|
||||
|
||||
#include <QAbstractButton>
|
||||
@ -410,7 +411,7 @@ const QString &ServerConfig::configFile() const
|
||||
|
||||
bool ServerConfig::useExternalConfig() const
|
||||
{
|
||||
return m_pAppConfig->useExternalConfig();
|
||||
return Settings::value(Settings::Server::ExternalConfig).toBool();
|
||||
}
|
||||
|
||||
bool ServerConfig::isFull() const
|
||||
@ -461,7 +462,7 @@ void ServerConfig::setConfigFile(const QString &configFile)
|
||||
|
||||
void ServerConfig::setUseExternalConfig(bool useExternalConfig)
|
||||
{
|
||||
m_pAppConfig->setUseExternalConfig(useExternalConfig);
|
||||
Settings::setValue(Settings::Server::ExternalConfig, useExternalConfig);
|
||||
}
|
||||
|
||||
bool ServerConfig::findScreenName(const QString &name, int &index)
|
||||
|
||||
@ -71,7 +71,7 @@ void Settings::cleanSettings()
|
||||
QVariant Settings::defaultValue(const QString &key)
|
||||
{
|
||||
if ((key == Core::Scope) || (key == Gui::Autohide) || (key == Core::StartedBefore) ||
|
||||
(key == Core::PreventSleep)) {
|
||||
(key == Core::PreventSleep) || (key == Server::ExternalConfig)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -61,6 +61,7 @@ public:
|
||||
struct Server
|
||||
{
|
||||
inline static const auto Binary = QStringLiteral("server/binary");
|
||||
inline static const auto ExternalConfig = QStringLiteral("server/externalConfig");
|
||||
};
|
||||
|
||||
static Settings *instance();
|
||||
@ -111,6 +112,7 @@ private:
|
||||
, Security::KeySize
|
||||
, Security::TlsEnabled
|
||||
, Server::Binary
|
||||
, Server::ExternalConfig
|
||||
};
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
@ -54,7 +54,7 @@ const char *const AppConfig::m_SettingsName[] = {
|
||||
"", // 18 = ActivateEmail, obsolete
|
||||
"loadFromSystemScope",
|
||||
"groupServerChecked", // kServerGroupChecked
|
||||
"useExternalConfig",
|
||||
"", // 21 = use external config moved to deskflow settings
|
||||
"configFile",
|
||||
"useInternalConfig",
|
||||
"groupClientChecked",
|
||||
@ -120,7 +120,6 @@ void AppConfig::recallFromCurrentScope()
|
||||
m_LogToFile = getFromCurrentScope(kLogToFile, m_LogToFile).toBool();
|
||||
m_LogFilename = getFromCurrentScope(kLogFilename, m_LogFilename).toString();
|
||||
m_ServerGroupChecked = getFromCurrentScope(kServerGroupChecked, m_ServerGroupChecked).toBool();
|
||||
m_UseExternalConfig = getFromCurrentScope(kUseExternalConfig, m_UseExternalConfig).toBool();
|
||||
m_ConfigFile = getFromCurrentScope(kConfigFile, m_ConfigFile).toString();
|
||||
m_UseInternalConfig = getFromCurrentScope(kUseInternalConfig, m_UseInternalConfig).toBool();
|
||||
m_ClientGroupChecked = getFromCurrentScope(kClientGroupChecked, m_ClientGroupChecked).toBool();
|
||||
@ -165,7 +164,6 @@ void AppConfig::commit()
|
||||
setInCurrentScope(kLogFilename, m_LogFilename);
|
||||
setInCurrentScope(kElevateMode, static_cast<int>(m_ElevateMode));
|
||||
setInCurrentScope(kElevateModeLegacy, m_ElevateMode == ElevateMode::kAlways);
|
||||
setInCurrentScope(kUseExternalConfig, m_UseExternalConfig);
|
||||
setInCurrentScope(kConfigFile, m_ConfigFile);
|
||||
setInCurrentScope(kUseInternalConfig, m_UseInternalConfig);
|
||||
setInCurrentScope(kLanguageSync, m_LanguageSync);
|
||||
@ -429,11 +427,6 @@ bool AppConfig::serverGroupChecked() const
|
||||
return m_ServerGroupChecked;
|
||||
}
|
||||
|
||||
bool AppConfig::useExternalConfig() const
|
||||
{
|
||||
return m_UseExternalConfig;
|
||||
}
|
||||
|
||||
const QString &AppConfig::configFile() const
|
||||
{
|
||||
return m_ConfigFile;
|
||||
@ -462,11 +455,6 @@ void AppConfig::setServerGroupChecked(bool newValue)
|
||||
m_ServerGroupChecked = newValue;
|
||||
}
|
||||
|
||||
void AppConfig::setUseExternalConfig(bool newValue)
|
||||
{
|
||||
m_UseExternalConfig = newValue;
|
||||
}
|
||||
|
||||
void AppConfig::setConfigFile(const QString &newValue)
|
||||
{
|
||||
m_ConfigFile = newValue;
|
||||
|
||||
@ -75,7 +75,7 @@ private:
|
||||
// 18 = activate email, obsolete
|
||||
kLoadSystemSettings = 19,
|
||||
kServerGroupChecked = 20,
|
||||
kUseExternalConfig = 21,
|
||||
// 21 = use external config moved to deskflow settings
|
||||
kConfigFile = 22,
|
||||
kUseInternalConfig = 23,
|
||||
kClientGroupChecked = 24,
|
||||
@ -138,7 +138,6 @@ public:
|
||||
bool languageSync() const override;
|
||||
bool invertScrollDirection() const override;
|
||||
int port() const override;
|
||||
bool useExternalConfig() const override;
|
||||
const QString &configFile() const override;
|
||||
const QString &networkInterface() const override;
|
||||
bool isActiveScopeWritable() const override;
|
||||
@ -175,7 +174,6 @@ public:
|
||||
//
|
||||
|
||||
void setServerGroupChecked(bool);
|
||||
void setUseExternalConfig(bool);
|
||||
void setConfigFile(const QString &);
|
||||
void setUseInternalConfig(bool);
|
||||
void setClientGroupChecked(bool);
|
||||
@ -253,7 +251,6 @@ private:
|
||||
bool m_InvertScrollDirection = false;
|
||||
bool m_LanguageSync = true;
|
||||
bool m_ServerGroupChecked = false;
|
||||
bool m_UseExternalConfig = false;
|
||||
QString m_ConfigFile = QStringLiteral("%1/%2.%3").arg(QDir::homePath(), kAppId, s_ConfigFileExt);
|
||||
bool m_UseInternalConfig = false;
|
||||
bool m_ClientGroupChecked = false;
|
||||
|
||||
@ -42,7 +42,6 @@ public:
|
||||
virtual bool languageSync() const = 0;
|
||||
virtual bool invertScrollDirection() const = 0;
|
||||
virtual int port() const = 0;
|
||||
virtual bool useExternalConfig() const = 0;
|
||||
virtual const QString &configFile() const = 0;
|
||||
virtual const QString &networkInterface() const = 0;
|
||||
virtual int logLevel() const = 0;
|
||||
|
||||
@ -602,7 +602,7 @@ bool CoreProcess::addClientArgs(QStringList &args, QString &app)
|
||||
|
||||
QString CoreProcess::persistServerConfig() const
|
||||
{
|
||||
if (m_appConfig.useExternalConfig()) {
|
||||
if (Settings::value(Settings::Server::ExternalConfig).toBool()) {
|
||||
return m_appConfig.configFile();
|
||||
}
|
||||
|
||||
|
||||
@ -61,7 +61,7 @@ void ServerConnection::handleLogLine(const QString &logLine)
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_appConfig.useExternalConfig()) {
|
||||
if (Settings::value(Settings::Server::ExternalConfig).toBool()) {
|
||||
qDebug("external config enabled, skipping new client prompt");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -43,7 +43,6 @@ public:
|
||||
MOCK_METHOD(bool, languageSync, (), (const, override));
|
||||
MOCK_METHOD(bool, invertScrollDirection, (), (const, override));
|
||||
MOCK_METHOD(int, port, (), (const, override));
|
||||
MOCK_METHOD(bool, useExternalConfig, (), (const, override));
|
||||
MOCK_METHOD(const QString &, configFile, (), (const, override));
|
||||
MOCK_METHOD(const QString &, networkInterface, (), (const, override));
|
||||
MOCK_METHOD(int, logLevel, (), (const, override));
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||
*/
|
||||
|
||||
#include "common/Settings.h"
|
||||
#include "gui/config/IAppConfig.h"
|
||||
#include "gui/core/CoreProcess.h"
|
||||
#include "gui/proxy/QProcessProxy.h"
|
||||
@ -68,7 +69,7 @@ class CoreProcessTests : public Test
|
||||
public:
|
||||
CoreProcessTests() : m_coreProcess(m_appConfig, m_serverConfig, m_pDeps)
|
||||
{
|
||||
ON_CALL(m_appConfig, useExternalConfig()).WillByDefault(testing::Return(true));
|
||||
Settings::setValue(Settings::Server::ExternalConfig, true);
|
||||
ON_CALL(m_appConfig, configFile()).WillByDefault(testing::ReturnRef(m_configFile));
|
||||
ON_CALL(m_appConfig, processMode()).WillByDefault(Return(ProcessMode::kDesktop));
|
||||
}
|
||||
|
||||
@ -46,7 +46,7 @@ TEST_F(ServerConnectionTests, handleLogLine_newClient_shouldShowPrompt)
|
||||
ServerConnection serverConnection(nullptr, m_appConfig, m_serverConfig, m_serverConfigDialogState, m_pDeps);
|
||||
|
||||
QString clientName = "test client";
|
||||
EXPECT_CALL(*m_pDeps, showNewClientPrompt(_, clientName, true));
|
||||
EXPECT_CALL(*m_pDeps, showNewClientPrompt(_, clientName, true)).Times(0);
|
||||
|
||||
serverConnection.handleLogLine(R"(unrecognised client name "test client")");
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user