Qt: Update analytics checkbox after initial prompt

This commit is contained in:
spycrab 2018-03-23 23:25:17 +01:00
parent cd4881d74b
commit 8ebb3a015e
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();
SConfig::GetInstance().m_analytics_permission_asked = true;
SConfig::GetInstance().m_analytics_enabled = (answer == QMessageBox::Yes);
Settings::Instance().SetAnalyticsEnabled(answer == QMessageBox::Yes);
DolphinAnalytics::Instance()->ReloadConfig();
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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());