on xenial help sign in
Merge pull request #63 from ubports/xenial_-_wizard-changelog
9b055e7Marius Gripsgard
plugins/Wizard/CMakeLists.txt+1
@@ -10,6 +10,7 @@ add_library(Wizard-qml MODULE
10 timezonemodel.cpp
10 timezonemodel.cpp
11 Status.cpp
11 Status.cpp
12 keyboardLayoutsModel.cpp
12 keyboardLayoutsModel.cpp
13+ Changelog.cpp
13)
14)
14
15
15qt5_use_modules(Wizard-qml DBus Qml)
16qt5_use_modules(Wizard-qml DBus Qml)
plugins/Wizard/Changelog.cppnew file+58
@@ -0,0 +1,58 @@
1+/*
2+ * Copyright (C) 2018 The UBports project
3+ * Written by: Marius Gripsgard <marius@ubports.com>
4+ *
5+ * This program is free software: you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 3, as published
7+ * by the Free Software Foundation.
8+ *
9+ * This program is distributed in the hope that it will be useful, but
10+ * WITHOUT ANY WARRANTY; without even the implied warranties of
11+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
12+ * PURPOSE. See the GNU General Public License for more details.
13+ *
14+ * You should have received a copy of the GNU General Public License along
15+ * with this program. If not, see <http://www.gnu.org/licenses/>.
16+ */
17+
18+#include "Changelog.h"
19+
20+#include <QDir>
21+#include <QFile>
22+#include <QTextStream>
23+
24+Changelog::Changelog()
25+ : QObject()
26+{
27+ readChangelog();
28+ if(QFile::exists(changelogPath()))
29+ m_fsWatcher.addPath(changelogPath());
30+ connect(&m_fsWatcher, &QFileSystemWatcher::fileChanged, this, &Changelog::watcherFileChanged);
31+}
32+
33+QString Changelog::changelogPath()
34+{
35+ return "/usr/share/ubports/changelogs/current";
36+}
37+
38+QString Changelog::text() const
39+{
40+ return m_text;
41+}
42+
43+void Changelog::readChangelog()
44+{
45+ if(!QFile::exists(changelogPath()))
46+ return;
47+ QFile f(changelogPath());
48+ if (!f.open(QFile::ReadOnly | QFile::Text)) return;
49+ QTextStream in(&f);
50+ m_text = in.readAll();
51+ Q_EMIT textChanged();
52+}
53+
54+void Changelog::watcherFileChanged()
55+{
56+ readChangelog();
57+ m_fsWatcher.removePath(changelogPath());
58+}
plugins/Wizard/Changelog.hnew file+52
@@ -0,0 +1,52 @@
1+/*
2+ * Copyright (C) 2018 The UBports project
3+ * Written by: Marius Gripsgard <marius@ubports.com>
4+ *
5+ * This program is free software: you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 3, as published
7+ * by the Free Software Foundation.
8+ *
9+ * This program is distributed in the hope that it will be useful, but
10+ * WITHOUT ANY WARRANTY; without even the implied warranties of
11+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
12+ * PURPOSE. See the GNU General Public License for more details.
13+ *
14+ * You should have received a copy of the GNU General Public License along
15+ * with this program. If not, see <http://www.gnu.org/licenses/>.
16+ */
17+
18+#ifndef WIZARD_CHANGELOG_H
19+#define WIZARD_CHANGELOG_H
20+
21+#include <QFileSystemWatcher>
22+#include <QObject>
23+#include <QString>
24+
25+class Changelog : public QObject
26+{
27+ Q_OBJECT
28+ Q_PROPERTY(QString text READ text NOTIFY textChanged)
29+
30+public:
31+ Changelog();
32+ ~Changelog() = default;
33+
34+ QString text() const;
35+
36+Q_SIGNALS:
37+ void textChanged();
38+
39+private Q_SLOTS:
40+ void watcherFileChanged();
41+
42+private:
43+ Q_DISABLE_COPY(Changelog)
44+
45+ static QString changelogPath();
46+ void readChangelog();
47+
48+ QFileSystemWatcher m_fsWatcher;
49+ QString m_text;
50+};
51+
52+#endif
plugins/Wizard/plugin.cpp+2
@@ -20,6 +20,7 @@
20#include "timezonemodel.h"
20#include "timezonemodel.h"
21#include "LocalePlugin.h"
21#include "LocalePlugin.h"
22#include "Status.h"
22#include "Status.h"
23+#include "Changelog.h"
23#include "keyboardLayoutsModel.h"
24#include "keyboardLayoutsModel.h"
24
25
25#include <QtQml/qqml.h>
26#include <QtQml/qqml.h>
@@ -30,6 +31,7 @@ void WizardPlugin::registerTypes(const char *uri)
30 qmlRegisterType<PageList>(uri, 0, 1, "PageList");
31 qmlRegisterType<PageList>(uri, 0, 1, "PageList");
31 qmlRegisterSingletonType<System>(uri, 0, 1, "System", [](QQmlEngine*, QJSEngine*) -> QObject* { return new System; });
32 qmlRegisterSingletonType<System>(uri, 0, 1, "System", [](QQmlEngine*, QJSEngine*) -> QObject* { return new System; });
32 qmlRegisterSingletonType<Status>(uri, 0, 1, "Status", [](QQmlEngine*, QJSEngine*) -> QObject* { return new Status; });
33 qmlRegisterSingletonType<Status>(uri, 0, 1, "Status", [](QQmlEngine*, QJSEngine*) -> QObject* { return new Status; });
34+ qmlRegisterSingletonType<Changelog>(uri, 0, 1, "Changelog", [](QQmlEngine*, QJSEngine*) -> QObject* { return new Changelog; });
33 qmlRegisterType<TimeZoneLocationModel>(uri, 0, 1, "TimeZoneModel");
35 qmlRegisterType<TimeZoneLocationModel>(uri, 0, 1, "TimeZoneModel");
34 qmlRegisterType<KeyboardLayoutsModel>(uri, 0, 1, "KeyboardLayoutsModel");
36 qmlRegisterType<KeyboardLayoutsModel>(uri, 0, 1, "KeyboardLayoutsModel");
35 qmlRegisterType<LocalePlugin>(uri, 0, 1, "LocalePlugin");
37 qmlRegisterType<LocalePlugin>(uri, 0, 1, "LocalePlugin");
qml/Wizard/Pages/11-changelog.qml+4−1
@@ -20,6 +20,7 @@
20import QtQuick 2.4
20import QtQuick 2.4
21import Ubuntu.Components 1.3
21import Ubuntu.Components 1.3
22import AccountsService 0.1
22import AccountsService 0.1
23+import Wizard 0.1
23import ".." as LocalComponents
24import ".." as LocalComponents
24
25
25LocalComponents.Page {
26LocalComponents.Page {
@@ -42,7 +43,9 @@ LocalComponents.Page {
42 }
43 }
43
44
44 Label {
45 Label {
45− text: "This is where cool stuff would go"
46+ width: parent.width
47+ wrapMode: Text.WordWrap
48+ text: Changelog.text
46 }
49 }
47 }
50 }
48
51
qml/Wizard/Pages/78-firmware-update.qml+2−1
@@ -135,6 +135,7 @@ LocalComponents.Page {
135
135
136 Label {
136 Label {
137 font.weight: Font.Light
137 font.weight: Font.Light
138+ wrapMode: Text.WordWrap
138 fontSize: "small"
139 fontSize: "small"
139 text: systemUpdatePage.partitions
140 text: systemUpdatePage.partitions
140 }
141 }
@@ -232,7 +233,7 @@ LocalComponents.Page {
232 Component {
233 Component {
233 id: forwardButton
234 id: forwardButton
234 LocalComponents.StackButton {
235 LocalComponents.StackButton {
235− text: !systemUpdatePage.hasUpdate && !systemUpdatePage.spinner
236+ text: !systemUpdatePage.hasUpdate && !systemUpdatePage.spinner.visible
236 ? i18n.tr("Next") : i18n.tr("Skip")
237 ? i18n.tr("Next") : i18n.tr("Skip")
237 onClicked: pageStack.next()
238 onClicked: pageStack.next()
238 }
239 }