From bbd2a1ffbe1408d21e7980880796f99d98aa23de Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Mon, 29 Jan 2018 22:02:37 +0100 Subject: Upgrade screen --- applications/kube/main.cpp | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) (limited to 'applications') 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 @@ #include #include #include +#include +#include #include "framework/src/keyring.h" #include "kube_version.h" @@ -130,6 +132,18 @@ void terminateHandler() std::abort(); } + +QString findFile(const QString file, const QStringList importPathList) +{ + for (const auto &path : importPathList) { + const QString f = path + file; + if (QFileInfo::exists(f)) { + return f; + } + } + return {}; +} + int main(int argc, char *argv[]) { std::signal(SIGSEGV, crashHandler); @@ -150,6 +164,7 @@ int main(int argc, char *argv[]) parser.addOption({{"k", "keyring"}, QCoreApplication::translate("main", "To automatically unlock the keyring pass in a keyring in the form of {\"accountId\": {\"resourceId\": \"secret\", *}}"), "keyring dictionary"} ); + parser.addOption({{"u", "upgrade"}, "", ""}); parser.process(app); if (parser.isSet("keyring")) { @@ -168,17 +183,23 @@ int main(int argc, char *argv[]) } } + { + bool upgradeComplete = false; + Sink::Store::upgrade().then([&] { + upgradeComplete = true; + app.quit(); + }).exec(); + if (!upgradeComplete) { + QQmlApplicationEngine engine; + const auto file = findFile("/org/kube/components/kube/upgrade.qml", engine.importPathList()); + engine.load(QUrl::fromLocalFile(file)); + app.exec(); + } + } + QQmlApplicationEngine engine; const auto file = "/org/kube/components/kube/main.qml"; - const auto mainFile = [&] { - for (const auto &path : engine.importPathList()) { - QString f = path + file; - if (QFileInfo::exists(f)) { - return f; - } - } - return QString{}; - }(); + const auto mainFile = findFile(file, engine.importPathList()); if (mainFile.isEmpty()) { qWarning() << "Failed to find " << file; qWarning() << "Searched: " << engine.importPathList(); -- cgit v1.2.3