diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-01-29 22:02:37 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-01-31 08:56:16 +0100 |
commit | bbd2a1ffbe1408d21e7980880796f99d98aa23de (patch) | |
tree | a3c26d77d52254026fb942cfb89a87f0c8c25b91 | |
parent | 6d2699c73a27078343037235b9bdcd7112320ab2 (diff) | |
download | kube-bbd2a1ffbe1408d21e7980880796f99d98aa23de.tar.gz kube-bbd2a1ffbe1408d21e7980880796f99d98aa23de.zip |
Upgrade screen
-rw-r--r-- | applications/kube/main.cpp | 39 | ||||
-rw-r--r-- | components/kube/qml/upgrade.qml | 47 |
2 files changed, 77 insertions, 9 deletions
diff --git a/applications/kube/main.cpp b/applications/kube/main.cpp index e098ed3a..2feb8dc9 100644 --- a/applications/kube/main.cpp +++ b/applications/kube/main.cpp | |||
@@ -38,6 +38,8 @@ | |||
38 | #include <QFileInfo> | 38 | #include <QFileInfo> |
39 | #include <QFont> | 39 | #include <QFont> |
40 | #include <QDebug> | 40 | #include <QDebug> |
41 | #include <QTimer> | ||
42 | #include <sink/store.h> | ||
41 | 43 | ||
42 | #include "framework/src/keyring.h" | 44 | #include "framework/src/keyring.h" |
43 | #include "kube_version.h" | 45 | #include "kube_version.h" |
@@ -130,6 +132,18 @@ void terminateHandler() | |||
130 | std::abort(); | 132 | std::abort(); |
131 | } | 133 | } |
132 | 134 | ||
135 | |||
136 | QString findFile(const QString file, const QStringList importPathList) | ||
137 | { | ||
138 | for (const auto &path : importPathList) { | ||
139 | const QString f = path + file; | ||
140 | if (QFileInfo::exists(f)) { | ||
141 | return f; | ||
142 | } | ||
143 | } | ||
144 | return {}; | ||
145 | } | ||
146 | |||
133 | int main(int argc, char *argv[]) | 147 | int main(int argc, char *argv[]) |
134 | { | 148 | { |
135 | std::signal(SIGSEGV, crashHandler); | 149 | std::signal(SIGSEGV, crashHandler); |
@@ -150,6 +164,7 @@ int main(int argc, char *argv[]) | |||
150 | parser.addOption({{"k", "keyring"}, | 164 | parser.addOption({{"k", "keyring"}, |
151 | QCoreApplication::translate("main", "To automatically unlock the keyring pass in a keyring in the form of {\"accountId\": {\"resourceId\": \"secret\", *}}"), "keyring dictionary"} | 165 | QCoreApplication::translate("main", "To automatically unlock the keyring pass in a keyring in the form of {\"accountId\": {\"resourceId\": \"secret\", *}}"), "keyring dictionary"} |
152 | ); | 166 | ); |
167 | parser.addOption({{"u", "upgrade"}, "", ""}); | ||
153 | parser.process(app); | 168 | parser.process(app); |
154 | 169 | ||
155 | if (parser.isSet("keyring")) { | 170 | if (parser.isSet("keyring")) { |
@@ -168,17 +183,23 @@ int main(int argc, char *argv[]) | |||
168 | } | 183 | } |
169 | } | 184 | } |
170 | 185 | ||
186 | { | ||
187 | bool upgradeComplete = false; | ||
188 | Sink::Store::upgrade().then([&] { | ||
189 | upgradeComplete = true; | ||
190 | app.quit(); | ||
191 | }).exec(); | ||
192 | if (!upgradeComplete) { | ||
193 | QQmlApplicationEngine engine; | ||
194 | const auto file = findFile("/org/kube/components/kube/upgrade.qml", engine.importPathList()); | ||
195 | engine.load(QUrl::fromLocalFile(file)); | ||
196 | app.exec(); | ||
197 | } | ||
198 | } | ||
199 | |||
171 | QQmlApplicationEngine engine; | 200 | QQmlApplicationEngine engine; |
172 | const auto file = "/org/kube/components/kube/main.qml"; | 201 | const auto file = "/org/kube/components/kube/main.qml"; |
173 | const auto mainFile = [&] { | 202 | const auto mainFile = findFile(file, engine.importPathList()); |
174 | for (const auto &path : engine.importPathList()) { | ||
175 | QString f = path + file; | ||
176 | if (QFileInfo::exists(f)) { | ||
177 | return f; | ||
178 | } | ||
179 | } | ||
180 | return QString{}; | ||
181 | }(); | ||
182 | if (mainFile.isEmpty()) { | 203 | if (mainFile.isEmpty()) { |
183 | qWarning() << "Failed to find " << file; | 204 | qWarning() << "Failed to find " << file; |
184 | qWarning() << "Searched: " << engine.importPathList(); | 205 | qWarning() << "Searched: " << engine.importPathList(); |
diff --git a/components/kube/qml/upgrade.qml b/components/kube/qml/upgrade.qml new file mode 100644 index 00000000..8548b54d --- /dev/null +++ b/components/kube/qml/upgrade.qml | |||
@@ -0,0 +1,47 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2017 Michael Bohlender, <michael.bohlender@kdemail.net> | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * 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, write to the Free Software Foundation, Inc., | ||
16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
17 | */ | ||
18 | |||
19 | import QtQuick 2.7 | ||
20 | import QtQuick 2.7 | ||
21 | import QtQuick.Layouts 1.3 | ||
22 | import QtQuick.Window 2.0 | ||
23 | |||
24 | import QtQuick.Controls 2.0 as Controls2 | ||
25 | import org.kube.framework 1.0 as Kube | ||
26 | |||
27 | Controls2.ApplicationWindow { | ||
28 | id: app | ||
29 | height: Screen.desktopAvailableHeight * 0.4 | ||
30 | width: Screen.desktopAvailableWidth * 0.4 | ||
31 | visible: true | ||
32 | font.family: Kube.Font.fontFamily | ||
33 | ColumnLayout { | ||
34 | anchors { | ||
35 | centerIn: parent | ||
36 | margins: Kube.Units.largeSpacing | ||
37 | } | ||
38 | spacing: 0 | ||
39 | Kube.Heading { | ||
40 | text: qsTr("Please wait while Kube is upgrading...") | ||
41 | color: Kube.Colors.highlightColor | ||
42 | } | ||
43 | Kube.Label { | ||
44 | text: qsTr("This might take a while.") | ||
45 | } | ||
46 | } | ||
47 | } | ||