refactor: Move update check setting to Settings

newkey: gui/enableUpdateCheck <= General/enableUpdateCheck
remove update check from `AppConfig`
This commit is contained in:
sithlord48 2025-03-04 23:25:38 -05:00 committed by Nick Bolton
parent e01c595071
commit 788f6c3eb2
5 changed files with 10 additions and 27 deletions

View file

@ -619,13 +619,13 @@ void MainWindow::serverConnectionConfigureClient(const QString &clientName)
void MainWindow::open() void MainWindow::open()
{ {
if (!m_appConfig.enableUpdateCheck().has_value()) {
if (!Settings::value(Settings::Gui::AutoUpdateCheck).isValid()) {
showAndActivate(); showAndActivate();
m_appConfig.setEnableUpdateCheck(messages::showUpdateCheckOption(this)); Settings::setValue(Settings::Gui::AutoUpdateCheck, messages::showUpdateCheckOption(this));
m_configScopes.save();
} }
if (m_appConfig.enableUpdateCheck().value()) { if (Settings::value(Settings::Gui::AutoUpdateCheck).toBool()) {
m_versionChecker.checkLatest(); m_versionChecker.checkLatest();
} else { } else {
qDebug() << "update check disabled"; qDebug() << "update check disabled";

View file

@ -150,7 +150,7 @@ void SettingsDialog::accept()
m_appConfig.setLogFilename(ui->lineLogFilename->text()); m_appConfig.setLogFilename(ui->lineLogFilename->text());
m_appConfig.setElevateMode(static_cast<ElevateMode>(ui->comboElevate->currentIndex())); m_appConfig.setElevateMode(static_cast<ElevateMode>(ui->comboElevate->currentIndex()));
Settings::setValue(Settings::Gui::Autohide, ui->cbAutoHide->isChecked()); Settings::setValue(Settings::Gui::Autohide, ui->cbAutoHide->isChecked());
m_appConfig.setEnableUpdateCheck(ui->cbAutoUpdate->isChecked()); Settings::setValue(Settings::Gui::AutoUpdateCheck, ui->cbAutoUpdate->isChecked());
m_appConfig.setPreventSleep(ui->cbPreventSleep->isChecked()); m_appConfig.setPreventSleep(ui->cbPreventSleep->isChecked());
m_appConfig.setTlsCertPath(ui->lineTlsCertPath->text()); m_appConfig.setTlsCertPath(ui->lineTlsCertPath->text());
m_appConfig.setTlsKeyLength(ui->comboTlsKeyLength->currentText().toInt()); m_appConfig.setTlsKeyLength(ui->comboTlsKeyLength->currentText().toInt());
@ -191,11 +191,7 @@ void SettingsDialog::loadFromConfig()
ui->cbCloseToTray->setChecked(m_appConfig.closeToTray()); ui->cbCloseToTray->setChecked(m_appConfig.closeToTray());
ui->comboElevate->setCurrentIndex(static_cast<int>(m_appConfig.elevateMode())); ui->comboElevate->setCurrentIndex(static_cast<int>(m_appConfig.elevateMode()));
if (m_appConfig.enableUpdateCheck().has_value()) { ui->cbAutoUpdate->setChecked(Settings::value(Settings::Gui::Autohide).toBool());
ui->cbAutoUpdate->setChecked(m_appConfig.enableUpdateCheck().value());
} else {
ui->cbAutoUpdate->setChecked(false);
}
if (m_appConfig.isActiveScopeSystem()) { if (m_appConfig.isActiveScopeSystem()) {
ui->rbScopeSystem->setChecked(true); ui->rbScopeSystem->setChecked(true);

View file

@ -37,6 +37,7 @@ public:
struct Gui struct Gui
{ {
inline static const auto Autohide = QStringLiteral("gui/autoHide"); inline static const auto Autohide = QStringLiteral("gui/autoHide");
inline static const auto AutoUpdateCheck = QStringLiteral("gui/enableUpdateCheck");
inline static const auto LogExpanded = QStringLiteral("gui/logExpanded"); inline static const auto LogExpanded = QStringLiteral("gui/logExpanded");
inline static const auto SymbolicTrayIcon = QStringLiteral("gui/symbolicTrayIcon"); inline static const auto SymbolicTrayIcon = QStringLiteral("gui/symbolicTrayIcon");
}; };
@ -73,6 +74,7 @@ private:
inline static const QStringList m_validKeys = { inline static const QStringList m_validKeys = {
Core::Scope Core::Scope
, Gui::Autohide , Gui::Autohide
, Gui::AutoUpdateCheck
, Gui::LogExpanded , Gui::LogExpanded
, Gui::SymbolicTrayIcon , Gui::SymbolicTrayIcon
}; };

View file

@ -76,7 +76,7 @@ const char *const AppConfig::m_SettingsName[] = {
"mainWindowPosition", "mainWindowPosition",
"", // 41 = Show dev thanks, obsolete "", // 41 = Show dev thanks, obsolete
"showCloseReminder", "showCloseReminder",
"enableUpdateCheck", "", // 43 Moved to deskflow settings
"", // 44, Moved to deskflow settings. "", // 44, Moved to deskflow settings.
"", // 45 Moved to deskflow settings "", // 45 Moved to deskflow settings
"requireClientCerts", "requireClientCerts",
@ -141,7 +141,6 @@ void AppConfig::recallFromCurrentScope()
getFromCurrentScope<QPoint>(kMainWindowPosition, [](const QVariant &v) { return v.toPoint(); }); getFromCurrentScope<QPoint>(kMainWindowPosition, [](const QVariant &v) { return v.toPoint(); });
m_MainWindowSize = getFromCurrentScope<QSize>(kMainWindowSize, [](const QVariant &v) { return v.toSize(); }); m_MainWindowSize = getFromCurrentScope<QSize>(kMainWindowSize, [](const QVariant &v) { return v.toSize(); });
m_ShowCloseReminder = getFromCurrentScope(kShowCloseReminder, m_ShowCloseReminder).toBool(); m_ShowCloseReminder = getFromCurrentScope(kShowCloseReminder, m_ShowCloseReminder).toBool();
m_EnableUpdateCheck = getFromCurrentScope<bool>(kEnableUpdateCheck, [](const QVariant &v) { return v.toBool(); });
} }
void AppConfig::recallScreenName() void AppConfig::recallScreenName()
@ -195,7 +194,6 @@ void AppConfig::commit()
setInCurrentScope(kMainWindowSize, m_MainWindowSize); setInCurrentScope(kMainWindowSize, m_MainWindowSize);
setInCurrentScope(kMainWindowPosition, m_MainWindowPosition); setInCurrentScope(kMainWindowPosition, m_MainWindowPosition);
setInCurrentScope(kShowCloseReminder, m_ShowCloseReminder); setInCurrentScope(kShowCloseReminder, m_ShowCloseReminder);
setInCurrentScope(kEnableUpdateCheck, m_EnableUpdateCheck);
setInCurrentScope(kRequireClientCert, m_RequireClientCert); setInCurrentScope(kRequireClientCert, m_RequireClientCert);
} }
@ -558,11 +556,6 @@ bool AppConfig::showCloseReminder() const
return m_ShowCloseReminder; return m_ShowCloseReminder;
} }
std::optional<bool> AppConfig::enableUpdateCheck() const
{
return m_EnableUpdateCheck;
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// End getters // End getters
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -725,11 +718,6 @@ void AppConfig::setShowCloseReminder(bool value)
m_ShowCloseReminder = value; m_ShowCloseReminder = value;
} }
void AppConfig::setEnableUpdateCheck(bool value)
{
m_EnableUpdateCheck = value;
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// End setters // End setters
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////

View file

@ -98,7 +98,7 @@ private:
kMainWindowPosition = 40, kMainWindowPosition = 40,
// 41 = show dev thanks, obsolete // 41 = show dev thanks, obsolete
kShowCloseReminder = 42, kShowCloseReminder = 42,
kEnableUpdateCheck = 43, // 43 = Enable Update Check,
// 44 = LogExpanded, Moved to deskflow settings // 44 = LogExpanded, Moved to deskflow settings
// 45 = Colorful Icon, Moved to deskflow settings // 45 = Colorful Icon, Moved to deskflow settings
kRequireClientCert = 46 kRequireClientCert = 46
@ -173,7 +173,6 @@ public:
std::optional<QSize> mainWindowSize() const; std::optional<QSize> mainWindowSize() const;
std::optional<QPoint> mainWindowPosition() const; std::optional<QPoint> mainWindowPosition() const;
bool showCloseReminder() const; bool showCloseReminder() const;
std::optional<bool> enableUpdateCheck() const;
// //
// Setters (overrides) // Setters (overrides)
@ -211,7 +210,6 @@ public:
void setMainWindowSize(const QSize &size); void setMainWindowSize(const QSize &size);
void setMainWindowPosition(const QPoint &position); void setMainWindowPosition(const QPoint &position);
void setShowCloseReminder(bool show); void setShowCloseReminder(bool show);
void setEnableUpdateCheck(bool value);
/// @brief Sets the user preference to load from SystemScope. /// @brief Sets the user preference to load from SystemScope.
/// @param [in] value /// @param [in] value
@ -313,7 +311,6 @@ private:
std::optional<QPoint> m_MainWindowPosition; std::optional<QPoint> m_MainWindowPosition;
bool m_LoadFromSystemScope = false; bool m_LoadFromSystemScope = false;
bool m_ShowCloseReminder = true; bool m_ShowCloseReminder = true;
std::optional<bool> m_EnableUpdateCheck;
bool m_RequireClientCert = true; bool m_RequireClientCert = true;
/** /**