From e4ad766315879e1ff05bb111229f073f8f0ed68e Mon Sep 17 00:00:00 2001 From: Andreas Grois Date: Mon, 10 Oct 2022 21:30:02 +0200 Subject: PassFish: Initial Commit Well, that's a lie. But nobody needs to see all the iterations I decided to sweep under the rug. That said, I think the repo is, while not clean, clean enough now, to not be embarrassed by uploading it to github. --- qml/components/NoticeOptional.qml | 68 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 qml/components/NoticeOptional.qml (limited to 'qml/components') diff --git a/qml/components/NoticeOptional.qml b/qml/components/NoticeOptional.qml new file mode 100644 index 0000000..83e0198 --- /dev/null +++ b/qml/components/NoticeOptional.qml @@ -0,0 +1,68 @@ +import QtQuick 2.6 +import Sailfish.Silica 1.0 + +/// Helper to allow using Notice without breaking compilation on SailfishOS 3.4. +/// This helper conditionally loads either a Notice or a Notification +/// (or nothing if useNotificationFallback is disabled) based on the availability +/// of the Notice type. +Loader { + property string text + property string duration : "Notice.Short" + property bool useNotificationFallback : true + property bool transientNotificationFallback : duration === "Notice.Short" + + readonly property bool noticesAvailable : typeof(Notices) !== "undefined" + + function show() { + asynchronous = false; + if(item){ + if(item.show) { + item.show(); + return; + } + else if(item.publish){ + item.publish(); + return; + } + } + console.log("Notice could not be shown: " + text); + } + + asynchronous: true + source: noticesAvailable + ? "../helpers/NoticeLoadable.qml" + : (useNotificationFallback ? "../helpers/NotificationLoadable.qml" : "") + + Binding { + target: item + property: "text" + value: text + when: noticesAvailable && status == Loader.Ready + } + Binding { + target: item + property: "duration" + value: duration + when: noticesAvailable && status == Loader.Ready + } + //---------------------------------------------------------- + //fallback bindings + Binding { + target: item + property: "summary" + value: text + when: !noticesAvailable && useNotificationFallback && status == Loader.Ready + } + Binding { + target: item + property: "previewSummary" + value: text + when: !noticesAvailable && useNotificationFallback && status == Loader.Ready + } + Binding { + target: item + property: "isTransient" + value: transientNotificationFallback + when: !noticesAvailable && useNotificationFallback && status == Loader.Ready + } +} -- cgit v1.2.3