diff --git a/src/common/config.cpp b/src/common/config.cpp index 358923e6b..7f4e44a6c 100644 --- a/src/common/config.cpp +++ b/src/common/config.cpp @@ -50,7 +50,6 @@ static bool isMotionControlsEnabled = true; static bool isDebugDump = false; static bool isShaderDebug = false; static bool isShowSplash = false; -static bool isAutoUpdate = false; static bool isAlwaysShowChangelog = false; static std::string isSideTrophy = "right"; static bool isNullGpu = false; @@ -243,10 +242,6 @@ bool showSplash() { return isShowSplash; } -bool autoUpdate() { - return isAutoUpdate; -} - bool alwaysShowChangelog() { return isAlwaysShowChangelog; } @@ -351,10 +346,6 @@ void setShowSplash(bool enable) { isShowSplash = enable; } -void setAutoUpdate(bool enable) { - isAutoUpdate = enable; -} - void setAlwaysShowChangelog(bool enable) { isAlwaysShowChangelog = enable; } @@ -629,7 +620,6 @@ void load(const std::filesystem::path& path) { updateChannel = toml::find_or(general, "updateChannel", "Nightly"); } isShowSplash = toml::find_or(general, "showSplash", true); - isAutoUpdate = toml::find_or(general, "autoUpdate", false); isAlwaysShowChangelog = toml::find_or(general, "alwaysShowChangelog", false); isSideTrophy = toml::find_or(general, "sideTrophy", "right"); compatibilityData = toml::find_or(general, "compatibilityEnabled", false); @@ -809,7 +799,6 @@ void save(const std::filesystem::path& path) { data["General"]["updateChannel"] = updateChannel; data["General"]["chooseHomeTab"] = chooseHomeTab; data["General"]["showSplash"] = isShowSplash; - data["General"]["autoUpdate"] = isAutoUpdate; data["General"]["alwaysShowChangelog"] = isAlwaysShowChangelog; data["General"]["sideTrophy"] = isSideTrophy; data["General"]["compatibilityEnabled"] = compatibilityData; @@ -953,7 +942,6 @@ void setDefaultValues() { isDebugDump = false; isShaderDebug = false; isShowSplash = false; - isAutoUpdate = false; isAlwaysShowChangelog = false; isSideTrophy = "right"; isNullGpu = false; diff --git a/src/common/config.h b/src/common/config.h index 6275a24b8..4d5131b78 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -62,7 +62,6 @@ bool allowHDR(); bool debugDump(); bool collectShadersForDebug(); bool showSplash(); -bool autoUpdate(); bool alwaysShowChangelog(); std::string sideTrophy(); bool nullGpu(); @@ -76,7 +75,6 @@ u32 vblankDiv(); void setDebugDump(bool enable); void setCollectShaderForDebug(bool enable); void setShowSplash(bool enable); -void setAutoUpdate(bool enable); void setAlwaysShowChangelog(bool enable); void setSideTrophy(std::string side); void setNullGpu(bool enable); diff --git a/src/qt_gui/check_update.cpp b/src/qt_gui/check_update.cpp index 550fdddb5..cafcc99a7 100644 --- a/src/qt_gui/check_update.cpp +++ b/src/qt_gui/check_update.cpp @@ -28,8 +28,10 @@ using namespace Common::FS; -CheckUpdate::CheckUpdate(const bool showMessage, QWidget* parent) - : QDialog(parent), networkManager(new QNetworkAccessManager(this)) { +CheckUpdate::CheckUpdate(std::shared_ptr gui_settings, const bool showMessage, + QWidget* parent) + : QDialog(parent), m_gui_settings(std::move(gui_settings)), + networkManager(new QNetworkAccessManager(this)) { setWindowTitle(tr("Auto Updater")); setFixedSize(0, 0); CheckForUpdates(showMessage); @@ -290,14 +292,14 @@ void CheckUpdate::setupUI(const QString& downloadUrl, const QString& latestDate, connect(noButton, &QPushButton::clicked, this, [this]() { close(); }); - autoUpdateCheckBox->setChecked(Config::autoUpdate()); + autoUpdateCheckBox->setChecked(m_gui_settings->GetValue(gui::gen_checkForUpdates).toBool()); #if (QT_VERSION < QT_VERSION_CHECK(6, 7, 0)) - connect(autoUpdateCheckBox, &QCheckBox::stateChanged, this, [](int state) { + connect(autoUpdateCheckBox, &QCheckBox::stateChanged, this, [this](int state) { #else - connect(autoUpdateCheckBox, &QCheckBox::checkStateChanged, this, [](Qt::CheckState state) { + connect(autoUpdateCheckBox, &QCheckBox::checkStateChanged, this, [this](Qt::CheckState state) { #endif const auto user_dir = Common::FS::GetUserPath(Common::FS::PathType::UserDir); - Config::setAutoUpdate(state == Qt::Checked); + m_gui_settings->SetValue(gui::gen_checkForUpdates, (state == Qt::Checked)); Config::save(user_dir / "config.toml"); }); diff --git a/src/qt_gui/check_update.h b/src/qt_gui/check_update.h index dfeb95e73..139059c41 100644 --- a/src/qt_gui/check_update.h +++ b/src/qt_gui/check_update.h @@ -8,12 +8,14 @@ #include #include #include +#include "gui_settings.h" class CheckUpdate : public QDialog { Q_OBJECT public: - explicit CheckUpdate(const bool showMessage, QWidget* parent = nullptr); + explicit CheckUpdate(std::shared_ptr gui_settings, const bool showMessage, + QWidget* parent = nullptr); ~CheckUpdate(); private slots: @@ -35,6 +37,7 @@ private: QString updateDownloadUrl; QNetworkAccessManager* networkManager; + std::shared_ptr m_gui_settings; }; #endif // CHECKUPDATE_H diff --git a/src/qt_gui/gui_settings.h b/src/qt_gui/gui_settings.h index 5c6806df2..c42c9d22a 100644 --- a/src/qt_gui/gui_settings.h +++ b/src/qt_gui/gui_settings.h @@ -8,10 +8,14 @@ namespace gui { // categories +const QString general = "general"; const QString main_window = "main_window"; const QString game_list = "game_list"; const QString game_grid = "game_grid"; +// general +const gui_value gen_checkForUpdates = gui_value(general, "showLabelsUnderIcons", false); + // main window settings const gui_value mw_geometry = gui_value(main_window, "geometry", QByteArray()); const gui_value mw_showLabelsUnderIcons = gui_value(main_window, "showLabelsUnderIcons", true); diff --git a/src/qt_gui/main_window.cpp b/src/qt_gui/main_window.cpp index 302eac4c0..f527b6413 100644 --- a/src/qt_gui/main_window.cpp +++ b/src/qt_gui/main_window.cpp @@ -367,11 +367,11 @@ void MainWindow::LoadGameLists() { #ifdef ENABLE_UPDATER void MainWindow::CheckUpdateMain(bool checkSave) { if (checkSave) { - if (!Config::autoUpdate()) { + if (!m_gui_settings->GetValue(gui::gen_checkForUpdates).toBool()) { return; } } - auto checkUpdate = new CheckUpdate(false); + auto checkUpdate = new CheckUpdate(m_gui_settings, false); checkUpdate->exec(); } #endif @@ -495,7 +495,7 @@ void MainWindow::CreateConnects() { #ifdef ENABLE_UPDATER connect(ui->updaterAct, &QAction::triggered, this, [this]() { - auto checkUpdate = new CheckUpdate(true); + auto checkUpdate = new CheckUpdate(m_gui_settings, true); checkUpdate->exec(); }); #endif diff --git a/src/qt_gui/settings_dialog.cpp b/src/qt_gui/settings_dialog.cpp index 571cf0dae..9ae2f75d4 100644 --- a/src/qt_gui/settings_dialog.cpp +++ b/src/qt_gui/settings_dialog.cpp @@ -177,14 +177,16 @@ SettingsDialog::SettingsDialog(std::shared_ptr gui_settings, { #ifdef ENABLE_UPDATER #if (QT_VERSION < QT_VERSION_CHECK(6, 7, 0)) - connect(ui->updateCheckBox, &QCheckBox::stateChanged, this, - [](int state) { Config::setAutoUpdate(state == Qt::Checked); }); + connect(ui->updateCheckBox, &QCheckBox::stateChanged, this, [this](int state) { + m_gui_settings->SetValue(gui::gen_checkForUpdates, state == Qt::Checked); + }); connect(ui->changelogCheckBox, &QCheckBox::stateChanged, this, [](int state) { Config::setAlwaysShowChangelog(state == Qt::Checked); }); #else - connect(ui->updateCheckBox, &QCheckBox::checkStateChanged, this, - [](Qt::CheckState state) { Config::setAutoUpdate(state == Qt::Checked); }); + connect(ui->updateCheckBox, &QCheckBox::checkStateChanged, this, [this](Qt::CheckState state) { + m_gui_settings->SetValue(gui::gen_checkForUpdates, state == Qt::Checked); + }); connect(ui->changelogCheckBox, &QCheckBox::checkStateChanged, this, [](Qt::CheckState state) { Config::setAlwaysShowChangelog(state == Qt::Checked); }); @@ -197,8 +199,8 @@ SettingsDialog::SettingsDialog(std::shared_ptr gui_settings, } }); - connect(ui->checkUpdateButton, &QPushButton::clicked, this, []() { - auto checkUpdate = new CheckUpdate(true); + connect(ui->checkUpdateButton, &QPushButton::clicked, this, [this]() { + auto checkUpdate = new CheckUpdate(m_gui_settings,true); checkUpdate->exec(); }); #else @@ -788,7 +790,7 @@ void SettingsDialog::UpdateSettings() { Config::setVkCrashDiagnosticEnabled(ui->crashDiagnosticsCheckBox->isChecked()); Config::setCollectShaderForDebug(ui->collectShaderCheckBox->isChecked()); Config::setCopyGPUCmdBuffers(ui->copyGPUBuffersCheckBox->isChecked()); - Config::setAutoUpdate(ui->updateCheckBox->isChecked()); + m_gui_settings->SetValue(gui::gen_checkForUpdates, ui->updateCheckBox->isChecked()); Config::setAlwaysShowChangelog(ui->changelogCheckBox->isChecked()); Config::setUpdateChannel(channelMap.value(ui->updateComboBox->currentText()).toStdString()); Config::setChooseHomeTab( @@ -873,4 +875,5 @@ void SettingsDialog::setDefaultValues() { m_gui_settings->SetValue(gui::gl_backgroundImageOpacity, 50); m_gui_settings->SetValue(gui::gl_playBackgroundMusic, false); m_gui_settings->SetValue(gui::gl_backgroundMusicVolume, 50); + m_gui_settings->SetValue(gui::gen_checkForUpdates, false); } \ No newline at end of file