From fac5058e7a23184c080d2b33224ca0a2047fff1f Mon Sep 17 00:00:00 2001 From: RickyRister Date: Sat, 28 Dec 2024 01:53:17 -0800 Subject: [PATCH] new setting --- cockatrice/src/dialogs/dlg_settings.cpp | 11 ++++++++--- cockatrice/src/dialogs/dlg_settings.h | 1 + cockatrice/src/settings/cache_settings.cpp | 7 +++++++ cockatrice/src/settings/cache_settings.h | 6 ++++++ dbconverter/src/mocks.cpp | 3 +++ tests/carddatabase/mocks.cpp | 3 +++ 6 files changed, 28 insertions(+), 3 deletions(-) diff --git a/cockatrice/src/dialogs/dlg_settings.cpp b/cockatrice/src/dialogs/dlg_settings.cpp index 4fcbeb407..d4ffd2815 100644 --- a/cockatrice/src/dialogs/dlg_settings.cpp +++ b/cockatrice/src/dialogs/dlg_settings.cpp @@ -61,6 +61,7 @@ GeneralSettingsPage::GeneralSettingsPage() // updates SettingsCache &settings = SettingsCache::instance(); + startupUpdateCheckCheckBox.setChecked(settings.getCheckUpdatesOnStartup()); updateNotificationCheckBox.setChecked(settings.getNotifyAboutUpdates()); newVersionOracleCheckBox.setChecked(settings.getNotifyAboutNewVersion()); @@ -68,6 +69,8 @@ GeneralSettingsPage::GeneralSettingsPage() connect(&languageBox, SIGNAL(currentIndexChanged(int)), this, SLOT(languageBoxChanged(int))); connect(&updateReleaseChannelBox, SIGNAL(currentIndexChanged(int)), &settings, SLOT(setUpdateReleaseChannel(int))); + connect(&startupUpdateCheckCheckBox, &QCheckBox::QT_STATE_CHANGED, &settings, + &SettingsCache::setCheckUpdatesOnStartup); connect(&updateNotificationCheckBox, &QCheckBox::QT_STATE_CHANGED, &settings, &SettingsCache::setNotifyAboutUpdate); connect(&newVersionOracleCheckBox, &QCheckBox::QT_STATE_CHANGED, &settings, &SettingsCache::setNotifyAboutNewVersion); @@ -78,9 +81,10 @@ GeneralSettingsPage::GeneralSettingsPage() personalGrid->addWidget(&languageBox, 0, 1); personalGrid->addWidget(&updateReleaseChannelLabel, 1, 0); personalGrid->addWidget(&updateReleaseChannelBox, 1, 1); - personalGrid->addWidget(&updateNotificationCheckBox, 3, 0, 1, 2); - personalGrid->addWidget(&newVersionOracleCheckBox, 4, 0, 1, 2); - personalGrid->addWidget(&showTipsOnStartup, 5, 0, 1, 2); + personalGrid->addWidget(&startupUpdateCheckCheckBox, 3, 0, 1, 2); + personalGrid->addWidget(&updateNotificationCheckBox, 4, 0, 1, 2); + personalGrid->addWidget(&newVersionOracleCheckBox, 5, 0, 1, 2); + personalGrid->addWidget(&showTipsOnStartup, 6, 0, 1, 2); personalGroupBox = new QGroupBox; personalGroupBox->setLayout(personalGrid); @@ -288,6 +292,7 @@ void GeneralSettingsPage::retranslateUi() customCardDatabasePathLabel.setText(tr("Custom database directory:")); tokenDatabasePathLabel.setText(tr("Token database:")); updateReleaseChannelLabel.setText(tr("Update channel")); + startupUpdateCheckCheckBox.setText(tr("Check for client updates on startup")); updateNotificationCheckBox.setText(tr("Notify if a feature supported by the server is missing in my client")); newVersionOracleCheckBox.setText(tr("Automatically run Oracle when running a new version of Cockatrice")); showTipsOnStartup.setText(tr("Show tips on startup")); diff --git a/cockatrice/src/dialogs/dlg_settings.h b/cockatrice/src/dialogs/dlg_settings.h index d7ecbd95c..983312184 100644 --- a/cockatrice/src/dialogs/dlg_settings.h +++ b/cockatrice/src/dialogs/dlg_settings.h @@ -65,6 +65,7 @@ private: QGroupBox *personalGroupBox; QGroupBox *pathsGroupBox; QComboBox languageBox; + QCheckBox startupUpdateCheckCheckBox; QCheckBox updateNotificationCheckBox; QCheckBox newVersionOracleCheckBox; QComboBox updateReleaseChannelBox; diff --git a/cockatrice/src/settings/cache_settings.cpp b/cockatrice/src/settings/cache_settings.cpp index 204497c87..618892044 100644 --- a/cockatrice/src/settings/cache_settings.cpp +++ b/cockatrice/src/settings/cache_settings.cpp @@ -192,6 +192,7 @@ SettingsCache::SettingsCache() mbDownloadSpoilers = settings->value("personal/downloadspoilers", false).toBool(); + checkUpdatesOnStartup = settings->value("personal/startupUpdateCheck", true).toBool(); notifyAboutUpdates = settings->value("personal/updatenotification", true).toBool(); notifyAboutNewVersion = settings->value("personal/newversionnotification", true).toBool(); updateReleaseChannel = settings->value("personal/updatereleasechannel", 0).toInt(); @@ -1107,6 +1108,12 @@ void SettingsCache::setDefaultStartingLifeTotal(const int _defaultStartingLifeTo settings->setValue("game/defaultstartinglifetotal", defaultStartingLifeTotal); }; +void SettingsCache::setCheckUpdatesOnStartup(QT_STATE_CHANGED_T value) +{ + checkUpdatesOnStartup = static_cast(value); + settings->setValue("personal/startupUpdateCheck", checkUpdatesOnStartup); +} + void SettingsCache::setRememberGameSettings(const bool _rememberGameSettings) { rememberGameSettings = _rememberGameSettings; diff --git a/cockatrice/src/settings/cache_settings.h b/cockatrice/src/settings/cache_settings.h index 19c736fbd..6b0a24598 100644 --- a/cockatrice/src/settings/cache_settings.h +++ b/cockatrice/src/settings/cache_settings.h @@ -93,6 +93,7 @@ private: QString lang; QString deckPath, replaysPath, picsPath, redirectCachePath, customPicsPath, cardDatabasePath, customCardDatabasePath, themesPath, spoilerDatabasePath, tokenDatabasePath, themeName; + bool checkUpdatesOnStartup; bool notifyAboutUpdates; bool notifyAboutNewVersion; bool showTipsOnStartup; @@ -269,6 +270,10 @@ public: { return buddyConnectNotificationsEnabled; } + bool getCheckUpdatesOnStartup() const + { + return checkUpdatesOnStartup; + } bool getNotifyAboutUpdates() const { return notifyAboutUpdates; @@ -704,6 +709,7 @@ public slots: void setCreateGameAsSpectator(const bool _createGameAsSpectator); void setDefaultStartingLifeTotal(const int _defaultStartingLifeTotal); void setRememberGameSettings(const bool _rememberGameSettings); + void setCheckUpdatesOnStartup(QT_STATE_CHANGED_T value); void setNotifyAboutUpdate(QT_STATE_CHANGED_T _notifyaboutupdate); void setNotifyAboutNewVersion(QT_STATE_CHANGED_T _notifyaboutnewversion); void setUpdateReleaseChannel(int _updateReleaseChannel); diff --git a/dbconverter/src/mocks.cpp b/dbconverter/src/mocks.cpp index a8d4cbf90..58ed79bf5 100644 --- a/dbconverter/src/mocks.cpp +++ b/dbconverter/src/mocks.cpp @@ -309,6 +309,9 @@ void SettingsCache::setDefaultStartingLifeTotal(const int /* _startingLifeTotal void SettingsCache::setRememberGameSettings(const bool /* _rememberGameSettings */) { } +void SettingsCache::setCheckUpdatesOnStartup(QT_STATE_CHANGED_T /* value */) +{ +} void SettingsCache::setNotifyAboutUpdate(QT_STATE_CHANGED_T /* _notifyaboutupdate */) { } diff --git a/tests/carddatabase/mocks.cpp b/tests/carddatabase/mocks.cpp index b251bbd7f..cfa2e947d 100644 --- a/tests/carddatabase/mocks.cpp +++ b/tests/carddatabase/mocks.cpp @@ -313,6 +313,9 @@ void SettingsCache::setDefaultStartingLifeTotal(const int /* _startingLifeTotal void SettingsCache::setRememberGameSettings(const bool /* _rememberGameSettings */) { } +void SettingsCache::setCheckUpdatesOnStartup(QT_STATE_CHANGED_T /* value */) +{ +} void SettingsCache::setNotifyAboutUpdate(QT_STATE_CHANGED_T /* _notifyaboutupdate */) { }