Merge pull request #6507 from spycrab/qt_analytics_fix

Qt: Update analytics checkbox after initial prompt
This commit is contained in:
Anthony 2018-03-23 15:38:19 -07:00 committed by GitHub
commit 41787261b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 3 deletions

View File

@ -153,7 +153,7 @@ int main(int argc, char* argv[])
const int answer = analytics_prompt.exec(); const int answer = analytics_prompt.exec();
SConfig::GetInstance().m_analytics_permission_asked = true; SConfig::GetInstance().m_analytics_permission_asked = true;
SConfig::GetInstance().m_analytics_enabled = (answer == QMessageBox::Yes); Settings::Instance().SetAnalyticsEnabled(answer == QMessageBox::Yes);
DolphinAnalytics::Instance()->ReloadConfig(); DolphinAnalytics::Instance()->ReloadConfig();
} }

View File

@ -335,3 +335,18 @@ QString Settings::GetAutoUpdateTrack() const
{ {
return QString::fromStdString(SConfig::GetInstance().m_auto_update_track); 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;
}

View File

@ -104,6 +104,10 @@ public:
QString GetAutoUpdateTrack() const; QString GetAutoUpdateTrack() const;
void SetAutoUpdateTrack(const QString& mode); void SetAutoUpdateTrack(const QString& mode);
// Analytics
bool IsAnalyticsEnabled() const;
void SetAnalyticsEnabled(bool enabled);
// Other // Other
GameListModel* GetGameListModel() const; GameListModel* GetGameListModel() const;
signals: signals:
@ -126,6 +130,7 @@ signals:
void DebugModeToggled(bool enabled); void DebugModeToggled(bool enabled);
void DebugFontChanged(QFont font); void DebugFontChanged(QFont font);
void AutoUpdateTrackChanged(const QString& mode); void AutoUpdateTrackChanged(const QString& mode);
void AnalyticsToggled(bool enabled);
private: private:
bool m_controller_state_needed = false; bool m_controller_state_needed = false;

View File

@ -82,6 +82,7 @@ void GeneralPane::ConnectLayout()
connect(m_radio_jit, &QRadioButton::clicked, this, &GeneralPane::OnSaveConfig); connect(m_radio_jit, &QRadioButton::clicked, this, &GeneralPane::OnSaveConfig);
#if defined(USE_ANALYTICS) && USE_ANALYTICS #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_checkbox_enable_analytics, &QCheckBox::clicked, this, &GeneralPane::OnSaveConfig);
connect(m_button_generate_new_identity, &QPushButton::clicked, this, connect(m_button_generate_new_identity, &QPushButton::clicked, this,
&GeneralPane::GenerateNewIdentity); &GeneralPane::GenerateNewIdentity);
@ -191,7 +192,7 @@ void GeneralPane::LoadConfig()
} }
#if defined(USE_ANALYTICS) && USE_ANALYTICS #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 #endif
m_checkbox_dualcore->setChecked(SConfig::GetInstance().bCPUThread); m_checkbox_dualcore->setChecked(SConfig::GetInstance().bCPUThread);
m_checkbox_cheats->setChecked(Settings::Instance().GetCheatsEnabled()); m_checkbox_cheats->setChecked(Settings::Instance().GetCheatsEnabled());
@ -251,7 +252,7 @@ void GeneralPane::OnSaveConfig()
} }
#if defined(USE_ANALYTICS) && USE_ANALYTICS #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 #endif
SConfig::GetInstance().bCPUThread = m_checkbox_dualcore->isChecked(); SConfig::GetInstance().bCPUThread = m_checkbox_dualcore->isChecked();
Settings::Instance().SetCheatsEnabled(m_checkbox_cheats->isChecked()); Settings::Instance().SetCheatsEnabled(m_checkbox_cheats->isChecked());