refactor: move closeToTray setting to Settings
newkey: gui/closeToTray <= General/closeToTray remove closeToTray from `AppConfig`
This commit is contained in:
parent
788f6c3eb2
commit
51a749b109
8 changed files with 10 additions and 26 deletions
|
|
@ -850,7 +850,7 @@ void MainWindow::showEvent(QShowEvent *event)
|
|||
|
||||
void MainWindow::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
if (m_appConfig.closeToTray() && event->spontaneous()) {
|
||||
if (Settings::value(Settings::Gui::CloseToTray).toBool() && event->spontaneous()) {
|
||||
if (m_appConfig.showCloseReminder()) {
|
||||
messages::showCloseReminder(this);
|
||||
m_appConfig.setShowCloseReminder(false);
|
||||
|
|
@ -881,7 +881,8 @@ void MainWindow::showFirstConnectedMessage()
|
|||
m_configScopes.save();
|
||||
|
||||
const auto isServer = m_coreProcess.mode() == CoreMode::Server;
|
||||
messages::showFirstConnectedMessage(this, m_appConfig.closeToTray(), m_appConfig.enableService(), isServer);
|
||||
const auto closeToTray = Settings::value(Settings::Gui::CloseToTray).toBool();
|
||||
messages::showFirstConnectedMessage(this, closeToTray, m_appConfig.enableService(), isServer);
|
||||
}
|
||||
|
||||
void MainWindow::updateStatus()
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ void SettingsDialog::accept()
|
|||
m_appConfig.setLanguageSync(ui->cbLanguageSync->isChecked());
|
||||
m_appConfig.setInvertScrollDirection(ui->cbScrollDirection->isChecked());
|
||||
m_appConfig.setEnableService(ui->cbServiceEnabled->isChecked());
|
||||
m_appConfig.setCloseToTray(ui->cbCloseToTray->isChecked());
|
||||
Settings::setValue(Settings::Gui::CloseToTray, ui->cbCloseToTray->isChecked());
|
||||
Settings::setValue(Settings::Gui::SymbolicTrayIcon, ui->rbIconMono->isChecked());
|
||||
m_appConfig.setRequireClientCerts(ui->cbRequireClientCert->isChecked());
|
||||
|
||||
|
|
@ -188,7 +188,7 @@ void SettingsDialog::loadFromConfig()
|
|||
ui->cbLanguageSync->setChecked(m_appConfig.languageSync());
|
||||
ui->cbScrollDirection->setChecked(m_appConfig.invertScrollDirection());
|
||||
ui->cbServiceEnabled->setChecked(m_appConfig.enableService());
|
||||
ui->cbCloseToTray->setChecked(m_appConfig.closeToTray());
|
||||
ui->cbCloseToTray->setChecked(Settings::value(Settings::Gui::CloseToTray).toBool());
|
||||
ui->comboElevate->setCurrentIndex(static_cast<int>(m_appConfig.elevateMode()));
|
||||
|
||||
ui->cbAutoUpdate->setChecked(Settings::value(Settings::Gui::Autohide).toBool());
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ QVariant Settings::defaultValue(const QString &key)
|
|||
return false;
|
||||
}
|
||||
|
||||
if ((key == Gui::LogExpanded) || (key == Gui::SymbolicTrayIcon)) {
|
||||
if ((key == Gui::CloseToTray) || (key == Gui::LogExpanded) || (key == Gui::SymbolicTrayIcon)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ public:
|
|||
{
|
||||
inline static const auto Autohide = QStringLiteral("gui/autoHide");
|
||||
inline static const auto AutoUpdateCheck = QStringLiteral("gui/enableUpdateCheck");
|
||||
inline static const auto CloseToTray = QStringLiteral("gui/closeToTray");
|
||||
inline static const auto LogExpanded = QStringLiteral("gui/logExpanded");
|
||||
inline static const auto SymbolicTrayIcon = QStringLiteral("gui/symbolicTrayIcon");
|
||||
};
|
||||
|
|
@ -75,6 +76,7 @@ private:
|
|||
Core::Scope
|
||||
, Gui::Autohide
|
||||
, Gui::AutoUpdateCheck
|
||||
, Gui::CloseToTray
|
||||
, Gui::LogExpanded
|
||||
, Gui::SymbolicTrayIcon
|
||||
};
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ const char *const AppConfig::m_SettingsName[] = {
|
|||
"", // 35 = clientHostMode, obsolete
|
||||
"", // 36 = serverClientMode, obsolete
|
||||
"enableService",
|
||||
"closeToTray",
|
||||
"", // 38 Moved to deskflow settings
|
||||
"mainWindowSize",
|
||||
"mainWindowPosition",
|
||||
"", // 41 = Show dev thanks, obsolete
|
||||
|
|
@ -132,7 +132,6 @@ void AppConfig::recallFromCurrentScope()
|
|||
m_LanguageSync = getFromCurrentScope(kLanguageSync, m_LanguageSync).toBool();
|
||||
m_InvertScrollDirection = getFromCurrentScope(kInvertScrollDirection, m_InvertScrollDirection).toBool();
|
||||
m_EnableService = getFromCurrentScope(kEnableService, m_EnableService).toBool();
|
||||
m_CloseToTray = getFromCurrentScope(kCloseToTray, m_CloseToTray).toBool();
|
||||
m_TlsEnabled = getFromCurrentScope(kTlsEnabled, m_TlsEnabled).toBool();
|
||||
m_TlsCertPath = getFromCurrentScope(kTlsCertPath, m_TlsCertPath).toString();
|
||||
m_TlsKeyLength = getFromCurrentScope(kTlsKeyLength, m_TlsKeyLength).toInt();
|
||||
|
|
@ -190,7 +189,6 @@ void AppConfig::commit()
|
|||
setInCurrentScope(kLanguageSync, m_LanguageSync);
|
||||
setInCurrentScope(kInvertScrollDirection, m_InvertScrollDirection);
|
||||
setInCurrentScope(kEnableService, m_EnableService);
|
||||
setInCurrentScope(kCloseToTray, m_CloseToTray);
|
||||
setInCurrentScope(kMainWindowSize, m_MainWindowSize);
|
||||
setInCurrentScope(kMainWindowPosition, m_MainWindowPosition);
|
||||
setInCurrentScope(kShowCloseReminder, m_ShowCloseReminder);
|
||||
|
|
@ -501,11 +499,6 @@ bool AppConfig::enableService() const
|
|||
return m_EnableService;
|
||||
}
|
||||
|
||||
bool AppConfig::closeToTray() const
|
||||
{
|
||||
return m_CloseToTray;
|
||||
}
|
||||
|
||||
bool AppConfig::serverGroupChecked() const
|
||||
{
|
||||
return m_ServerGroupChecked;
|
||||
|
|
@ -691,11 +684,6 @@ void AppConfig::setEnableService(bool enabled)
|
|||
m_EnableService = enabled;
|
||||
}
|
||||
|
||||
void AppConfig::setCloseToTray(bool minimize)
|
||||
{
|
||||
m_CloseToTray = minimize;
|
||||
}
|
||||
|
||||
void AppConfig::setRequireClientCerts(bool requireClientCerts)
|
||||
{
|
||||
if (requireClientCerts == m_RequireClientCert)
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ private:
|
|||
// 35 = client-host-mode, obsolete
|
||||
// 36 = server-client-mode, obsolete
|
||||
kEnableService = 37,
|
||||
kCloseToTray = 38,
|
||||
// 38, close to tray moved to deskflow settings
|
||||
kMainWindowSize = 39,
|
||||
kMainWindowPosition = 40,
|
||||
// 41 = show dev thanks, obsolete
|
||||
|
|
@ -157,7 +157,6 @@ public:
|
|||
bool isActiveScopeSystem() const override;
|
||||
int logLevel() const override;
|
||||
bool enableService() const override;
|
||||
bool closeToTray() const override;
|
||||
bool clientGroupChecked() const override;
|
||||
bool requireClientCerts() const override;
|
||||
|
||||
|
|
@ -190,7 +189,6 @@ public:
|
|||
void setLanguageSync(bool b) override;
|
||||
void setPreventSleep(bool b) override;
|
||||
void setEnableService(bool enabled) override;
|
||||
void setCloseToTray(bool minimize) override;
|
||||
void setTlsCertPath(const QString &path) override;
|
||||
void setTlsKeyLength(int length) override;
|
||||
void setRequireClientCerts(bool requireClientCerts) override;
|
||||
|
|
@ -305,7 +303,6 @@ private:
|
|||
bool m_ClientGroupChecked = false;
|
||||
QString m_ServerHostname = "";
|
||||
bool m_EnableService = deskflow::gui::kDefaultProcessMode == ProcessMode::kService;
|
||||
bool m_CloseToTray = true;
|
||||
int m_TlsKeyLength = deskflow::gui::kDefaultTlsKeyLength;
|
||||
std::optional<QSize> m_MainWindowSize;
|
||||
std::optional<QPoint> m_MainWindowPosition;
|
||||
|
|
|
|||
|
|
@ -54,7 +54,6 @@ public:
|
|||
virtual const QString &serverHostname() const = 0;
|
||||
virtual int logLevel() const = 0;
|
||||
virtual bool enableService() const = 0;
|
||||
virtual bool closeToTray() const = 0;
|
||||
virtual bool isActiveScopeSystem() const = 0;
|
||||
virtual bool isActiveScopeWritable() const = 0;
|
||||
virtual bool clientGroupChecked() const = 0;
|
||||
|
|
@ -79,7 +78,6 @@ public:
|
|||
virtual void setLanguageSync(bool languageSync) = 0;
|
||||
virtual void setInvertScrollDirection(bool invertScrollDirection) = 0;
|
||||
virtual void setEnableService(bool enableService) = 0;
|
||||
virtual void setCloseToTray(bool closeToTray) = 0;
|
||||
virtual void setRequireClientCerts(bool requireClientCerts) = 0;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -55,7 +55,6 @@ public:
|
|||
MOCK_METHOD(const QString &, serverHostname, (), (const, override));
|
||||
MOCK_METHOD(int, logLevel, (), (const, override));
|
||||
MOCK_METHOD(bool, enableService, (), (const, override));
|
||||
MOCK_METHOD(bool, closeToTray, (), (const, override));
|
||||
MOCK_METHOD(bool, isActiveScopeSystem, (), (const, override));
|
||||
MOCK_METHOD(bool, isActiveScopeWritable, (), (const, override));
|
||||
MOCK_METHOD(bool, clientGroupChecked, (), (const, override));
|
||||
|
|
@ -80,7 +79,6 @@ public:
|
|||
MOCK_METHOD(void, setLanguageSync, (bool languageSync), (override));
|
||||
MOCK_METHOD(void, setInvertScrollDirection, (bool invertScrollDirection), (override));
|
||||
MOCK_METHOD(void, setEnableService, (bool enableService), (override));
|
||||
MOCK_METHOD(void, setCloseToTray, (bool closeToTray), (override));
|
||||
MOCK_METHOD(void, setRequireClientCerts, (bool requireClientCerts), (override));
|
||||
|
||||
private:
|
||||
|
|
|
|||
Loading…
Reference in a new issue