refactor: move port to Settigns
newkey: core/port <= General/port remove port from AppConfig
This commit is contained in:
parent
9aa1d6b79d
commit
5e6381c88a
8 changed files with 21 additions and 33 deletions
|
|
@ -143,7 +143,7 @@ void SettingsDialog::showReadOnlyMessage()
|
|||
void SettingsDialog::accept()
|
||||
{
|
||||
m_appConfig.setLoadFromSystemScope(ui->rbScopeSystem->isChecked());
|
||||
m_appConfig.setPort(ui->sbPort->value());
|
||||
Settings::setValue(Settings::Core::Port, ui->sbPort->value());
|
||||
Settings::setValue(Settings::Core::Interface, ui->lineInterface->text());
|
||||
m_appConfig.setLogLevel(ui->comboLogLevel->currentIndex());
|
||||
m_appConfig.setLogToFile(ui->cbLogToFile->isChecked());
|
||||
|
|
@ -178,7 +178,7 @@ void SettingsDialog::reject()
|
|||
void SettingsDialog::loadFromConfig()
|
||||
{
|
||||
|
||||
ui->sbPort->setValue(m_appConfig.port());
|
||||
ui->sbPort->setValue(Settings::value(Settings::Core::Port).toInt());
|
||||
ui->lineInterface->setText(Settings::value(Settings::Core::Interface).toString());
|
||||
ui->comboLogLevel->setCurrentIndex(m_appConfig.logLevel());
|
||||
ui->cbLogToFile->setChecked(m_appConfig.logToFile());
|
||||
|
|
|
|||
|
|
@ -84,22 +84,26 @@ QVariant Settings::defaultValue(const QString &key)
|
|||
if (key == Gui::WindowGeometry)
|
||||
return QRect();
|
||||
|
||||
if (key == Security::KeySize)
|
||||
return 2048;
|
||||
|
||||
if (key == Security::Certificate)
|
||||
return QStringLiteral("%1/%2/%3").arg(instance()->settingsPath(), kTlsDirName, kTlsCertificateFilename);
|
||||
|
||||
if (key == Security::KeySize)
|
||||
return 2048;
|
||||
|
||||
if (key == Client::Binary)
|
||||
return kClientBinName;
|
||||
|
||||
if (key == Server::Binary)
|
||||
return kServerBinName;
|
||||
|
||||
if (key == Server::ExternalConfigFile) {
|
||||
const auto baseDir = QFileInfo(instance()->m_settings->fileName()).absolutePath();
|
||||
return QStringLiteral("%1/%2.conf").arg(baseDir, kAppId);
|
||||
}
|
||||
if (key == Server::ExternalConfigFile)
|
||||
return QStringLiteral("%1/%2.conf").arg(instance()->settingsPath(), kAppId);
|
||||
|
||||
if (key == Security::KeySize)
|
||||
return 2048;
|
||||
|
||||
if (key == Core::Port)
|
||||
return 24800;
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ public:
|
|||
{
|
||||
inline static const auto Interface = QStringLiteral("core/interface");
|
||||
inline static const auto LastVersion = QStringLiteral("core/lastVersion");
|
||||
inline static const auto Port = QStringLiteral("core/port");
|
||||
inline static const auto PreventSleep = QStringLiteral("core/preventSleep");
|
||||
inline static const auto Scope = QStringLiteral("core/loadFromSystemScope");
|
||||
inline static const auto StartedBefore = QStringLiteral("core/startedBefore");
|
||||
|
|
@ -104,6 +105,7 @@ private:
|
|||
, Client::RemoteHost
|
||||
, Core::Interface
|
||||
, Core::LastVersion
|
||||
, Core::Port
|
||||
, Core::PreventSleep
|
||||
, Core::Scope
|
||||
, Core::StartedBefore
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ const char AppConfig::m_LogDir[] = "/var/log/";
|
|||
// TODO: instead, use key value pair table, which would be less fragile.
|
||||
const char *const AppConfig::m_SettingsName[] = {
|
||||
"screenName",
|
||||
"port",
|
||||
"", // port moved to deskflow settings
|
||||
"", // interface moved to deskflow settings
|
||||
"logLevel2",
|
||||
"logToFile",
|
||||
|
|
@ -114,7 +114,6 @@ void AppConfig::recallFromCurrentScope()
|
|||
recallScreenName();
|
||||
recallElevateMode();
|
||||
|
||||
m_Port = getFromCurrentScope(kPort, m_Port).toInt();
|
||||
m_LogLevel = getFromCurrentScope(kLogLevel, m_LogLevel).toInt();
|
||||
m_LogToFile = getFromCurrentScope(kLogToFile, m_LogToFile).toBool();
|
||||
m_LogFilename = getFromCurrentScope(kLogFilename, m_LogFilename).toString();
|
||||
|
|
@ -153,7 +152,6 @@ void AppConfig::commit()
|
|||
|
||||
if (isActiveScopeWritable()) {
|
||||
setInCurrentScope(kScreenName, m_ScreenName);
|
||||
setInCurrentScope(kPort, m_Port);
|
||||
setInCurrentScope(kLogLevel, m_LogLevel);
|
||||
setInCurrentScope(kLogToFile, m_LogToFile);
|
||||
setInCurrentScope(kLogFilename, m_LogFilename);
|
||||
|
|
@ -359,11 +357,6 @@ const QString &AppConfig::screenName() const
|
|||
return m_ScreenName;
|
||||
}
|
||||
|
||||
int AppConfig::port() const
|
||||
{
|
||||
return m_Port;
|
||||
}
|
||||
|
||||
int AppConfig::logLevel() const
|
||||
{
|
||||
return m_LogLevel;
|
||||
|
|
@ -443,11 +436,6 @@ void AppConfig::setScreenName(const QString &s)
|
|||
Q_EMIT screenNameChanged();
|
||||
}
|
||||
|
||||
void AppConfig::setPort(int i)
|
||||
{
|
||||
m_Port = i;
|
||||
}
|
||||
|
||||
void AppConfig::setLogLevel(int i)
|
||||
{
|
||||
const auto changed = (m_LogLevel != i);
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ private:
|
|||
enum class Setting
|
||||
{
|
||||
kScreenName = 0,
|
||||
kPort = 1,
|
||||
// kPort = 1, moved to deskflow settings
|
||||
// kInterface = 2, moved to deskflow settings
|
||||
kLogLevel = 3,
|
||||
kLogToFile = 4,
|
||||
|
|
@ -135,7 +135,6 @@ public:
|
|||
bool logToFile() const override;
|
||||
const QString &logFilename() const override;
|
||||
void persistLogDir() const override;
|
||||
int port() const override;
|
||||
bool isActiveScopeWritable() const override;
|
||||
bool isActiveScopeSystem() const override;
|
||||
int logLevel() const override;
|
||||
|
|
@ -155,7 +154,6 @@ public:
|
|||
//
|
||||
|
||||
void setScreenName(const QString &s) override;
|
||||
void setPort(int i) override;
|
||||
void setLogLevel(int i) override;
|
||||
void setLogToFile(bool b) override;
|
||||
void setLogFilename(const QString &s) override;
|
||||
|
|
@ -227,7 +225,6 @@ private:
|
|||
/// @brief Contains the string values of the settings names that will be saved
|
||||
static const char *const m_SettingsName[];
|
||||
|
||||
int m_Port = 24800;
|
||||
int m_LogLevel = 0;
|
||||
bool m_LogToFile = false;
|
||||
QString m_LogFilename = logDir() + deskflow::gui::kDefaultLogFile;
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@ public:
|
|||
virtual bool logToFile() const = 0;
|
||||
virtual const QString &logFilename() const = 0;
|
||||
virtual void persistLogDir() const = 0;
|
||||
virtual int port() const = 0;
|
||||
virtual int logLevel() const = 0;
|
||||
virtual bool enableService() const = 0;
|
||||
virtual bool isActiveScopeSystem() const = 0;
|
||||
|
|
@ -52,7 +51,6 @@ public:
|
|||
|
||||
virtual void setLoadFromSystemScope(bool loadFromSystemScope) = 0;
|
||||
virtual void setScreenName(const QString &screenName) = 0;
|
||||
virtual void setPort(int port) = 0;
|
||||
virtual void setLogLevel(int logLevel) = 0;
|
||||
virtual void setLogToFile(bool logToFile) = 0;
|
||||
virtual void setLogFilename(const QString &logFilename) = 0;
|
||||
|
|
|
|||
|
|
@ -595,7 +595,7 @@ bool CoreProcess::addClientArgs(QStringList &args, QString &app)
|
|||
return false;
|
||||
}
|
||||
|
||||
args << correctedAddress() + ":" + QString::number(m_appConfig.port());
|
||||
args << correctedAddress() + ":" + Settings::value(Settings::Core::Port).toString();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -720,8 +720,9 @@ void CoreProcess::checkOSXNotification(const QString &line)
|
|||
|
||||
QString CoreProcess::correctedInterface() const
|
||||
{
|
||||
QString interface = wrapIpv6(Settings::value(Settings::Core::Interface).toString());
|
||||
return interface + ":" + QString::number(m_appConfig.port());
|
||||
const QString interface = wrapIpv6(Settings::value(Settings::Core::Interface).toString());
|
||||
const auto port = Settings::value(Settings::Core::Port).toString();
|
||||
return QStringLiteral("%1:%2").arg(interface, port);
|
||||
}
|
||||
|
||||
QString CoreProcess::correctedAddress() const
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@ public:
|
|||
MOCK_METHOD(bool, logToFile, (), (const, override));
|
||||
MOCK_METHOD(const QString &, logFilename, (), (const, override));
|
||||
MOCK_METHOD(void, persistLogDir, (), (const, override));
|
||||
MOCK_METHOD(int, port, (), (const, override));
|
||||
MOCK_METHOD(int, logLevel, (), (const, override));
|
||||
MOCK_METHOD(bool, enableService, (), (const, override));
|
||||
MOCK_METHOD(bool, isActiveScopeSystem, (), (const, override));
|
||||
|
|
@ -51,7 +50,6 @@ public:
|
|||
|
||||
MOCK_METHOD(void, setLoadFromSystemScope, (bool loadFromSystemScope), (override));
|
||||
MOCK_METHOD(void, setScreenName, (const QString &screenName), (override));
|
||||
MOCK_METHOD(void, setPort, (int port), (override));
|
||||
MOCK_METHOD(void, setLogLevel, (int logLevel), (override));
|
||||
MOCK_METHOD(void, setLogToFile, (bool logToFile), (override));
|
||||
MOCK_METHOD(void, setLogFilename, (const QString &logFilename), (override));
|
||||
|
|
|
|||
Loading…
Reference in a new issue