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 ++++++++++++++++++++++++++-------- components/kube/qml/upgrade.qml | 47 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 9 deletions(-) create mode 100644 components/kube/qml/upgrade.qml 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(); 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 @@ +/* + * Copyright (C) 2017 Michael Bohlender, + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +import QtQuick 2.7 +import QtQuick 2.7 +import QtQuick.Layouts 1.3 +import QtQuick.Window 2.0 + +import QtQuick.Controls 2.0 as Controls2 +import org.kube.framework 1.0 as Kube + +Controls2.ApplicationWindow { + id: app + height: Screen.desktopAvailableHeight * 0.4 + width: Screen.desktopAvailableWidth * 0.4 + visible: true + font.family: Kube.Font.fontFamily + ColumnLayout { + anchors { + centerIn: parent + margins: Kube.Units.largeSpacing + } + spacing: 0 + Kube.Heading { + text: qsTr("Please wait while Kube is upgrading...") + color: Kube.Colors.highlightColor + } + Kube.Label { + text: qsTr("This might take a while.") + } + } +} -- cgit v1.2.3