diff --git a/Source/Core/DolphinQt2/Main.cpp b/Source/Core/DolphinQt2/Main.cpp index 46ea5fa353..4c615676b2 100644 --- a/Source/Core/DolphinQt2/Main.cpp +++ b/Source/Core/DolphinQt2/Main.cpp @@ -153,7 +153,7 @@ int main(int argc, char* argv[]) const int answer = analytics_prompt.exec(); SConfig::GetInstance().m_analytics_permission_asked = true; - SConfig::GetInstance().m_analytics_enabled = (answer == QMessageBox::Yes); + Settings::Instance().SetAnalyticsEnabled(answer == QMessageBox::Yes); DolphinAnalytics::Instance()->ReloadConfig(); } diff --git a/Source/Core/DolphinQt2/Settings.cpp b/Source/Core/DolphinQt2/Settings.cpp index ed2746888d..baa86879e8 100644 --- a/Source/Core/DolphinQt2/Settings.cpp +++ b/Source/Core/DolphinQt2/Settings.cpp @@ -335,3 +335,18 @@ QString Settings::GetAutoUpdateTrack() const { return QString::fromStdString(SConfig::GetInstance().m_auto_update_track); } + +void Settings::SetAnalyticsEnabled(bool enabled) +{ + if (enabled == IsAnalyticsEnabled()) + return; + + SConfig::GetInstance().m_analytics_enabled = enabled; + + emit AnalyticsToggled(enabled); +} + +bool Settings::IsAnalyticsEnabled() const +{ + return SConfig::GetInstance().m_analytics_enabled; +} diff --git a/Source/Core/DolphinQt2/Settings.h b/Source/Core/DolphinQt2/Settings.h index f96d8d67b5..b4e96b6e84 100644 --- a/Source/Core/DolphinQt2/Settings.h +++ b/Source/Core/DolphinQt2/Settings.h @@ -104,6 +104,10 @@ public: QString GetAutoUpdateTrack() const; void SetAutoUpdateTrack(const QString& mode); + // Analytics + bool IsAnalyticsEnabled() const; + void SetAnalyticsEnabled(bool enabled); + // Other GameListModel* GetGameListModel() const; signals: @@ -126,6 +130,7 @@ signals: void DebugModeToggled(bool enabled); void DebugFontChanged(QFont font); void AutoUpdateTrackChanged(const QString& mode); + void AnalyticsToggled(bool enabled); private: bool m_controller_state_needed = false; diff --git a/Source/Core/DolphinQt2/Settings/GeneralPane.cpp b/Source/Core/DolphinQt2/Settings/GeneralPane.cpp index 464fd07790..a7064f967d 100644 --- a/Source/Core/DolphinQt2/Settings/GeneralPane.cpp +++ b/Source/Core/DolphinQt2/Settings/GeneralPane.cpp @@ -82,6 +82,7 @@ void GeneralPane::ConnectLayout() connect(m_radio_jit, &QRadioButton::clicked, this, &GeneralPane::OnSaveConfig); #if defined(USE_ANALYTICS) && USE_ANALYTICS + connect(&Settings::Instance(), &Settings::AnalyticsToggled, this, &GeneralPane::LoadConfig); connect(m_checkbox_enable_analytics, &QCheckBox::clicked, this, &GeneralPane::OnSaveConfig); connect(m_button_generate_new_identity, &QPushButton::clicked, this, &GeneralPane::GenerateNewIdentity); @@ -191,7 +192,7 @@ void GeneralPane::LoadConfig() } #if defined(USE_ANALYTICS) && USE_ANALYTICS - m_checkbox_enable_analytics->setChecked(SConfig::GetInstance().m_analytics_enabled); + m_checkbox_enable_analytics->setChecked(Settings::Instance().IsAnalyticsEnabled()); #endif m_checkbox_dualcore->setChecked(SConfig::GetInstance().bCPUThread); m_checkbox_cheats->setChecked(Settings::Instance().GetCheatsEnabled()); @@ -251,7 +252,7 @@ void GeneralPane::OnSaveConfig() } #if defined(USE_ANALYTICS) && USE_ANALYTICS - SConfig::GetInstance().m_analytics_enabled = m_checkbox_enable_analytics->isChecked(); + Settings::Instance().SetAnalyticsEnabled(m_checkbox_enable_analytics->isChecked()); #endif SConfig::GetInstance().bCPUThread = m_checkbox_dualcore->isChecked(); Settings::Instance().SetCheatsEnabled(m_checkbox_cheats->isChecked());