Commit dbb5c288 authored by Volker Krause's avatar Volker Krause
Browse files

Also don't change the telemetry settings until explicitly confirming them

parent b5fe5fb9
...@@ -134,7 +134,7 @@ private slots: ...@@ -134,7 +134,7 @@ private slots:
provider.addDataSource(new PlatformInfoSource, Provider::BasicSystemInformation); provider.addDataSource(new PlatformInfoSource, Provider::BasicSystemInformation);
provider.setStatisticsCollectionMode(Provider::NoStatistics); provider.setStatisticsCollectionMode(Provider::NoStatistics);
QByteArray b; QByteArray b;
QMetaObject::invokeMethod(&provider, "jsonData", Q_RETURN_ARG(QByteArray, b)); QMetaObject::invokeMethod(&provider, "jsonData", Q_RETURN_ARG(QByteArray, b), Q_ARG(UserFeedback::Provider::StatisticsCollectionMode, provider.statisticsCollectionMode()));
b.replace('\n', ""); b.replace('\n', "");
QCOMPARE(b.constData(), "{}"); QCOMPARE(b.constData(), "{}");
} }
......
...@@ -138,13 +138,13 @@ void ProviderPrivate::aboutToQuit() ...@@ -138,13 +138,13 @@ void ProviderPrivate::aboutToQuit()
store(); store();
} }
QByteArray ProviderPrivate::jsonData() const QByteArray ProviderPrivate::jsonData(Provider::StatisticsCollectionMode mode) const
{ {
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
QJsonObject obj; QJsonObject obj;
if (statisticsMode != Provider::NoStatistics) { if (mode != Provider::NoStatistics) {
foreach (auto source, dataSources) { foreach (auto source, dataSources) {
if (statisticsMode < source->collectionMode()) if (mode < source->collectionMode())
continue; continue;
const auto data = source->data(); const auto data = source->data();
if (data.canConvert<QVariantMap>()) if (data.canConvert<QVariantMap>())
...@@ -387,7 +387,7 @@ void Provider::submit() ...@@ -387,7 +387,7 @@ void Provider::submit()
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
request.setHeader(QNetworkRequest::UserAgentHeader, QStringLiteral("UserFeedback/") + QStringLiteral(USERFEEDBACK_VERSION)); request.setHeader(QNetworkRequest::UserAgentHeader, QStringLiteral("UserFeedback/") + QStringLiteral(USERFEEDBACK_VERSION));
#endif #endif
auto reply = d->networkAccessManager->post(request, d->jsonData()); auto reply = d->networkAccessManager->post(request, d->jsonData(d->statisticsMode));
connect(reply, SIGNAL(finished()), this, SLOT(submitFinished())); connect(reply, SIGNAL(finished()), this, SLOT(submitFinished()));
} }
......
...@@ -127,7 +127,7 @@ private: ...@@ -127,7 +127,7 @@ private:
Q_PRIVATE_SLOT(d, void submitFinished()) Q_PRIVATE_SLOT(d, void submitFinished())
Q_PRIVATE_SLOT(d, void emitShowEncouragementMessage()) Q_PRIVATE_SLOT(d, void emitShowEncouragementMessage())
// for UI // for UI
Q_PRIVATE_SLOT(d, QByteArray jsonData()) Q_PRIVATE_SLOT(d, QByteArray jsonData(UserFeedback::Provider::StatisticsCollectionMode))
// for testing // for testing
Q_PRIVATE_SLOT(d, void load()) Q_PRIVATE_SLOT(d, void load())
Q_PRIVATE_SLOT(d, void store()) Q_PRIVATE_SLOT(d, void store())
...@@ -135,4 +135,6 @@ private: ...@@ -135,4 +135,6 @@ private:
} }
Q_DECLARE_METATYPE(UserFeedback::Provider::StatisticsCollectionMode)
#endif // USERFEEDBACK_PROVIDER_H #endif // USERFEEDBACK_PROVIDER_H
...@@ -45,7 +45,7 @@ public: ...@@ -45,7 +45,7 @@ public:
void aboutToQuit(); void aboutToQuit();
QByteArray jsonData() const; QByteArray jsonData(Provider::StatisticsCollectionMode mode) const;
void scheduleNextSubmission(); void scheduleNextSubmission();
void submitFinished(); void submitFinished();
......
...@@ -58,6 +58,7 @@ void FeedbackConfigDialog::setFeedbackProvider(UserFeedback::Provider* provider) ...@@ -58,6 +58,7 @@ void FeedbackConfigDialog::setFeedbackProvider(UserFeedback::Provider* provider)
void FeedbackConfigDialog::accept() void FeedbackConfigDialog::accept()
{ {
auto p = d->ui->configWidget->feedbackProvider(); auto p = d->ui->configWidget->feedbackProvider();
p->setStatisticsCollectionMode(d->ui->configWidget->statisticsCollectionMode());
p->setSurveyInterval(d->ui->configWidget->surveyInterval()); p->setSurveyInterval(d->ui->configWidget->surveyInterval());
QDialog::accept(); QDialog::accept();
} }
......
...@@ -102,7 +102,6 @@ void FeedbackConfigWidgetPrivate::telemetrySliderChanged() ...@@ -102,7 +102,6 @@ void FeedbackConfigWidgetPrivate::telemetrySliderChanged()
if (!provider) if (!provider)
return; return;
provider->setStatisticsCollectionMode(telemetryModeMap[ui->telemetrySlider->value()]);
if (!ui->rawTelemetryButton->isChecked()) { if (!ui->rawTelemetryButton->isChecked()) {
auto detailsStr = QStringLiteral("<ul>"); auto detailsStr = QStringLiteral("<ul>");
...@@ -113,7 +112,7 @@ void FeedbackConfigWidgetPrivate::telemetrySliderChanged() ...@@ -113,7 +112,7 @@ void FeedbackConfigWidgetPrivate::telemetrySliderChanged()
ui->telemetryDetails->setHtml(detailsStr + QStringLiteral("</ul>")); ui->telemetryDetails->setHtml(detailsStr + QStringLiteral("</ul>"));
} else { } else {
QByteArray jsonData; QByteArray jsonData;
QMetaObject::invokeMethod(provider, "jsonData", Q_RETURN_ARG(QByteArray, jsonData)); QMetaObject::invokeMethod(provider, "jsonData", Q_RETURN_ARG(QByteArray, jsonData), Q_ARG(UserFeedback::Provider::StatisticsCollectionMode, telemetryModeMap[ui->telemetrySlider->value()]));
ui->telemetryDetails->setPlainText(QString::fromUtf8(jsonData)); ui->telemetryDetails->setPlainText(QString::fromUtf8(jsonData));
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment