diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2020-04-01 07:27:10 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-04-04 12:00:24 -0700 |
commit | 8801ae857ebfc720fcbd812baae425bc8f90e65e (patch) | |
tree | 0f62f6d1846766a260a54282e70e9a57a0535c15 | |
parent | d317eefb6726314efd20ae1007c2298ecf99e772 (diff) | |
download | subsurface-8801ae857ebfc720fcbd812baae425bc8f90e65e.tar.gz |
mobile/startup: show notification directly in the UI window
Until the app is initialized, we have problems getting the 'floating'
passive notifications to show up and be useful. Instead update the user
by filling a text block on the otherwise empty initial page of the app.
Delay the switch to the dive list until the app is initialized and then
use the passive notifications again. While we are initializing also show
a busy spinner so the user doesn't think the app is hung.
As a side effect of this change, the dive list isn't shown until our
models are initialized. And strangely this causes every single possible
delegate to be instantiated. We can prevent that by not setting the dive
list model until after we are done setting up the model.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | mobile-widgets/qml/DiveList.qml | 2 | ||||
-rw-r--r-- | mobile-widgets/qml/main.qml | 74 |
2 files changed, 57 insertions, 19 deletions
diff --git a/mobile-widgets/qml/DiveList.qml b/mobile-widgets/qml/DiveList.qml index 50f69436b..b048d4f2d 100644 --- a/mobile-widgets/qml/DiveList.qml +++ b/mobile-widgets/qml/DiveList.qml @@ -13,7 +13,7 @@ Kirigami.ScrollablePage { title: qsTr("Dive list") verticalScrollBarPolicy: Qt.ScrollBarAlwaysOff property int horizontalPadding: Kirigami.Units.gridUnit / 2 - Kirigami.Units.smallSpacing + 1 - property QtObject diveListModel: diveModel + property QtObject diveListModel: null supportsRefreshing: true onRefreshingChanged: { diff --git a/mobile-widgets/qml/main.qml b/mobile-widgets/qml/main.qml index 243978c46..81d08140d 100644 --- a/mobile-widgets/qml/main.qml +++ b/mobile-widgets/qml/main.qml @@ -36,13 +36,28 @@ Kirigami.ApplicationWindow { property int colWidth: undefined onNotificationTextChanged: { - if (notificationText != "") { - // there's a risk that we have a >5 second gap in update events; - // still, keep the timeout at 5s to avoid odd unchanging notifications - showPassiveNotification(notificationText, 5000) + // once the app is fully initialized and the UI is running, we use passive + // notifications to show the notification text, but during initialization + // we instead dump the information into the textBlock below - and to make + // this visually more useful we interpret a "\r" at the beginning of a notification + // to mean that we want to simply over-write the last line, not create a new one + if (initialized) { + // make sure any old notification is hidden + hidePassiveNotification() + if (notificationText !== "") { + // there's a risk that we have a >5 second gap in update events; + // still, keep the timeout at 5s to avoid odd unchanging notifications + showPassiveNotification(notificationText, 5000) + } } else { - // hiding the notification right away may be a mistake as it hides the last warning / error - hidePassiveNotification(); + var oldText = textBlock.text + if (notificationText.startsWith("\r")) { + // replace the last line that was sent + oldText = oldText.substr(0, oldText.lastIndexOf("\n")) + textBlock.text = oldText + "\n" + notificationText.substr(1) + } else { + textBlock.text = oldText + "\n" + notificationText + } } } visible: false @@ -63,7 +78,7 @@ Kirigami.ApplicationWindow { function hideBusy() { busy.running = false - showPassiveNotification("", 10) // this hides a notification messssage that's still shown + hidePassiveNotification() } function returnTopPage() { @@ -707,28 +722,51 @@ if you have network connectivity and want to sync your data to cloud storage."), id: manager } + property bool initialized: manager.initialized + + onInitializedChanged: { + if (initialized) { + hideBusy() + manager.appendTextToLog("initialization completed - showing the dive list") + showPage(diveList) // we want to make sure that gets on the stack + diveList.diveListModel = diveModel + manager.appendTextToLog("if we got started by a plugged in device, switch to download page -- pluggedInDeviceName = " + pluggedInDeviceName) + if (pluggedInDeviceName !== "") + // if we were started with a dive computer plugged in, + // immediately switch to download page + showDownloadForPluggedInDevice() + } + } + + Label { + id: textBlock + visible: !initialized + text: qsTr("Subsurface-mobile starting up") + font.pointSize: subsurfaceTheme.headingPointSize + topPadding: 2 * Kirigami.Units.gridUnit + leftPadding: Kirigami.Units.gridUnit + } + StartPage { id: startPage anchors.fill: parent - visible: Backend.cloud_verification_status !== Enums.CS_NOCLOUD && + visible: initialized && + Backend.cloud_verification_status !== Enums.CS_NOCLOUD && Backend.cloud_verification_status !== Enums.CS_VERIFIED onVisibleChanged: { + manager.appendTextToLog("StartPage visibility changed to " + visible) + if (!initialized) { + manager.appendTextToLog("not yet initialized, show busy spinner") + showBusy() + } if (visible) { pageStack.clear() - } else { + } else if (initialized) { showDiveList() } } Component.onCompleted: { - if (!visible) { - manager.appendTextToLog("StartPage completed - showing the dive list") - showPage(diveList) // we want to make sure that gets on the stack - manager.appendTextToLog("if we got started by a plugged in device, switch to download page -- pluggedInDeviceName = " + pluggedInDeviceName) - if (pluggedInDeviceName !== "") - // if we were started with a dive computer plugged in, - // immediately switch to download page - showDownloadForPluggedInDevice() - } + manager.appendTextToLog("StartPage completed -- initialized is " + initialized) } } |