refactor: move networkinterface to Settings
newkey: core/interface <= General/interface remove networkinterface from appconfig
This commit is contained in:
parent
d45d6baacb
commit
9aa1d6b79d
7 changed files with 7 additions and 26 deletions
|
|
@ -144,7 +144,7 @@ void SettingsDialog::accept()
|
||||||
{
|
{
|
||||||
m_appConfig.setLoadFromSystemScope(ui->rbScopeSystem->isChecked());
|
m_appConfig.setLoadFromSystemScope(ui->rbScopeSystem->isChecked());
|
||||||
m_appConfig.setPort(ui->sbPort->value());
|
m_appConfig.setPort(ui->sbPort->value());
|
||||||
m_appConfig.setNetworkInterface(ui->lineInterface->text());
|
Settings::setValue(Settings::Core::Interface, ui->lineInterface->text());
|
||||||
m_appConfig.setLogLevel(ui->comboLogLevel->currentIndex());
|
m_appConfig.setLogLevel(ui->comboLogLevel->currentIndex());
|
||||||
m_appConfig.setLogToFile(ui->cbLogToFile->isChecked());
|
m_appConfig.setLogToFile(ui->cbLogToFile->isChecked());
|
||||||
m_appConfig.setLogFilename(ui->lineLogFilename->text());
|
m_appConfig.setLogFilename(ui->lineLogFilename->text());
|
||||||
|
|
@ -179,7 +179,7 @@ void SettingsDialog::loadFromConfig()
|
||||||
{
|
{
|
||||||
|
|
||||||
ui->sbPort->setValue(m_appConfig.port());
|
ui->sbPort->setValue(m_appConfig.port());
|
||||||
ui->lineInterface->setText(m_appConfig.networkInterface());
|
ui->lineInterface->setText(Settings::value(Settings::Core::Interface).toString());
|
||||||
ui->comboLogLevel->setCurrentIndex(m_appConfig.logLevel());
|
ui->comboLogLevel->setCurrentIndex(m_appConfig.logLevel());
|
||||||
ui->cbLogToFile->setChecked(m_appConfig.logToFile());
|
ui->cbLogToFile->setChecked(m_appConfig.logToFile());
|
||||||
ui->lineLogFilename->setText(m_appConfig.logFilename());
|
ui->lineLogFilename->setText(m_appConfig.logFilename());
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ public:
|
||||||
};
|
};
|
||||||
struct Core
|
struct Core
|
||||||
{
|
{
|
||||||
|
inline static const auto Interface = QStringLiteral("core/interface");
|
||||||
inline static const auto LastVersion = QStringLiteral("core/lastVersion");
|
inline static const auto LastVersion = QStringLiteral("core/lastVersion");
|
||||||
inline static const auto PreventSleep = QStringLiteral("core/preventSleep");
|
inline static const auto PreventSleep = QStringLiteral("core/preventSleep");
|
||||||
inline static const auto Scope = QStringLiteral("core/loadFromSystemScope");
|
inline static const auto Scope = QStringLiteral("core/loadFromSystemScope");
|
||||||
|
|
@ -101,6 +102,7 @@ private:
|
||||||
, Client::InvertScrollDirection
|
, Client::InvertScrollDirection
|
||||||
, Client::LanguageSync
|
, Client::LanguageSync
|
||||||
, Client::RemoteHost
|
, Client::RemoteHost
|
||||||
|
, Core::Interface
|
||||||
, Core::LastVersion
|
, Core::LastVersion
|
||||||
, Core::PreventSleep
|
, Core::PreventSleep
|
||||||
, Core::Scope
|
, Core::Scope
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ const char AppConfig::m_LogDir[] = "/var/log/";
|
||||||
const char *const AppConfig::m_SettingsName[] = {
|
const char *const AppConfig::m_SettingsName[] = {
|
||||||
"screenName",
|
"screenName",
|
||||||
"port",
|
"port",
|
||||||
"interface",
|
"", // interface moved to deskflow settings
|
||||||
"logLevel2",
|
"logLevel2",
|
||||||
"logToFile",
|
"logToFile",
|
||||||
"logFilename",
|
"logFilename",
|
||||||
|
|
@ -115,7 +115,6 @@ void AppConfig::recallFromCurrentScope()
|
||||||
recallElevateMode();
|
recallElevateMode();
|
||||||
|
|
||||||
m_Port = getFromCurrentScope(kPort, m_Port).toInt();
|
m_Port = getFromCurrentScope(kPort, m_Port).toInt();
|
||||||
m_Interface = getFromCurrentScope(kInterface, m_Interface).toString();
|
|
||||||
m_LogLevel = getFromCurrentScope(kLogLevel, m_LogLevel).toInt();
|
m_LogLevel = getFromCurrentScope(kLogLevel, m_LogLevel).toInt();
|
||||||
m_LogToFile = getFromCurrentScope(kLogToFile, m_LogToFile).toBool();
|
m_LogToFile = getFromCurrentScope(kLogToFile, m_LogToFile).toBool();
|
||||||
m_LogFilename = getFromCurrentScope(kLogFilename, m_LogFilename).toString();
|
m_LogFilename = getFromCurrentScope(kLogFilename, m_LogFilename).toString();
|
||||||
|
|
@ -155,7 +154,6 @@ void AppConfig::commit()
|
||||||
if (isActiveScopeWritable()) {
|
if (isActiveScopeWritable()) {
|
||||||
setInCurrentScope(kScreenName, m_ScreenName);
|
setInCurrentScope(kScreenName, m_ScreenName);
|
||||||
setInCurrentScope(kPort, m_Port);
|
setInCurrentScope(kPort, m_Port);
|
||||||
setInCurrentScope(kInterface, m_Interface);
|
|
||||||
setInCurrentScope(kLogLevel, m_LogLevel);
|
setInCurrentScope(kLogLevel, m_LogLevel);
|
||||||
setInCurrentScope(kLogToFile, m_LogToFile);
|
setInCurrentScope(kLogToFile, m_LogToFile);
|
||||||
setInCurrentScope(kLogFilename, m_LogFilename);
|
setInCurrentScope(kLogFilename, m_LogFilename);
|
||||||
|
|
@ -366,11 +364,6 @@ int AppConfig::port() const
|
||||||
return m_Port;
|
return m_Port;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &AppConfig::networkInterface() const
|
|
||||||
{
|
|
||||||
return m_Interface;
|
|
||||||
}
|
|
||||||
|
|
||||||
int AppConfig::logLevel() const
|
int AppConfig::logLevel() const
|
||||||
{
|
{
|
||||||
return m_LogLevel;
|
return m_LogLevel;
|
||||||
|
|
@ -455,11 +448,6 @@ void AppConfig::setPort(int i)
|
||||||
m_Port = i;
|
m_Port = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppConfig::setNetworkInterface(const QString &s)
|
|
||||||
{
|
|
||||||
m_Interface = s;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AppConfig::setLogLevel(int i)
|
void AppConfig::setLogLevel(int i)
|
||||||
{
|
{
|
||||||
const auto changed = (m_LogLevel != i);
|
const auto changed = (m_LogLevel != i);
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ private:
|
||||||
{
|
{
|
||||||
kScreenName = 0,
|
kScreenName = 0,
|
||||||
kPort = 1,
|
kPort = 1,
|
||||||
kInterface = 2,
|
// kInterface = 2, moved to deskflow settings
|
||||||
kLogLevel = 3,
|
kLogLevel = 3,
|
||||||
kLogToFile = 4,
|
kLogToFile = 4,
|
||||||
kLogFilename = 5,
|
kLogFilename = 5,
|
||||||
|
|
@ -136,7 +136,6 @@ public:
|
||||||
const QString &logFilename() const override;
|
const QString &logFilename() const override;
|
||||||
void persistLogDir() const override;
|
void persistLogDir() const override;
|
||||||
int port() const override;
|
int port() const override;
|
||||||
const QString &networkInterface() const override;
|
|
||||||
bool isActiveScopeWritable() const override;
|
bool isActiveScopeWritable() const override;
|
||||||
bool isActiveScopeSystem() const override;
|
bool isActiveScopeSystem() const override;
|
||||||
int logLevel() const override;
|
int logLevel() const override;
|
||||||
|
|
@ -157,7 +156,6 @@ public:
|
||||||
|
|
||||||
void setScreenName(const QString &s) override;
|
void setScreenName(const QString &s) override;
|
||||||
void setPort(int i) override;
|
void setPort(int i) override;
|
||||||
void setNetworkInterface(const QString &s) override;
|
|
||||||
void setLogLevel(int i) override;
|
void setLogLevel(int i) override;
|
||||||
void setLogToFile(bool b) override;
|
void setLogToFile(bool b) override;
|
||||||
void setLogFilename(const QString &s) override;
|
void setLogFilename(const QString &s) override;
|
||||||
|
|
@ -230,7 +228,6 @@ private:
|
||||||
static const char *const m_SettingsName[];
|
static const char *const m_SettingsName[];
|
||||||
|
|
||||||
int m_Port = 24800;
|
int m_Port = 24800;
|
||||||
QString m_Interface = "";
|
|
||||||
int m_LogLevel = 0;
|
int m_LogLevel = 0;
|
||||||
bool m_LogToFile = false;
|
bool m_LogToFile = false;
|
||||||
QString m_LogFilename = logDir() + deskflow::gui::kDefaultLogFile;
|
QString m_LogFilename = logDir() + deskflow::gui::kDefaultLogFile;
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,6 @@ public:
|
||||||
virtual const QString &logFilename() const = 0;
|
virtual const QString &logFilename() const = 0;
|
||||||
virtual void persistLogDir() const = 0;
|
virtual void persistLogDir() const = 0;
|
||||||
virtual int port() const = 0;
|
virtual int port() const = 0;
|
||||||
virtual const QString &networkInterface() const = 0;
|
|
||||||
virtual int logLevel() const = 0;
|
virtual int logLevel() const = 0;
|
||||||
virtual bool enableService() const = 0;
|
virtual bool enableService() const = 0;
|
||||||
virtual bool isActiveScopeSystem() const = 0;
|
virtual bool isActiveScopeSystem() const = 0;
|
||||||
|
|
@ -54,7 +53,6 @@ public:
|
||||||
virtual void setLoadFromSystemScope(bool loadFromSystemScope) = 0;
|
virtual void setLoadFromSystemScope(bool loadFromSystemScope) = 0;
|
||||||
virtual void setScreenName(const QString &screenName) = 0;
|
virtual void setScreenName(const QString &screenName) = 0;
|
||||||
virtual void setPort(int port) = 0;
|
virtual void setPort(int port) = 0;
|
||||||
virtual void setNetworkInterface(const QString &networkInterface) = 0;
|
|
||||||
virtual void setLogLevel(int logLevel) = 0;
|
virtual void setLogLevel(int logLevel) = 0;
|
||||||
virtual void setLogToFile(bool logToFile) = 0;
|
virtual void setLogToFile(bool logToFile) = 0;
|
||||||
virtual void setLogFilename(const QString &logFilename) = 0;
|
virtual void setLogFilename(const QString &logFilename) = 0;
|
||||||
|
|
|
||||||
|
|
@ -720,7 +720,7 @@ void CoreProcess::checkOSXNotification(const QString &line)
|
||||||
|
|
||||||
QString CoreProcess::correctedInterface() const
|
QString CoreProcess::correctedInterface() const
|
||||||
{
|
{
|
||||||
QString interface = wrapIpv6(m_appConfig.networkInterface());
|
QString interface = wrapIpv6(Settings::value(Settings::Core::Interface).toString());
|
||||||
return interface + ":" + QString::number(m_appConfig.port());
|
return interface + ":" + QString::number(m_appConfig.port());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,6 @@ public:
|
||||||
{
|
{
|
||||||
ON_CALL(*this, screenName()).WillByDefault(testing::ReturnRef(m_stub));
|
ON_CALL(*this, screenName()).WillByDefault(testing::ReturnRef(m_stub));
|
||||||
|
|
||||||
ON_CALL(*this, networkInterface()).WillByDefault(testing::ReturnRef(m_stub));
|
|
||||||
|
|
||||||
ON_CALL(*this, logLevelText()).WillByDefault(testing::Return(m_stub));
|
ON_CALL(*this, logLevelText()).WillByDefault(testing::Return(m_stub));
|
||||||
|
|
||||||
ON_CALL(*this, logFilename()).WillByDefault(testing::ReturnRef(m_stub));
|
ON_CALL(*this, logFilename()).WillByDefault(testing::ReturnRef(m_stub));
|
||||||
|
|
@ -41,7 +39,6 @@ public:
|
||||||
MOCK_METHOD(const QString &, logFilename, (), (const, override));
|
MOCK_METHOD(const QString &, logFilename, (), (const, override));
|
||||||
MOCK_METHOD(void, persistLogDir, (), (const, override));
|
MOCK_METHOD(void, persistLogDir, (), (const, override));
|
||||||
MOCK_METHOD(int, port, (), (const, override));
|
MOCK_METHOD(int, port, (), (const, override));
|
||||||
MOCK_METHOD(const QString &, networkInterface, (), (const, override));
|
|
||||||
MOCK_METHOD(int, logLevel, (), (const, override));
|
MOCK_METHOD(int, logLevel, (), (const, override));
|
||||||
MOCK_METHOD(bool, enableService, (), (const, override));
|
MOCK_METHOD(bool, enableService, (), (const, override));
|
||||||
MOCK_METHOD(bool, isActiveScopeSystem, (), (const, override));
|
MOCK_METHOD(bool, isActiveScopeSystem, (), (const, override));
|
||||||
|
|
@ -55,7 +52,6 @@ public:
|
||||||
MOCK_METHOD(void, setLoadFromSystemScope, (bool loadFromSystemScope), (override));
|
MOCK_METHOD(void, setLoadFromSystemScope, (bool loadFromSystemScope), (override));
|
||||||
MOCK_METHOD(void, setScreenName, (const QString &screenName), (override));
|
MOCK_METHOD(void, setScreenName, (const QString &screenName), (override));
|
||||||
MOCK_METHOD(void, setPort, (int port), (override));
|
MOCK_METHOD(void, setPort, (int port), (override));
|
||||||
MOCK_METHOD(void, setNetworkInterface, (const QString &networkInterface), (override));
|
|
||||||
MOCK_METHOD(void, setLogLevel, (int logLevel), (override));
|
MOCK_METHOD(void, setLogLevel, (int logLevel), (override));
|
||||||
MOCK_METHOD(void, setLogToFile, (bool logToFile), (override));
|
MOCK_METHOD(void, setLogToFile, (bool logToFile), (override));
|
||||||
MOCK_METHOD(void, setLogFilename, (const QString &logFilename), (override));
|
MOCK_METHOD(void, setLogFilename, (const QString &logFilename), (override));
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue