aboutsummaryrefslogtreecommitdiffstats
path: root/mobile-widgets/qml/main.qml
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2021-01-17 13:34:21 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2021-01-19 12:42:47 -0800
commit126329ab7c1b4062a4ba72c7cbac4ee703d65e3c (patch)
tree8730d1c916140cacf827797cbc741df5c98928dd /mobile-widgets/qml/main.qml
parente1cb36843742e3ad901c5eac8cdeb007f406ed66 (diff)
downloadsubsurface-126329ab7c1b4062a4ba72c7cbac4ee703d65e3c.tar.gz
mobile/UI: add button to change notification
This is fun... with just a tiny bit of 'magic text parsing' we can allow the backend code to add a button to the notification that will open the context menu that will make it super obvious to the user how they can undo an operation. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'mobile-widgets/qml/main.qml')
-rw-r--r--mobile-widgets/qml/main.qml16
1 files changed, 10 insertions, 6 deletions
diff --git a/mobile-widgets/qml/main.qml b/mobile-widgets/qml/main.qml
index 931279b41..194391e9f 100644
--- a/mobile-widgets/qml/main.qml
+++ b/mobile-widgets/qml/main.qml
@@ -55,13 +55,17 @@ Kirigami.ApplicationWindow {
// notifications to show the notification text, but during initialization
// we instead dump the information into the textBlock below
if (initialized) {
- // make sure any old notification is hidden
- // hiding notifications is no longer supported????
- // 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)
+ var actionEnd = notificationText.indexOf("]")
+ if (notificationText.startsWith("[") && actionEnd !== -1) {
+ // we have a notification text that starts with our special syntax to indication
+ // an action that the user can take (the actual action is always opening the context drawer
+ // so the action text should always be something that can then be found in the context drawer)
+ showPassiveNotification(notificationText.substring(actionEnd + 1), 5000, notificationText.substring(1,actionEnd),
+ function() { contextDrawer.open() })
+ } else {
+ showPassiveNotification(notificationText, 5000)
+ }
}
} else {
textBlock.text = textBlock.text + "\n" + notificationText