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

Port feedback config dialog to the new config widget

parent ed9b040d
......@@ -329,10 +329,14 @@ Provider::StatisticsCollectionMode Provider::statisticsCollectionMode() const
void Provider::setStatisticsCollectionMode(StatisticsCollectionMode mode)
{
if (d->statisticsMode == mode)
return;
d->statisticsMode = mode;
d->scheduleNextSubmission();
d->scheduleEncouragement();
d->store();
emit statisticsCollectionModeChanged();
}
void Provider::addDataSource(AbstractDataSource *source, StatisticsCollectionMode mode)
......@@ -358,10 +362,14 @@ int Provider::surveyInterval() const
void Provider::setSurveyInterval(int days)
{
if (d->surveyInterval == days)
return;
d->surveyInterval = days;
d->scheduleNextSubmission();
d->scheduleEncouragement();
d->store();
emit surveyIntervalChanged();
}
void Provider::setApplicationStartsUntilEncouragement(int starts)
......
......@@ -34,6 +34,8 @@ class SurveyInfo;
class USERFEEDBACKCORE_EXPORT Provider : public QObject
{
Q_OBJECT
Q_PROPERTY(int surveyInterval READ surveyInterval WRITE setSurveyInterval NOTIFY surveyIntervalChanged)
Q_PROPERTY(StatisticsCollectionMode statisticsCollectionMode READ statisticsCollectionMode WRITE setStatisticsCollectionMode NOTIFY statisticsCollectionModeChanged)
public:
enum StatisticsCollectionMode {
NoStatistics,
......@@ -111,6 +113,12 @@ signals:
/** Indicate that the encouragement notice should be shown. */
void showEncouragementMessage();
/** Emitted when the survey interval changed. */
void surveyIntervalChanged();
/** Emitted when the statistics collection mode has changed. */
void statisticsCollectionModeChanged();
private:
friend class ProviderPrivate;
ProviderPrivate * const d;
......
......@@ -21,83 +21,49 @@
#include <provider/core/provider.h>
#include <QDebug>
#include <QDesktopServices>
#include <QPushButton>
#include <QUrl>
using namespace UserFeedback;
namespace UserFeedback {
class FeedbackConfigDialogPrivate {
public:
void updateButtonState();
std::unique_ptr<Ui::FeedbackConfigDialog> ui;
};
}
FeedbackConfigDialog::FeedbackConfigDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::FeedbackConfigDialog)
d(new FeedbackConfigDialogPrivate)
{
ui->setupUi(this);
ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Contribute!"));
ui->buttonBox->button(QDialogButtonBox::Close)->setText(tr("No, I do not want to contribute."));
connect(ui->basicStats, &QCheckBox::toggled, this, &FeedbackConfigDialog::updateButtonState);
connect(ui->advancedStats, &QCheckBox::toggled, this, &FeedbackConfigDialog::updateButtonState);
connect(ui->basicSurveys, &QCheckBox::toggled, this, &FeedbackConfigDialog::updateButtonState);
connect(ui->allSurveys, &QCheckBox::toggled, this, &FeedbackConfigDialog::updateButtonState);
connect(ui->introLabel, &QLabel::linkActivated, this, &FeedbackConfigDialog::linkActivated);
connect(ui->basicStatsLabel, &QLabel::linkActivated, this, &FeedbackConfigDialog::linkActivated);
connect(ui->advancedStatsLabel, &QLabel::linkActivated, this, &FeedbackConfigDialog::linkActivated);
connect(ui->basicSurveyLabel, &QLabel::linkActivated, this, &FeedbackConfigDialog::linkActivated);
connect(ui->allSurveyLabel, &QLabel::linkActivated, this, &FeedbackConfigDialog::linkActivated);
d->ui.reset(new Ui::FeedbackConfigDialog);
d->ui->setupUi(this);
d->ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Contribute!"));
d->ui->buttonBox->button(QDialogButtonBox::Close)->setText(tr("No, I do not want to contribute."));
}
FeedbackConfigDialog::~FeedbackConfigDialog() = default;
void FeedbackConfigDialog::setFeedbackProvider(UserFeedback::Provider* provider)
{
m_provider = provider;
ui->advancedStats->setChecked(m_provider->statisticsCollectionMode() == Provider::AllStatistics);
ui->basicStats->setChecked(m_provider->statisticsCollectionMode() != Provider::NoStatistics);
d->ui->configWidget->setFeedbackProvider(provider);
ui->allSurveys->setChecked(m_provider->surveyInterval() >= 0 && m_provider->surveyInterval() < 90);
ui->basicSurveys->setChecked(m_provider->surveyInterval() >= 90);
updateButtonState();
connect(provider, SIGNAL(surveyIntervalChanged()), this, SLOT(updateButtonState()));
connect(provider, SIGNAL(statisticsCollectionModeChanged()), this, SLOT(updateButtonState()));
d->updateButtonState();
}
void FeedbackConfigDialog::accept()
void FeedbackConfigDialogPrivate::updateButtonState()
{
if (!ui->basicStats->isChecked()) {
m_provider->setStatisticsCollectionMode(Provider::NoStatistics);
} else {
m_provider->setStatisticsCollectionMode(ui->advancedStats->isChecked() ? Provider::AllStatistics : Provider::BasicStatistics);
}
if (!ui->basicSurveys->isChecked()) {
m_provider->setSurveyInterval(-1);
} else {
m_provider->setSurveyInterval(ui->allSurveys->isChecked() ? 0 : 90);
}
if (!ui->configWidget->feedbackProvier())
return;
const auto any = ui->configWidget->feedbackProvier()->surveyInterval() >= 0
|| ui->configWidget->feedbackProvier()->statisticsCollectionMode() != Provider::NoStatistics;
// TODO store provider settings, to not lose this on a crash
QDialog::accept();
}
void FeedbackConfigDialog::linkActivated(const QString& link)
{
QDesktopServices::openUrl(QUrl(link));
}
void FeedbackConfigDialog::updateButtonState()
{
const auto advStats = ui->advancedStats->isChecked();
if (advStats)
ui->basicStats->setChecked(true);
ui->basicStats->setEnabled(!advStats);
const auto allSurveys = ui->allSurveys->isChecked();
if (allSurveys)
ui->basicSurveys->setChecked(true);
ui->basicSurveys->setEnabled(!allSurveys);
const auto any = ui->basicStats->isChecked() || ui->basicSurveys->isChecked();
ui->buttonBox->button(QDialogButtonBox::Ok)->setVisible(any);
ui->buttonBox->button(QDialogButtonBox::Close)->setVisible(!any);
}
#include "moc_feedbackconfigdialog.cpp"
......@@ -25,13 +25,9 @@
namespace UserFeedback {
class FeedbackConfigDialogPrivate;
class Provider;
namespace Ui
{
class FeedbackConfigDialog;
}
/** Configure which feedback a user wants to provide. */
class USERFEEDBACKWIDGETS_EXPORT FeedbackConfigDialog : public QDialog
{
......@@ -41,14 +37,10 @@ public:
~FeedbackConfigDialog();
void setFeedbackProvider(UserFeedback::Provider *provider);
void accept() override;
private:
void linkActivated(const QString &link);
void updateButtonState();
std::unique_ptr<Ui::FeedbackConfigDialog> ui;
UserFeedback::Provider *m_provider;
Q_PRIVATE_SLOT(d, void updateButtonState())
std::unique_ptr<FeedbackConfigDialogPrivate> d;
};
}
......
......@@ -15,87 +15,7 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="introLabel">
<property name="text">
<string>We make $APPLICATION for you, for free. Contribute to make it even better and more useful to you!&lt;br/&gt;
&lt;a href=&quot;https://feedback.volkerkrause.eu/feedback.html&quot;&gt;Learn more...&lt;/a&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="basicStats">
<property name="text">
<string>I'll contribute basic usage statistics!</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="basicStatsLabel">
<property name="text">
<string>This will automatically gather statistics on how often $APPLICATION is used, and sent this information to $VENDOR. No unique identification of you is included, nor any data your process with $APPLICATION. &lt;br/&gt;
&lt;a href=&quot;https://feedback.volkerkrause.eu/feedback.html#basic-stats&quot;&gt;Learn more...&lt;/a&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="advancedStats">
<property name="text">
<string>I'll contribute detailed usage statistics!</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="advancedStatsLabel">
<property name="text">
<string>This will automatically gather statistics on how often individual features of $APPLICATION are used, and send this information to $VENDOR. No unique identification of you is included, nor any data you process with $APPLICAITON. &lt;br/&gt;
&lt;a href=&quot;https://feedback.volkerkrause.eu/feedback.html#detailed-stats&quot;&gt;Learn more...&lt;/a&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="basicSurveys">
<property name="text">
<string>I'll participate occasionally in user surveys.</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="basicSurveyLabel">
<property name="text">
<string>This will ask you occasionally to participate in a web survey about aspects of $APPLICATION we are currently working on, not more than 4 times a year though.&lt;br/&gt;
&lt;a href=&quot;https://feedback.volkerkrause.eu/feedback.html#basic-surveys&quot;&gt;Learn more...&lt;/a&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="allSurveys">
<property name="text">
<string>I'll participate in user surveys whenever you have one!</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="allSurveyLabel">
<property name="text">
<string>This will offer you to participate in web surveys about $APPLICATION whenever we have questions for you. You of course will have the option to skip or defer those. &lt;br/&gt;
&lt;a href=&quot;https://feedback.volkerkrause.eu/feedback.html#all-surveys&quot;&gt;Learn more...&lt;/a&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
<widget class="UserFeedback::FeedbackConfigWidget" name="configWidget" native="true"/>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
......@@ -109,6 +29,14 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>UserFeedback::FeedbackConfigWidget</class>
<extends>QWidget</extends>
<header>feedbackconfigwidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
......
......@@ -95,6 +95,7 @@ void FeedbackConfigWidgetPrivate::telemetrySliderChanged()
if (!provider)
return;
provider->setStatisticsCollectionMode(telemetryModeMap[ui->telemetrySlider->value()]);
if (!ui->rawTelemetryButton->isChecked()) {
auto detailsStr = QStringLiteral("<ul>");
......@@ -108,8 +109,6 @@ void FeedbackConfigWidgetPrivate::telemetrySliderChanged()
QMetaObject::invokeMethod(provider, "jsonData", Q_RETURN_ARG(QByteArray, jsonData));
ui->telemetryDetails->setPlainText(QString::fromUtf8(jsonData));
}
provider->setStatisticsCollectionMode(telemetryModeMap[ui->telemetrySlider->value()]);
}
void FeedbackConfigWidgetPrivate::surveySliderChanged()
......@@ -179,7 +178,12 @@ FeedbackConfigWidget::~FeedbackConfigWidget()
{
}
void FeedbackConfigWidget::setFeedbackProvider(UserFeedback::Provider* provider)
Provider* FeedbackConfigWidget::feedbackProvier() const
{
return d->provider;
}
void FeedbackConfigWidget::setFeedbackProvider(Provider* provider)
{
d->provider = provider;
if (!provider) {
......
......@@ -41,8 +41,11 @@ public:
explicit FeedbackConfigWidget(QWidget *parent = nullptr);
~FeedbackConfigWidget();
/** Returns the feedback provider configured by this widget. */
Provider* feedbackProvier() const;
/** Set the feedback provider that should be configured with this widget. */
void setFeedbackProvider(UserFeedback::Provider *provider);
void setFeedbackProvider(Provider *provider);
protected:
bool eventFilter(QObject *receiver, QEvent *event) override;
......
set(server_top_srcs
feedback.html
)
set(server_analytics_srcs
analytics/index.php
analytics/.htaccess
......@@ -41,7 +37,6 @@ php_lint(${server_receiver_srcs})
if (SERVER_DEPLOY_DESTINATION)
add_custom_target(deploy
COMMAND scp ${server_top_srcs} ${SERVER_DEPLOY_DESTINATION}/
COMMAND scp ${server_analytics_srcs} ${SERVER_DEPLOY_DESTINATION}/analytics
COMMAND scp ${server_config_srcs} ${SERVER_DEPLOY_DESTINATION}/config
COMMAND scp ${server_receiver_srcs} ${SERVER_DEPLOY_DESTINATION}/receiver
......
<html>
<body>
<h1>Contribute to making free software better!</h1>
<h2>Why do we need your help?</h2>
<p>yada yada yada</p>
<h2>Usage Statistics</h>
<p>yada yada yada</p>
<h3 id="basic-stats">Basic Usage Statistics</h3>
<p>yada yada yada</p>
<p><ul>
<li>How often was the application started?</li>
<li>How long was the application used?</li>
<li>Which version of the application is being used?</li>
<li>On which platform is the application being used?</li>
</ul></p>
<p>The data sent to us is entirely anonymous, there is no unique identifier in any form included. And of coure no data or content you are working with inside the application is included either.</p>
<h3 id="detailed-stats">Detailed Usage Statistics</h3>
<p>yada yada yada</p>
<p><ul>
<li>Includes everying listed in <a href="#basic-stats">basic usage statistics</a>.
<li>Which features of the application are used how often?</li>
</ul></p>
<p>The data sent to us is entirely anonymous, there is no unique identifier in any form included. And of coure no data or content you are working with inside the application is included either.</p>
<a id="basic-surveys"></a>
<a id="all-surveys"></a>
<h2>User Surveys</h2>
<p>yada yada yada</p>
</body>
</html>
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