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 /applications | |
parent | 6d2699c73a27078343037235b9bdcd7112320ab2 (diff) | |
download | kube-bbd2a1ffbe1408d21e7980880796f99d98aa23de.tar.gz kube-bbd2a1ffbe1408d21e7980880796f99d98aa23de.zip |
Upgrade screen
Diffstat (limited to 'applications')
-rw-r--r-- | applications/kube/main.cpp | 39 |
1 files changed, 30 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(); |