diff options
-rw-r--r-- | qt-ui/mainwindow.cpp | 27 | ||||
-rw-r--r-- | qt-ui/mainwindow.h | 2 | ||||
-rw-r--r-- | qt-ui/usersurvey.cpp | 53 | ||||
-rw-r--r-- | qt-ui/usersurvey.h | 25 | ||||
-rw-r--r-- | qt-ui/usersurvey.ui | 209 | ||||
-rw-r--r-- | subsurface.pro | 9 |
6 files changed, 320 insertions, 5 deletions
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 <fcntl.h> #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 <QShortcut> +#include <QMessageBox> +#include <QDebug> +#include <QSettings> + +#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 <QDialog> + +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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>UserSurvey</class> + <widget class="QDialog" name="UserSurvey"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>410</width> + <height>524</height> + </rect> + </property> + <property name="windowTitle"> + <string>Dialog</string> + </property> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="geometry"> + <rect> + <x>40</x> + <y>490</y> + <width>341</width> + <height>32</height> + </rect> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Save</set> + </property> + </widget> + <widget class="QLabel" name="label"> + <property name="geometry"> + <rect> + <x>10</x> + <y>10</y> + <width>381</width> + <height>16</height> + </rect> + </property> + <property name="font"> + <font> + <pointsize>11</pointsize> + </font> + </property> + <property name="text"> + <string>Subsurface User Survey</string> + </property> + </widget> + <widget class="QLabel" name="label_2"> + <property name="geometry"> + <rect> + <x>10</x> + <y>40</y> + <width>371</width> + <height>81</height> + </rect> + </property> + <property name="text"> + <string>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.</string> + </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> + </property> + <property name="wordWrap"> + <bool>true</bool> + </property> + </widget> + <widget class="QCheckBox" name="recreational"> + <property name="geometry"> + <rect> + <x>10</x> + <y>140</y> + <width>151</width> + <height>20</height> + </rect> + </property> + <property name="text"> + <string>Recreational DIver</string> + </property> + </widget> + <widget class="QCheckBox" name="tech"> + <property name="geometry"> + <rect> + <x>160</x> + <y>140</y> + <width>151</width> + <height>20</height> + </rect> + </property> + <property name="text"> + <string>Tech Diver</string> + </property> + </widget> + <widget class="QCheckBox" name="planning"> + <property name="geometry"> + <rect> + <x>10</x> + <y>160</y> + <width>211</width> + <height>20</height> + </rect> + </property> + <property name="text"> + <string>Interested in dive planning</string> + </property> + </widget> + <widget class="QCheckBox" name="download"> + <property name="geometry"> + <rect> + <x>10</x> + <y>180</y> + <width>371</width> + <height>20</height> + </rect> + </property> + <property name="text"> + <string>I am downloading dives from supported dive computer</string> + </property> + </widget> + <widget class="QCheckBox" name="import_2"> + <property name="geometry"> + <rect> + <x>10</x> + <y>200</y> + <width>371</width> + <height>20</height> + </rect> + </property> + <property name="text"> + <string>I am importing dives from other software / sources</string> + </property> + </widget> + <widget class="QCheckBox" name="manual"> + <property name="geometry"> + <rect> + <x>10</x> + <y>220</y> + <width>371</width> + <height>20</height> + </rect> + </property> + <property name="text"> + <string>I am manually entering dives</string> + </property> + </widget> + <widget class="QTextEdit" name="suggestions"> + <property name="geometry"> + <rect> + <x>10</x> + <y>270</y> + <width>371</width> + <height>101</height> + </rect> + </property> + <property name="html"> + <string><!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></string> + </property> + </widget> + <widget class="QCheckBox" name="companion"> + <property name="geometry"> + <rect> + <x>10</x> + <y>240</y> + <width>381</width> + <height>20</height> + </rect> + </property> + <property name="text"> + <string>I use the Android companion app to track dive locations</string> + </property> + </widget> + <widget class="QTextEdit" name="system"> + <property name="geometry"> + <rect> + <x>10</x> + <y>380</y> + <width>371</width> + <height>101</height> + </rect> + </property> + <property name="html"> + <string><!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></string> + </property> + </widget> + </widget> + <tabstops> + <tabstop>recreational</tabstop> + <tabstop>tech</tabstop> + <tabstop>planning</tabstop> + <tabstop>download</tabstop> + <tabstop>import_2</tabstop> + <tabstop>manual</tabstop> + <tabstop>companion</tabstop> + <tabstop>suggestions</tabstop> + <tabstop>system</tabstop> + <tabstop>buttonBox</tabstop> + </tabstops> + <resources/> + <connections/> +</ui> 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 |