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:
provider.addDataSource(new PlatformInfoSource, Provider::BasicSystemInformation);
provider.setStatisticsCollectionMode(Provider::NoStatistics);
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', "");
QCOMPARE(b.constData(), "{}");
}
......
......@@ -138,13 +138,13 @@ void ProviderPrivate::aboutToQuit()
store();
}
QByteArray ProviderPrivate::jsonData() const
QByteArray ProviderPrivate::jsonData(Provider::StatisticsCollectionMode mode) const
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
QJsonObject obj;
if (statisticsMode != Provider::NoStatistics) {
if (mode != Provider::NoStatistics) {
foreach (auto source, dataSources) {
if (statisticsMode < source->collectionMode())
if (mode < source->collectionMode())
continue;
const auto data = source->data();
if (data.canConvert<QVariantMap>())
......@@ -387,7 +387,7 @@ void Provider::submit()
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
request.setHeader(QNetworkRequest::UserAgentHeader, QStringLiteral("UserFeedback/") + QStringLiteral(USERFEEDBACK_VERSION));
#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()));
}
......
......@@ -127,7 +127,7 @@ private:
Q_PRIVATE_SLOT(d, void submitFinished())
Q_PRIVATE_SLOT(d, void emitShowEncouragementMessage())
// for UI
Q_PRIVATE_SLOT(d, QByteArray jsonData())
Q_PRIVATE_SLOT(d, QByteArray jsonData(UserFeedback::Provider::StatisticsCollectionMode))
// for testing
Q_PRIVATE_SLOT(d, void load())
Q_PRIVATE_SLOT(d, void store())
......@@ -135,4 +135,6 @@ private:
}
Q_DECLARE_METATYPE(UserFeedback::Provider::StatisticsCollectionMode)
#endif // USERFEEDBACK_PROVIDER_H
......@@ -45,7 +45,7 @@ public:
void aboutToQuit();
QByteArray jsonData() const;
QByteArray jsonData(Provider::StatisticsCollectionMode mode) const;
void scheduleNextSubmission();
void submitFinished();
......
......@@ -58,6 +58,7 @@ void FeedbackConfigDialog::setFeedbackProvider(UserFeedback::Provider* provider)
void FeedbackConfigDialog::accept()
{
auto p = d->ui->configWidget->feedbackProvider();
p->setStatisticsCollectionMode(d->ui->configWidget->statisticsCollectionMode());
p->setSurveyInterval(d->ui->configWidget->surveyInterval());
QDialog::accept();
}
......
......@@ -102,7 +102,6 @@ void FeedbackConfigWidgetPrivate::telemetrySliderChanged()
if (!provider)
return;
provider->setStatisticsCollectionMode(telemetryModeMap[ui->telemetrySlider->value()]);
if (!ui->rawTelemetryButton->isChecked()) {
auto detailsStr = QStringLiteral("<ul>");
......@@ -113,7 +112,7 @@ void FeedbackConfigWidgetPrivate::telemetrySliderChanged()
ui->telemetryDetails->setHtml(detailsStr + QStringLiteral("</ul>"));
} else {
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));
}
}
......
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