Merge pull request #945 from ggrtk/settings-version-warning

Qt: Improve handling of settings version increases
This commit is contained in:
Connor McLaughlin 2020-10-09 18:07:26 +10:00 committed by GitHub
commit 568de19fc6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 39 additions and 2 deletions

View File

@ -256,6 +256,7 @@ void AutoUpdaterDialog::getChangesComplete(QNetworkReply* reply)
const QJsonArray commits(doc_object["commits"].toArray()); const QJsonArray commits(doc_object["commits"].toArray());
bool update_will_break_save_states = false; bool update_will_break_save_states = false;
bool update_increases_settings_version = false;
for (const QJsonValue& commit : commits) for (const QJsonValue& commit : commits)
{ {
@ -274,6 +275,9 @@ void AutoUpdaterDialog::getChangesComplete(QNetworkReply* reply)
if (message.contains(QStringLiteral("[SAVEVERSION+]"))) if (message.contains(QStringLiteral("[SAVEVERSION+]")))
update_will_break_save_states = true; update_will_break_save_states = true;
if (message.contains(QStringLiteral("[SETTINGSVERSION+]")))
update_increases_settings_version = true;
} }
changes_html += "</ul>"; changes_html += "</ul>";
@ -285,6 +289,13 @@ void AutoUpdaterDialog::getChangesComplete(QNetworkReply* reply)
"before installing this update or you will lose progress.</p>")); "before installing this update or you will lose progress.</p>"));
} }
if (update_increases_settings_version)
{
changes_html.prepend(
tr("<h2>Settings Warning</h2><p>Installing this update will reset your program configuration. Please note "
"that you will have to reconfigure your settings after this update.</p>"));
}
changes_html += tr("<h4>Installing this update will download %1 MB through your internet connection.</h4>") changes_html += tr("<h4>Installing this update will download %1 MB through your internet connection.</h4>")
.arg(static_cast<double>(m_download_size) / 1000000.0, 0, 'f', 2); .arg(static_cast<double>(m_download_size) / 1000000.0, 0, 'f', 2);

View File

@ -55,6 +55,8 @@ int main(int argc, char* argv[])
window->startupUpdateCheck(); window->startupUpdateCheck();
} }
window->reportSettingsVersionMismatchString();
int result = app.exec(); int result = app.exec();
window.reset(); window.reset();

View File

@ -1088,6 +1088,13 @@ void MainWindow::startupUpdateCheck()
checkForUpdates(false); checkForUpdates(false);
} }
void MainWindow::reportSettingsVersionMismatchString()
{
const QString mismatch_str = QString::fromStdString(m_host_interface->GetSettingsVersionMismatchString());
if (!mismatch_str.isEmpty())
reportError(mismatch_str);
}
void MainWindow::updateDebugMenuVisibility() void MainWindow::updateDebugMenuVisibility()
{ {
const bool visible = m_host_interface->GetBoolSettingValue("Main", "ShowDebugMenu", false); const bool visible = m_host_interface->GetBoolSettingValue("Main", "ShowDebugMenu", false);

View File

@ -30,6 +30,10 @@ public:
/// Performs update check if enabled in settings. /// Performs update check if enabled in settings.
void startupUpdateCheck(); void startupUpdateCheck();
/// Reports m_host_interface's settings version mismatch string. Does nothing if string is empty (no settings version
/// mismatch detected).
void reportSettingsVersionMismatchString();
public Q_SLOTS: public Q_SLOTS:
/// Updates debug menu visibility (hides if disabled). /// Updates debug menu visibility (hides if disabled).
void updateDebugMenuVisibility(); void updateDebugMenuVisibility();

View File

@ -1995,8 +1995,10 @@ void CommonHostInterface::CheckSettings(SettingsInterface& si)
if (settings_version == SETTINGS_VERSION) if (settings_version == SETTINGS_VERSION)
return; return;
ReportFormattedError("Settings version %d does not match expected version %d, resetting", settings_version, m_settings_version_mismatch_str = StringUtil::StdStringFromFormat(
SETTINGS_VERSION); "Settings version %d does not match expected version %d, resetting", settings_version, SETTINGS_VERSION);
ReportError(m_settings_version_mismatch_str.c_str());
si.Clear(); si.Clear();
si.SetIntValue("Main", "SettingsVersion", SETTINGS_VERSION); si.SetIntValue("Main", "SettingsVersion", SETTINGS_VERSION);
SetDefaultSettings(si); SetDefaultSettings(si);
@ -2101,6 +2103,11 @@ void CommonHostInterface::CheckForSettingsChanges(const Settings& old_settings)
UpdateInputMap(); UpdateInputMap();
} }
const std::string& CommonHostInterface::GetSettingsVersionMismatchString() const
{
return m_settings_version_mismatch_str;
}
void CommonHostInterface::SetTimerResolutionIncreased(bool enabled) void CommonHostInterface::SetTimerResolutionIncreased(bool enabled)
{ {
if (m_timer_resolution_increased == enabled) if (m_timer_resolution_increased == enabled)

View File

@ -174,6 +174,10 @@ public:
/// Reloads post processing shaders with the current configuration. /// Reloads post processing shaders with the current configuration.
void ReloadPostProcessingShaders(); void ReloadPostProcessingShaders();
/// Returns an empty string if no settings version mismatch was detected, non-empty otherwise. Should not be called
/// before CheckSettings(SettingsInterface& si).
const std::string& GetSettingsVersionMismatchString() const;
protected: protected:
enum : u32 enum : u32
{ {
@ -371,6 +375,8 @@ private:
// running in batch mode? i.e. exit after stopping emulation // running in batch mode? i.e. exit after stopping emulation
bool m_batch_mode = false; bool m_batch_mode = false;
std::string m_settings_version_mismatch_str;
#ifdef WITH_DISCORD_PRESENCE #ifdef WITH_DISCORD_PRESENCE
// discord rich presence // discord rich presence
bool m_discord_presence_enabled = false; bool m_discord_presence_enabled = false;