summaryrefslogtreecommitdiffstats
path: root/application/MultiMC.cpp
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2016-11-24 04:10:07 +0100
committerPetr Mrázek <peterix@gmail.com>2016-11-24 04:10:07 +0100
commit121e2fd46ca109e6aadef0924f8ef9fcd1931bc3 (patch)
treebe7e17ddbc72c58f471b7dd10a0729a140c50119 /application/MultiMC.cpp
parent295c6e808ab15c8f10326d375c7c4cdd80531e5f (diff)
downloadMultiMC-121e2fd46ca109e6aadef0924f8ef9fcd1931bc3.tar
MultiMC-121e2fd46ca109e6aadef0924f8ef9fcd1931bc3.tar.gz
MultiMC-121e2fd46ca109e6aadef0924f8ef9fcd1931bc3.tar.lz
MultiMC-121e2fd46ca109e6aadef0924f8ef9fcd1931bc3.tar.xz
MultiMC-121e2fd46ca109e6aadef0924f8ef9fcd1931bc3.zip
NOISSUE add analytics settings (enable/disable)
Diffstat (limited to 'application/MultiMC.cpp')
-rw-r--r--application/MultiMC.cpp44
1 files changed, 33 insertions, 11 deletions
diff --git a/application/MultiMC.cpp b/application/MultiMC.cpp
index 2a903437..83bb731d 100644
--- a/application/MultiMC.cpp
+++ b/application/MultiMC.cpp
@@ -513,14 +513,11 @@ void MultiMC::initAnalytics()
{
if(BuildConfig.ANALYTICS_ID.isEmpty())
{
- qDebug() << "Analytics disabled by build.";
- return;
- }
- if(!m_settings->get("Analytics").toBool())
- {
- qDebug() << "Analytics disabled by user.";
return;
}
+
+ auto analyticsSetting = m_settings->getSetting("Analytics");
+ connect(analyticsSetting.get(), &Setting::SettingChanged, this, &MultiMC::analyticsSettingChanged);
QString clientID = m_settings->get("AnalyticsClientID").toString();
if(clientID.isEmpty())
{
@@ -533,9 +530,15 @@ void MultiMC::initAnalytics()
m_analytics->setLogLevel(GAnalytics::Debug);
m_analytics->setAnonymizeIPs(true);
m_analytics->setNetworkAccessManager(&ENV.qnam());
- m_analytics->startSending();
+
+ if(!m_settings->get("Analytics").toBool())
+ {
+ qDebug() << "Analytics disabled by user.";
+ return;
+ }
+
+ m_analytics->enable();
qDebug() << "Initialized analytics with tid" << BuildConfig.ANALYTICS_ID << "and cid" << clientID;
- // TODO: load unsent messages?
}
void MultiMC::shutdownAnalytics()
@@ -546,6 +549,22 @@ void MultiMC::shutdownAnalytics()
}
}
+void MultiMC::analyticsSettingChanged(const Setting&, QVariant value)
+{
+ if(!m_analytics)
+ return;
+ bool enabled = value.toBool();
+ if(enabled)
+ {
+ qDebug() << "Analytics enabled by user.";
+ }
+ else
+ {
+ qDebug() << "Analytics disabled by user.";
+ }
+ m_analytics->enable(enabled);
+}
+
void MultiMC::initInstances()
{
auto InstDirSetting = m_settings->getSetting("InstanceDir");
@@ -703,9 +722,12 @@ void MultiMC::initGlobalSettings()
// paste.ee API key
m_settings->registerSetting("PasteEEAPIKey", "multimc");
- // Analytics
- m_settings->registerSetting("Analytics", true);
- m_settings->registerSetting("AnalyticsClientID", QString());
+ if(!BuildConfig.ANALYTICS_ID.isEmpty())
+ {
+ // Analytics
+ m_settings->registerSetting("Analytics", true);
+ m_settings->registerSetting("AnalyticsClientID", QString());
+ }
// Init page provider
{