on xenial help sign in
mark the wizard to skip until the last page temporarily

to greet the user with the "Welcome to Ubuntu" page for the next boot after a system update had been installed

commit25007329d0737d3c01fe56e8bcebfa0bdf56a0f4 authorLukáš Tinkl <lukas.tinkl@canonical.com> dateMon 18 Jul 2016, 12:56 (10 years ago) parent0f35940
6 files changed+43−1
plugins/Wizard/PageList.cpp+16 plugins/Wizard/System.cpp+8 plugins/Wizard/System.h+4 qml/Wizard/Pages/77-system-update.qml+3−1 tests/mocks/Wizard/MockSystem.cpp+8 tests/mocks/Wizard/MockSystem.h+4
plugins/Wizard/PageList.cpp+16
@@ -34,6 +34,7 @@
3434#include <QDir>
3535#include <QSet>
3636#include <QStandardPaths>
37+#include <QSettings>
3738
3839PageList::PageList(QObject *parent)
3940 : QObject(parent),
@@ -66,6 +67,21 @@ PageList::PageList(QObject *parent)
6667 Q_FOREACH(const QString &page, disabledPages) {
6768 m_pages.remove(page);
6869 }
70+
71+ // If there was a system update installed, skip until the last page to just greet the user
72+ QSettings settings;
73+
74+ if (settings.value(QStringLiteral("Wizard/SkipUntilFinishedPage")).toBool()) {
75+ const QString lastPage = m_pages.lastKey();
76+ Q_FOREACH(const QString &page, m_pages.keys()) {
77+ if (Q_UNLIKELY(page != lastPage)) {
78+ m_pages.remove(page);
79+ }
80+ }
81+
82+ // ... and reset it again for the next run
83+ settings.remove(QStringLiteral("Wizard/SkipUntilFinishedPage"));
84+ }
6985}
7086
7187QStringList PageList::entries() const
plugins/Wizard/System.cpp+8
@@ -26,6 +26,7 @@
2626#include <QMap>
2727#include <QProcess>
2828#include <QDebug>
29+#include <QSettings>
2930
3031System::System()
3132 : QObject()
@@ -109,3 +110,10 @@ void System::updateSessionLocale(const QString &locale)
109110 initctl restart --no-wait indicator-messages; \
110111 initctl restart --no-wait unity8-dash\""));
111112}
113+
114+void System::skipUntilFinishedPage()
115+{
116+ QSettings settings;
117+ settings.setValue(QStringLiteral("Wizard/SkipUntilFinishedPage"), true);
118+ settings.sync();
119+}
plugins/Wizard/System.h+4
@@ -35,6 +35,10 @@ public:
3535
3636public Q_SLOTS:
3737 void updateSessionLocale(const QString &locale);
38+ /**
39+ * Mark the wizard to skip all the pages and just show the last (welcome to ubuntu) page
40+ */
41+ void skipUntilFinishedPage();
3842
3943Q_SIGNALS:
4044 void wizardEnabledChanged();
qml/Wizard/Pages/77-system-update.qml+3−1
@@ -18,6 +18,7 @@ import QtQuick 2.4
1818import QtQuick.Layouts 1.1
1919import Ubuntu.Components 1.3
2020import Ubuntu.SystemImage 0.1
21+import Wizard 0.1
2122import ".." as LocalComponents
2223
2324LocalComponents.Page {
@@ -122,7 +123,8 @@ LocalComponents.Page {
122123 objectName: "installButton"
123124 anchors.fill: parent
124125 onClicked: {
125− SystemImage.applyUpdate(); // TODO mark the wizard to skip until the finished page for the next boot
126+ System.skipUntilFinishedPage();
127+ SystemImage.applyUpdate();
126128 }
127129 }
128130
tests/mocks/Wizard/MockSystem.cpp+8
@@ -15,6 +15,7 @@
1515 */
1616
1717#include <QDebug>
18+#include <QSettings>
1819
1920#include "MockSystem.h"
2021
@@ -39,3 +40,10 @@ void MockSystem::updateSessionLocale(const QString &locale)
3940{
4041 Q_EMIT updateSessionLocaleCalled(locale);
4142}
43+
44+void MockSystem::skipUntilFinishedPage()
45+{
46+ QSettings settings;
47+ settings.setValue(QStringLiteral("Wizard/SkipUntilFinishedPage"), true);
48+ settings.sync();
49+}
tests/mocks/Wizard/MockSystem.h+4
@@ -33,6 +33,10 @@ public:
3333
3434public Q_SLOTS:
3535 void updateSessionLocale(const QString &locale);
36+ /**
37+ * Mark the wizard to skip all the pages and just show the last (welcome to ubuntu) page
38+ */
39+ void skipUntilFinishedPage();
3640
3741Q_SIGNALS:
3842 void wizardEnabledChanged();