From 1facae9ba5deb5af12093d70674b1661b1685c3d Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Sun, 11 Feb 2018 22:50:40 +0100 Subject: Restart kube after a storage upgrade. We currently don't deal with disappearing databases, and the db's are loaded on process initialization. Thus we have to restart Kube for now when something was upgraded. --- applications/kube/main.cpp | 17 +++++++++++------ components/kube/qml/upgrade.qml | 11 +++++++++-- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/applications/kube/main.cpp b/applications/kube/main.cpp index 2feb8dc9..6cb1f769 100644 --- a/applications/kube/main.cpp +++ b/applications/kube/main.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include #include "framework/src/keyring.h" @@ -184,16 +185,20 @@ int main(int argc, char *argv[]) } { + QQmlContext *rootContext = nullptr; bool upgradeComplete = false; - Sink::Store::upgrade().then([&] { - upgradeComplete = true; - app.quit(); + Sink::Store::upgrade().then([&] (Sink::Store::UpgradeResult upgradeExecuted) { + upgradeComplete = !upgradeExecuted.upgradeExecuted; + if (rootContext) { + rootContext->setContextProperty("upgradeComplete", true); + } }).exec(); if (!upgradeComplete) { QQmlApplicationEngine engine; - const auto file = findFile("/org/kube/components/kube/upgrade.qml", engine.importPathList()); - engine.load(QUrl::fromLocalFile(file)); - app.exec(); + engine.rootContext()->setContextProperty("upgradeComplete", false); + rootContext = engine.rootContext(); + engine.load(QUrl::fromLocalFile(findFile("/org/kube/components/kube/upgrade.qml", engine.importPathList()))); + return app.exec(); } } diff --git a/components/kube/qml/upgrade.qml b/components/kube/qml/upgrade.qml index 8548b54d..3ce1c63b 100644 --- a/components/kube/qml/upgrade.qml +++ b/components/kube/qml/upgrade.qml @@ -37,11 +37,18 @@ Controls2.ApplicationWindow { } spacing: 0 Kube.Heading { - text: qsTr("Please wait while Kube is upgrading...") + text: !upgradeComplete ? qsTr("Please wait while Kube is upgrading...") : qsTr("Kube has upgraded the storage layer.") color: Kube.Colors.highlightColor } Kube.Label { - text: qsTr("This might take a while.") + text: !upgradeComplete ? qsTr("This might take a while.") : qsTr("Please exit and restart Kube.") + } + Kube.Button { + anchors.topMargin: Kube.Units.largeSpacing + text: qsTr("Exit") + onClicked: { + app.close() + } } } } -- cgit v1.2.3