mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-04-30 15:15:41 -04:00
Qt: Simplify settings version check
This commit is contained in:
parent
74880ac047
commit
cb6502afa3
@ -55,8 +55,6 @@ int main(int argc, char* argv[])
|
|||||||
window->startupUpdateCheck();
|
window->startupUpdateCheck();
|
||||||
}
|
}
|
||||||
|
|
||||||
window->reportSettingsVersionMismatchString();
|
|
||||||
|
|
||||||
int result = app.exec();
|
int result = app.exec();
|
||||||
|
|
||||||
window.reset();
|
window.reset();
|
||||||
|
@ -1121,13 +1121,6 @@ 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);
|
||||||
|
@ -30,10 +30,6 @@ 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();
|
||||||
|
@ -680,8 +680,14 @@ void QtHostInterface::OnSystemStateSaved(bool global, s32 slot)
|
|||||||
void QtHostInterface::LoadSettings()
|
void QtHostInterface::LoadSettings()
|
||||||
{
|
{
|
||||||
m_settings_interface = std::make_unique<INISettingsInterface>(CommonHostInterface::GetSettingsFileName());
|
m_settings_interface = std::make_unique<INISettingsInterface>(CommonHostInterface::GetSettingsFileName());
|
||||||
|
Log::SetConsoleOutputParams(true);
|
||||||
|
|
||||||
|
if (!CommonHostInterface::CheckSettings(*m_settings_interface.get()))
|
||||||
|
{
|
||||||
|
QTimer::singleShot(1000,
|
||||||
|
[this]() { ReportError("Settings version mismatch, settings have been reset to defaults."); });
|
||||||
|
}
|
||||||
|
|
||||||
CommonHostInterface::CheckSettings(*m_settings_interface.get());
|
|
||||||
CommonHostInterface::LoadSettings(*m_settings_interface.get());
|
CommonHostInterface::LoadSettings(*m_settings_interface.get());
|
||||||
CommonHostInterface::FixIncompatibleSettings(false);
|
CommonHostInterface::FixIncompatibleSettings(false);
|
||||||
}
|
}
|
||||||
|
@ -47,10 +47,12 @@ public:
|
|||||||
bool Initialize() override;
|
bool Initialize() override;
|
||||||
void Shutdown() override;
|
void Shutdown() override;
|
||||||
|
|
||||||
|
public Q_SLOTS:
|
||||||
void ReportError(const char* message) override;
|
void ReportError(const char* message) override;
|
||||||
void ReportMessage(const char* message) override;
|
void ReportMessage(const char* message) override;
|
||||||
bool ConfirmMessage(const char* message) override;
|
bool ConfirmMessage(const char* message) override;
|
||||||
|
|
||||||
|
public:
|
||||||
/// Thread-safe settings access.
|
/// Thread-safe settings access.
|
||||||
std::string GetStringSettingValue(const char* section, const char* key, const char* default_value = "") override;
|
std::string GetStringSettingValue(const char* section, const char* key, const char* default_value = "") override;
|
||||||
bool GetBoolSettingValue(const char* section, const char* key, bool default_value = false) override;
|
bool GetBoolSettingValue(const char* section, const char* key, bool default_value = false) override;
|
||||||
|
@ -1989,19 +1989,19 @@ std::string CommonHostInterface::GetMostRecentResumeSaveStatePath() const
|
|||||||
return std::move(most_recent->FileName);
|
return std::move(most_recent->FileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommonHostInterface::CheckSettings(SettingsInterface& si)
|
bool CommonHostInterface::CheckSettings(SettingsInterface& si)
|
||||||
{
|
{
|
||||||
const int settings_version = si.GetIntValue("Main", "SettingsVersion", -1);
|
const int settings_version = si.GetIntValue("Main", "SettingsVersion", -1);
|
||||||
if (settings_version == SETTINGS_VERSION)
|
if (settings_version == SETTINGS_VERSION)
|
||||||
return;
|
return true;
|
||||||
|
|
||||||
m_settings_version_mismatch_str = StringUtil::StdStringFromFormat(
|
Log_ErrorPrintf("Settings version %d does not match expected version %d, resetting", settings_version,
|
||||||
"Settings version %d does not match expected version %d, resetting", settings_version, 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);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommonHostInterface::SetDefaultSettings(SettingsInterface& si)
|
void CommonHostInterface::SetDefaultSettings(SettingsInterface& si)
|
||||||
@ -2103,11 +2103,6 @@ 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)
|
||||||
|
@ -174,10 +174,6 @@ 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
|
||||||
{
|
{
|
||||||
@ -282,7 +278,7 @@ protected:
|
|||||||
std::string GetCheatFileName() const;
|
std::string GetCheatFileName() const;
|
||||||
|
|
||||||
/// Ensures the settings is valid and the correct version. If not, resets to defaults.
|
/// Ensures the settings is valid and the correct version. If not, resets to defaults.
|
||||||
void CheckSettings(SettingsInterface& si);
|
bool CheckSettings(SettingsInterface& si);
|
||||||
|
|
||||||
/// Restores all settings to defaults.
|
/// Restores all settings to defaults.
|
||||||
virtual void SetDefaultSettings(SettingsInterface& si) override;
|
virtual void SetDefaultSettings(SettingsInterface& si) override;
|
||||||
@ -375,8 +371,6 @@ 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;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user