NOISSUE add analytics settings (enable/disable)
This commit is contained in:
@ -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
|
||||
{
|
||||
|
@ -162,6 +162,7 @@ private slots:
|
||||
|
||||
void controllerSucceeded();
|
||||
void controllerFailed(const QString & error);
|
||||
void analyticsSettingChanged(const Setting &setting, QVariant value);
|
||||
|
||||
private:
|
||||
void initLogger();
|
||||
|
@ -75,6 +75,11 @@ MultiMCPage::MultiMCPage(QWidget *parent) : QWidget(parent), ui(new Ui::MultiMCP
|
||||
{
|
||||
ui->updateSettingsBox->setHidden(true);
|
||||
}
|
||||
// Analytics
|
||||
if(BuildConfig.ANALYTICS_ID.isEmpty())
|
||||
{
|
||||
ui->tabWidget->removeTab(ui->tabWidget->indexOf(ui->analyticsTab));
|
||||
}
|
||||
connect(ui->fontSizeBox, SIGNAL(valueChanged(int)), SLOT(refreshFontPreview()));
|
||||
connect(ui->consoleFont, SIGNAL(currentFontChanged(QFont)), SLOT(refreshFontPreview()));
|
||||
}
|
||||
@ -346,6 +351,12 @@ void MultiMCPage::applySettings()
|
||||
s->set("InstSortMode", "Name");
|
||||
break;
|
||||
}
|
||||
|
||||
// Analytics
|
||||
if(!BuildConfig.ANALYTICS_ID.isEmpty())
|
||||
{
|
||||
s->set("Analytics", ui->analyticsCheck->isChecked());
|
||||
}
|
||||
}
|
||||
void MultiMCPage::loadSettings()
|
||||
{
|
||||
@ -467,6 +478,12 @@ void MultiMCPage::loadSettings()
|
||||
{
|
||||
ui->sortByNameBtn->setChecked(true);
|
||||
}
|
||||
|
||||
// Analytics
|
||||
if(!BuildConfig.ANALYTICS_ID.isEmpty())
|
||||
{
|
||||
ui->analyticsCheck->setChecked(s->get("Analytics").toBool());
|
||||
}
|
||||
}
|
||||
|
||||
void MultiMCPage::refreshFontPreview()
|
||||
|
@ -6,7 +6,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>487</width>
|
||||
<width>458</width>
|
||||
<height>614</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -31,6 +31,9 @@
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="toolTip">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="tabShape">
|
||||
<enum>QTabWidget::Rounded</enum>
|
||||
</property>
|
||||
@ -431,7 +434,7 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab">
|
||||
<widget class="QWidget" name="consoleTab">
|
||||
<attribute name="title">
|
||||
<string>Console</string>
|
||||
</attribute>
|
||||
@ -566,6 +569,69 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="analyticsTab">
|
||||
<attribute name="title">
|
||||
<string>Analytics</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_8">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="consoleSettingsBox_2">
|
||||
<property name="title">
|
||||
<string>Analytics Settings</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="analyticsCheck">
|
||||
<property name="text">
|
||||
<string>Send anonymous usage statistics?</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string><html><head/>
|
||||
<body>
|
||||
<p>MultiMC sends anonymous usage statistics on every start of the application.</p><p>The following data is collected:</p>
|
||||
<ul>
|
||||
<li>MultiMC version.</li>
|
||||
<li>Operating system name, version and architecture.</li>
|
||||
<li>CPU architecture (kernel architecture on linux).</li>
|
||||
<li>Size of system memory.</li>
|
||||
<li>Java version, architecture and memory settings.</li>
|
||||
</ul>
|
||||
</body></html></string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
Reference in New Issue
Block a user