From cdd3b3d9cd5439cd56fb752e56a72045bed55f90 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Fri, 13 Jun 2014 10:56:46 -0700 Subject: Start a user survey dialog The idea is that a week after the user starts using Subsurface we ask them if they would like to submit a survey response. If you are running a development build, don't wait seven days. This patch doesn't do anything with the user's selections, doesn't submit anything to our server, etc. It's just a placeholder to tune what we should ask, etc. Signed-off-by: Dirk Hohndel --- qt-ui/mainwindow.cpp | 27 ++++++- qt-ui/mainwindow.h | 2 + qt-ui/usersurvey.cpp | 53 +++++++++++++ qt-ui/usersurvey.h | 25 ++++++ qt-ui/usersurvey.ui | 209 +++++++++++++++++++++++++++++++++++++++++++++++++++ subsurface.pro | 9 ++- 6 files changed, 320 insertions(+), 5 deletions(-) create mode 100644 qt-ui/usersurvey.cpp create mode 100644 qt-ui/usersurvey.h create mode 100644 qt-ui/usersurvey.ui diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 676ca3ab7..da1a1cd54 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -24,7 +24,7 @@ #include #include "divelistview.h" #include "starwidget.h" - +#include "ssrf-version.h" #include "dive.h" #include "display.h" #include "divelist.h" @@ -47,6 +47,7 @@ #endif #include "divelogimportdialog.h" #include "divelogexportdialog.h" +#include "usersurvey.h" #ifndef NO_USERMANUAL #include "usermanual.h" #endif @@ -61,7 +62,8 @@ MainWindow::MainWindow() : QMainWindow(), yearlyStatsModel(0), state(VIEWALL), updateManager(0), - fakeDiveId(0) + fakeDiveId(0), + survey(0) { Q_ASSERT_X(m_Instance == NULL, "MainWindow", "MainWindow recreated!"); m_Instance = this; @@ -814,10 +816,31 @@ void MainWindow::readSettings() default_dive_computer_device = getSetting(s, "dive_computer_device"); s.endGroup(); loadRecentFiles(&s); + checkSurvey(&s); } #undef TOOLBOX_PREF_BUTTON +void MainWindow::checkSurvey(QSettings *s) +{ + s->beginGroup("UserSurvey"); + if (!s->contains("FirstUse42")) { + QVariant value = QDate().currentDate(); + s->setValue("FirstUse42", value); + } else { + // wait a week for production versions, but not at all for non-tagged builds + QString ver(VERSION_STRING); + int waitTime = ver.contains('-') ? -1 : 7; + QDate firstUse42 = s->value("FirstUse42").toDate(); + if (firstUse42.daysTo(QDate().currentDate()) > waitTime && !s->contains("SurveyDone")) { + if (!survey) + survey = new UserSurvey(this); + survey->show(); + } + } + s->endGroup(); +} + void MainWindow::writeSettings() { QSettings settings; diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h index 828c628d7..cfac072d2 100644 --- a/qt-ui/mainwindow.h +++ b/qt-ui/mainwindow.h @@ -79,6 +79,7 @@ public: bool filesFromCommandLine() const; void setPlanNotes(const char *notes); void printPlan(); + void checkSurvey(QSettings *s); private slots: /* file menu action */ @@ -184,6 +185,7 @@ private: bool plannerStateClean(); void createFakeDiveForAddAndPlan(); int fakeDiveId; + QDialog *survey; }; #endif // MAINWINDOW_H diff --git a/qt-ui/usersurvey.cpp b/qt-ui/usersurvey.cpp new file mode 100644 index 000000000..7da7b3cdb --- /dev/null +++ b/qt-ui/usersurvey.cpp @@ -0,0 +1,53 @@ +#include +#include +#include +#include + +#include "usersurvey.h" +#include "ui_usersurvey.h" +#include "ssrf-version.h" + +#include "helpers.h" + +UserSurvey::UserSurvey(QWidget *parent) : QDialog(parent), + ui(new Ui::UserSurvey) +{ + ui->setupUi(this); + // fill in the system data +} + +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(); +} diff --git a/qt-ui/usersurvey.h b/qt-ui/usersurvey.h new file mode 100644 index 000000000..e1663c7e0 --- /dev/null +++ b/qt-ui/usersurvey.h @@ -0,0 +1,25 @@ +#ifndef USERSURVEY_H +#define USERSURVEY_H + +#include + +namespace Ui { + class UserSurvey; +} + +class UserSurvey : public QDialog { + Q_OBJECT + +public: + explicit UserSurvey(QWidget *parent = 0); + ~UserSurvey(); + +private +slots: + void on_buttonBox_accepted(); + void on_buttonBox_rejected(); + +private: + Ui::UserSurvey *ui; +}; +#endif // USERSURVEY_H diff --git a/qt-ui/usersurvey.ui b/qt-ui/usersurvey.ui new file mode 100644 index 000000000..436ec9079 --- /dev/null +++ b/qt-ui/usersurvey.ui @@ -0,0 +1,209 @@ + + + UserSurvey + + + + 0 + 0 + 410 + 524 + + + + Dialog + + + + + 40 + 490 + 341 + 32 + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Save + + + + + + 10 + 10 + 381 + 16 + + + + + 11 + + + + Subsurface User Survey + + + + + + 10 + 40 + 371 + 81 + + + + We would love to learn more about our users, their preferences and their usage habits. Please take a minute to fill out this form and submit it to the Subsurface team. Please select all options that apply to you. + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + 10 + 140 + 151 + 20 + + + + Recreational DIver + + + + + + 160 + 140 + 151 + 20 + + + + Tech Diver + + + + + + 10 + 160 + 211 + 20 + + + + Interested in dive planning + + + + + + 10 + 180 + 371 + 20 + + + + I am downloading dives from supported dive computer + + + + + + 10 + 200 + 371 + 20 + + + + I am importing dives from other software / sources + + + + + + 10 + 220 + 371 + 20 + + + + I am manually entering dives + + + + + + 10 + 270 + 371 + 101 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Suggestions and missing features</p></body></html> + + + + + + 10 + 240 + 381 + 20 + + + + I use the Android companion app to track dive locations + + + + + + 10 + 380 + 371 + 101 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Filled with some preferences (language, units, etc) plus system data (OS detailed version)</p></body></html> + + + + + recreational + tech + planning + download + import_2 + manual + companion + suggestions + system + buttonBox + + + + diff --git a/subsurface.pro b/subsurface.pro index d5ded8472..8245f75d4 100644 --- a/subsurface.pro +++ b/subsurface.pro @@ -81,7 +81,8 @@ HEADERS = \ qt-ui/profile/divetooltipitem.h \ qt-ui/profile/ruleritem.h \ qt-ui/updatemanager.h \ - qt-ui/divelogexportdialog.h + qt-ui/divelogexportdialog.h \ + qt-ui/usersurvey.h android: HEADERS -= \ qt-ui/usermanual.h \ @@ -158,7 +159,8 @@ SOURCES = \ qt-ui/profile/divetooltipitem.cpp \ qt-ui/profile/ruleritem.cpp \ qt-ui/updatemanager.cpp \ - qt-ui/divelogexportdialog.cpp + qt-ui/divelogexportdialog.cpp \ + qt-ui/usersurvey.cpp android: SOURCES += android.cpp else: linux*: SOURCES += linux.c @@ -188,7 +190,8 @@ FORMS = \ qt-ui/divelogimportdialog.ui \ qt-ui/usermanual.ui \ qt-ui/divelogexportdialog.ui \ - qt-ui/plannerSettings.ui + qt-ui/plannerSettings.ui \ + qt-ui/usersurvey.ui # Nether usermanual or printing is supported on android right now android: FORMS -= qt-ui/usermanual.ui qt-ui/printoptions.ui -- cgit v1.2.3-70-g09d2