summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--applications/kube/main.cpp39
-rw-r--r--components/kube/qml/upgrade.qml47
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
136QString 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
133int main(int argc, char *argv[]) 147int 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
19import QtQuick 2.7
20import QtQuick 2.7
21import QtQuick.Layouts 1.3
22import QtQuick.Window 2.0
23
24import QtQuick.Controls 2.0 as Controls2
25import org.kube.framework 1.0 as Kube
26
27Controls2.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}