summaryrefslogtreecommitdiffstats
path: root/qt-ui/usersurvey.cpp
blob: d9cee8ce8c2c8eff9389db4f367cc578578e04db (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <QShortcut>
#include <QMessageBox>
#include <QDebug>
#include <QSettings>

#include "usersurvey.h"
#include "ui_usersurvey.h"
#include "ssrf-version.h"

#include "helpers.h"
#include "subsurfacesysinfo.h"
UserSurvey::UserSurvey(QWidget *parent) : QDialog(parent),
	ui(new Ui::UserSurvey)
{
	ui->setupUi(this);
	// fill in the system data
	ui->system->append(tr("Operating System: %1").arg(SubsurfaceSysInfo::prettyOsName()));
	ui->system->append(tr("CPU Architecture: %1").arg(SubsurfaceSysInfo::cpuArchitecture()));
}

UserSurvey::~UserSurvey()
{
	delete ui;
}

void UserSurvey::on_buttonBox_accepted()
{
	// now we need to collect the data and submit it
	QSettings s;
	s.beginGroup("UserSurvey");
	s.setValue("SurveyDone", "submitted");
	hide();
}

void UserSurvey::on_buttonBox_rejected()
{
	QMessageBox response(this);
	response.setText(tr("Should we ask you later?"));
	response.addButton(tr("Don't ask me again"), QMessageBox::RejectRole);
	response.addButton(tr("Ask Later"), QMessageBox::AcceptRole);
	response.setWindowTitle(tr("Ask again?")); // Not displayed on MacOSX as described in Qt API
	response.setIcon(QMessageBox::Question);
	response.setWindowModality(Qt::WindowModal);
	switch (response.exec()) {
	case QDialog::Accepted:
		// nothing to do here, we'll just ask again the next time they start
		break;
	case QDialog::Rejected:
		QSettings s;
		s.beginGroup("UserSurvey");
		s.setValue("SurveyDone", "declined");
		break;
	}
	hide();
}