From 6e28f4dae6dc415316faa424d70f11a66b078c3f Mon Sep 17 00:00:00 2001 From: spycrab Date: Sat, 20 May 2017 23:41:02 +0200 Subject: [PATCH] Qt: Implement analytics (+ prompt) --- Source/Core/DolphinQt2/Main.cpp | 36 +++++++++++++++++++++++++++++ Source/Core/DolphinQt2/Settings.cpp | 10 ++++++++ Source/Core/DolphinQt2/Settings.h | 2 ++ 3 files changed, 48 insertions(+) diff --git a/Source/Core/DolphinQt2/Main.cpp b/Source/Core/DolphinQt2/Main.cpp index 6b2186fa6d..f140564563 100644 --- a/Source/Core/DolphinQt2/Main.cpp +++ b/Source/Core/DolphinQt2/Main.cpp @@ -4,7 +4,10 @@ #include #include +#include +#include +#include "Core/Analytics.h" #include "Core/BootManager.h" #include "Core/Core.h" #include "DolphinQt2/Host.h" @@ -36,8 +39,41 @@ int main(int argc, char* argv[]) } if (!retval) { + DolphinAnalytics::Instance()->ReportDolphinStart("qt"); + MainWindow win; win.show(); + +#if defined(USE_ANALYTICS) && USE_ANALYTICS + if (!Settings().HasAskedForAnalyticsPermission()) + { + QMessageBox analytics_prompt(&win); + + analytics_prompt.setIcon(QMessageBox::Question); + analytics_prompt.setStandardButtons(QMessageBox::Yes | QMessageBox::No); + analytics_prompt.setText(QObject::tr( + "Do you authorize Dolphin to report this information to Dolphin's developers?")); + analytics_prompt.setInformativeText( + QObject::tr("If authorized, Dolphin can collect data on its performance, " + "feature usage, and configuration, as well as data on your system's " + "hardware and operating system.\n\n" + "No private data is ever collected. This data helps us understand " + "how people and emulated games use Dolphin and prioritize our " + "efforts. It also helps us identify rare configurations that are " + "causing bugs, performance and stability issues.\n" + "This authorization can be revoked at any time through Dolphin's " + "settings.\n\n")); + + const int answer = analytics_prompt.exec(); + + Settings().SetAskedForAnalyticsPermission(true); + Settings().SetAnalyticsEnabled(answer == QMessageBox::Yes); + Settings().Save(); + + DolphinAnalytics::Instance()->ReloadConfig(); + } +#endif + retval = app.exec(); } diff --git a/Source/Core/DolphinQt2/Settings.cpp b/Source/Core/DolphinQt2/Settings.cpp index 5488207e5f..45379f5e98 100644 --- a/Source/Core/DolphinQt2/Settings.cpp +++ b/Source/Core/DolphinQt2/Settings.cpp @@ -346,3 +346,13 @@ QVector Settings::GetProfiles(const InputConfig* config) const return vec; } + +bool Settings::HasAskedForAnalyticsPermission() const +{ + return SConfig::GetInstance().m_analytics_permission_asked; +} + +void Settings::SetAskedForAnalyticsPermission(bool value) +{ + SConfig::GetInstance().m_analytics_permission_asked = value; +} diff --git a/Source/Core/DolphinQt2/Settings.h b/Source/Core/DolphinQt2/Settings.h index 04a6ce39b1..dd94577f6d 100644 --- a/Source/Core/DolphinQt2/Settings.h +++ b/Source/Core/DolphinQt2/Settings.h @@ -62,6 +62,8 @@ public: void SetForceNTSCJ(bool val); // Analytics + bool HasAskedForAnalyticsPermission() const; + void SetAskedForAnalyticsPermission(bool value); bool GetAnalyticsEnabled() const; void SetAnalyticsEnabled(bool val);