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

Don't change the survey interval until explicitly confirming the dialog

The same fix is still needed for the telemetry settings.
parent 04dbb0ca
/*
Copyright (C) 2017 Volker Krause <vkrause@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <provider/widgets/feedbackconfigwidget.h>
#include <provider/core/platforminfosource.h>
#include <provider/core/provider.h>
......@@ -40,6 +57,7 @@ private slots:
QCOMPARE(telemetrySlider->value(), 0);
telemetrySlider->setValue(1);
QCOMPARE(w.statisticsCollectionMode(), Provider::BasicSystemInformation);
QTest::qWait(1);
QCOMPARE(p.statisticsCollectionMode(), Provider::NoStatistics);
}
......@@ -62,10 +80,12 @@ private slots:
QCOMPARE(slider->value(), 0);
slider->setValue(1);
QCOMPARE(w.surveyInterval(), 90);
QTest::qWait(1);
QCOMPARE(p.surveyInterval(), -1);
slider->setValue(2);
QCOMPARE(w.surveyInterval(), 0);
QTest::qWait(1);
QCOMPARE(p.surveyInterval(), -1);
}
......
......@@ -55,12 +55,19 @@ void FeedbackConfigDialog::setFeedbackProvider(UserFeedback::Provider* provider)
d->updateButtonState();
}
void FeedbackConfigDialog::accept()
{
auto p = d->ui->configWidget->feedbackProvider();
p->setSurveyInterval(d->ui->configWidget->surveyInterval());
QDialog::accept();
}
void FeedbackConfigDialogPrivate::updateButtonState()
{
if (!ui->configWidget->feedbackProvier())
if (!ui->configWidget->feedbackProvider())
return;
const auto any = ui->configWidget->feedbackProvier()->surveyInterval() >= 0
|| ui->configWidget->feedbackProvier()->statisticsCollectionMode() != Provider::NoStatistics;
const auto any = ui->configWidget->feedbackProvider()->surveyInterval() >= 0
|| ui->configWidget->feedbackProvider()->statisticsCollectionMode() != Provider::NoStatistics;
ui->buttonBox->button(QDialogButtonBox::Ok)->setVisible(any);
ui->buttonBox->button(QDialogButtonBox::Close)->setVisible(!any);
......
......@@ -38,6 +38,8 @@ public:
void setFeedbackProvider(UserFeedback::Provider *provider);
void accept() override;
private:
Q_PRIVATE_SLOT(d, void updateButtonState())
std::unique_ptr<FeedbackConfigDialogPrivate> d;
......
......@@ -129,19 +129,16 @@ void FeedbackConfigWidgetPrivate::surveySliderChanged()
"We make this application for you. In order to ensure it actually does what you need it to do we "
"would like to ask you about your use cases and your feedback, in the form of a web survey."
));
provider->setSurveyInterval(-1);
break;
case 1:
ui->surveyLabel->setText(FeedbackConfigWidget::tr(
"I will occasionally participate in web surveys about the application, not more than four times a year though."
));
provider->setSurveyInterval(90);
break;
case 2:
ui->surveyLabel->setText(FeedbackConfigWidget::tr(
"I will participate in web surveys whenever one is available. Surveys can of course be defered or skipped."
));
provider->setSurveyInterval(0);
break;
}
......@@ -188,7 +185,7 @@ FeedbackConfigWidget::~FeedbackConfigWidget()
{
}
Provider* FeedbackConfigWidget::feedbackProvier() const
Provider* FeedbackConfigWidget::feedbackProvider() const
{
return d->provider;
}
......@@ -254,4 +251,19 @@ bool FeedbackConfigWidget::eventFilter(QObject* receiver, QEvent* event)
return QWidget::eventFilter(receiver, event);
}
Provider::StatisticsCollectionMode FeedbackConfigWidget::statisticsCollectionMode() const
{
return d->telemetryModeMap[d->ui->telemetrySlider->value()];
}
int FeedbackConfigWidget::surveyInterval() const
{
switch (d->ui->surveySlider->value()) {
case 0: return -1;
case 1: return 90;
case 2: return 0;
}
return -1;
}
#include "moc_feedbackconfigwidget.cpp"
......@@ -20,6 +20,8 @@
#include "userfeedbackwidgets_export.h"
#include "../core/provider.h"
#include <QWidget>
#include <memory>
......@@ -42,11 +44,16 @@ public:
~FeedbackConfigWidget();
/** Returns the feedback provider configured by this widget. */
Provider* feedbackProvier() const;
Provider* feedbackProvider() const;
/** Set the feedback provider that should be configured with this widget. */
void setFeedbackProvider(Provider *provider);
/** Returns the telemetry level currently selected in the widget. */
Provider::StatisticsCollectionMode statisticsCollectionMode() const;
/** Returns the survey interval currently selected in this widget. */
int surveyInterval() const;
protected:
bool eventFilter(QObject *receiver, QEvent *event) override;
......
......@@ -15,7 +15,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <provider/widgets/feedbackconfigwidget.h>
#include <provider/widgets/feedbackconfigdialog.h>
#include <provider/core/applicationversionsource.h>
#include <provider/core/platforminfosource.h>
......@@ -45,7 +45,7 @@ int main(int argc, char **argv)
provider.addDataSource(new ScreenInfoSource, Provider::DetailedSystemInformation);
provider.addDataSource(new QtVersionSource, Provider::DetailedSystemInformation);
FeedbackConfigWidget w;
FeedbackConfigDialog w;
w.setFeedbackProvider(&provider);
w.show();
return app.exec();
......
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