Commit 37df09e8 authored by Volker Krause's avatar Volker Krause
Browse files

Expand the test application to allow manually overriding statistics.

parent 9936c700
......@@ -133,11 +133,11 @@ set(
# Actually build the stuff
#
add_subdirectory(provider)
add_subdirectory(server)
if(Qt5Widgets_FOUND AND NOT CMAKE_VERSION VERSION_LESS 3.0) # analyzer is Qt5 only and needs AUTOUIC support
add_subdirectory(analyzer)
add_subdirectory(tests/manual)
endif()
add_subdirectory(server)
add_subdirectory(tests/manual)
#
# CMake package config file generation
......
......@@ -64,6 +64,9 @@ private:
ProviderPrivate * const d;
Q_PRIVATE_SLOT(d, void aboutToQuit())
Q_PRIVATE_SLOT(d, void submitFinished())
// for testing
Q_PRIVATE_SLOT(d, void load())
Q_PRIVATE_SLOT(d, void store())
};
}
......
......@@ -15,14 +15,64 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "orwell.h"
#include "ui_orwell.h"
#include <provider/core/provider.h>
#include <provider/core/surveyinfo.h>
#include <QApplication>
#include <QDesktopServices>
#include <QPushButton>
#include <QVBoxLayout>
#include <QWidget>
#include <QSettings>
static std::unique_ptr<UserFeedback::Provider> provider; // TODO make this nicer
Orwell::Orwell(QWidget* parent) :
QMainWindow(parent),
ui(new Ui::Orwell)
{
ui->setupUi(this);
loadStats();
connect(ui->version, &QLineEdit::textChanged, this, [this]() {
QCoreApplication::setApplicationVersion(ui->version->text());
});
connect(ui->submitButton, &QPushButton::clicked, provider.get(), &UserFeedback::Provider::submit);
connect(ui->overrideButton, &QPushButton::clicked, this, [this] (){
writeStats();
QMetaObject::invokeMethod(provider.get(), "load");
loadStats();
});
connect(provider.get(), &UserFeedback::Provider::surveyAvailable, this, [](const UserFeedback::SurveyInfo &info) {
QDesktopServices::openUrl(info.url());
provider->setSurveyCompleted(info);
});
connect(ui->actionQuit, &QAction::triggered, qApp, &QCoreApplication::quit);
}
Orwell::~Orwell() = default;
void Orwell::loadStats()
{
ui->version->setText(QCoreApplication::applicationVersion());
QSettings settings;
ui->startCount->setValue(settings.value(QStringLiteral("UserFeedback/ApplicationStartCount")).toInt());
ui->runtime->setValue(settings.value(QStringLiteral("UserFeedback/ApplicationTime")).toInt());
ui->surveys->setText(settings.value(QStringLiteral("UserFeedback/CompletedSurveys")).toStringList().join(QStringLiteral(", ")));
}
void Orwell::writeStats()
{
QSettings settings;
settings.setValue(QStringLiteral("UserFeedback/ApplicationStartCount"), ui->startCount->value());
settings.setValue(QStringLiteral("UserFeedback/ApplicationTime"), ui->runtime->value());
settings.setValue(QStringLiteral("UserFeedback/CompletedSurveys"), ui->surveys->text().split(QStringLiteral(", ")));
}
int main(int argc, char** argv)
{
......@@ -33,25 +83,12 @@ int main(int argc, char** argv)
QApplication app(argc, argv);
UserFeedback::Provider provider;
provider.setProductIdentifier(QStringLiteral("org.kde.orwell"));
provider.setFeedbackServer(QUrl(QStringLiteral("https://feedback.volkerkrause.eu")));
QObject::connect(&provider, &UserFeedback::Provider::surveyAvailable, &app, [&provider](const UserFeedback::SurveyInfo &info) {
QDesktopServices::openUrl(info.url());
provider.setSurveyCompleted(info);
});
// TODO
QWidget top;
top.show();
auto topLayout = new QVBoxLayout;
top.setLayout(topLayout);
provider.reset(new UserFeedback::Provider);
provider->setProductIdentifier(QStringLiteral("org.kde.orwell"));
provider->setFeedbackServer(QUrl(QStringLiteral("https://feedback.volkerkrause.eu")));
auto submitButton = new QPushButton(QStringLiteral("Submit Manually"));
topLayout->addWidget(submitButton);
QObject::connect(submitButton, SIGNAL(clicked()), &provider, SLOT(submit()));
Orwell mainWindow;
mainWindow.show();
return app.exec();
}
#ifndef ORWELL_H
#define ORWELL_H
#include <QMainWindow>
#include <memory>
namespace Ui { class Orwell; }
class Orwell : public QMainWindow
{
public:
explicit Orwell(QWidget *parent = nullptr);
~Orwell();
private:
void loadStats();
void writeStats();
std::unique_ptr<Ui::Orwell> ui;
};
#endif
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Orwell</class>
<widget class="QMainWindow" name="Orwell">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>405</width>
<height>269</height>
</rect>
</property>
<property name="windowTitle">
<string>User Feedback Test Application</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Version:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="version"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Starts:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="startCount"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Runtime:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="runtime">
<property name="suffix">
<string>secs</string>
</property>
<property name="maximum">
<number>999999</number>
</property>
<property name="singleStep">
<number>60</number>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QPushButton" name="submitButton">
<property name="text">
<string>Submit Manually</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="surveys">
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Completed Surveys:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QPushButton" name="overrideButton">
<property name="text">
<string>Override Stats</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>405</width>
<height>30</height>
</rect>
</property>
<widget class="QMenu" name="menu_File">
<property name="title">
<string>&amp;File</string>
</property>
<addaction name="actionQuit"/>
</widget>
<addaction name="menu_File"/>
</widget>
<widget class="QStatusBar" name="statusbar"/>
<action name="actionQuit">
<property name="text">
<string>&amp;Quit</string>
</property>
</action>
</widget>
<resources/>
<connections/>
</ui>
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