on xenial help sign in
Add logic to check the versions that should be shown in the wizard
3356f48Dalton Durst
plugins/Wizard/System.cpp+33−2
@@ -20,6 +20,7 @@
20#include <QDBusMessage>
20#include <QDBusMessage>
21#include <QDBusConnection>
21#include <QDBusConnection>
22#include <QDBusMetaType>
22#include <QDBusMetaType>
23+#include <QVersionNumber>
23#include <QDir>
24#include <QDir>
24#include <QFile>
25#include <QFile>
25#include <QLocale>
26#include <QLocale>
@@ -43,12 +44,42 @@ System::System()
43QString System::wizardEnabledPath()
44QString System::wizardEnabledPath()
44{
45{
45 // Uses ubuntu-system-settings namespace for historic compatibility reasons
46 // Uses ubuntu-system-settings namespace for historic compatibility reasons
46− return QDir::home().filePath(QStringLiteral(".config/ubuntu-system-settings/wizard-has-run"));
47+ return QDir::home().filePath(QStringLiteral(".config/ubuntu-system-settings/wizard-has-run/"));
47}
48}
48
49
49bool System::wizardEnabled() const
50bool System::wizardEnabled() const
50{
51{
52+ // versionsToShow will only be empty if there are no missed wizard runs
53+ return (sizeof(this->versionsToShow()) != 0);
54+}
55+
56+std::vector<QVersionNumber> System::versionsToShow() const
57+{
51− return !QFile::exists(wizardEnabledPath());
58+ if (!QFile::exists(wizardEnabledPath())) {
59+ std::vector<QVersionNumber> versions = {QVersionNumber(0)};
60+ return versions;
61+ }
62+
63+ std::vector<QVersionNumber> missedVersions;
64+
65+ for(int i = 0; i < sizeof(wizardUpdates()); i++)
66+ {
67+ QVersionNumber versionToCheck = wizardUpdates()[i];
68+ QString pathToCheck = QDir(wizardEnabledPath()).filePath(versionToCheck.toString());
69+
70+ if (versionToCheck > currentVersion()) {
71+ continue;
72+ }
73+
74+ if (!QFile::exists(pathToCheck)) {
75+ continue;
76+ }
77+
78+ missedVersions.push_back(versionToCheck);
79+ }
80+
81+ return missedVersions;
82+
52}
83}
53
84
54void System::setWizardEnabled(bool enabled)
85void System::setWizardEnabled(bool enabled)
plugins/Wizard/System.h+42
@@ -18,6 +18,7 @@
18#define WIZARD_SYSTEM_H
18#define WIZARD_SYSTEM_H
19
19
20#include <QFileSystemWatcher>
20#include <QFileSystemWatcher>
21+#include <QVersionNumber>
21#include <QObject>
22#include <QObject>
22#include <QString>
23#include <QString>
23
24
@@ -30,7 +31,48 @@ public:
30 System();
31 System();
31 ~System() = default;
32 ~System() = default;
32
33
34+ /**
35+ * Checks whether the wizard is enabled for first-run or otherwise
36+ */
33 bool wizardEnabled() const;
37 bool wizardEnabled() const;
38+
39+ /**
40+ * Returns the update version(s) that the wizard has not yet run for.
41+ * Will be empty if the current wizard version is the same version that has
42+ * already run or if the OOBE (first-time) wizard is set to run.
43+ * The special value [QVersionNumber(0)] denotes that the first-time setup
44+ * should run.
45+ * The special value [] denotes that the wizard should not be run.
46+ */
47+ std::vector<QVersionNumber> versionsToShow() const;
48+
49+ /**
50+ * Returns the possible update versions
51+ */
52+ std::vector<QVersionNumber> wizardUpdates() const
53+ {
54+ // Add a new QVersionNumber to this array for every new set of pages you
55+ // would like to add to the wizard. The wizard will check for every
56+ // version between its last run and its current version (::currentVersion())
57+ return {
58+ QVersionNumber(1, 0, 0)
59+ };
60+ }
61+
62+ /**
63+ * The update version for the Wizard in this version of Unity8. Bump this
64+ * version and add your new value to ::wizardUpdates(), then set the
65+ * showOnVersions property for the pages you would like to run on the current
66+ * update to the new value.
67+ */
68+ QVersionNumber currentVersion() const
69+ {
70+ return QVersionNumber(1, 0, 0);
71+ }
72+
73+ /**
74+ * Set that the OOBE (first-run) wizard should be run
75+ */
34 void setWizardEnabled(bool enabled);
76 void setWizardEnabled(bool enabled);
35
77
36public Q_SLOTS:
78public Q_SLOTS: