//pragma Strict // had to comment this out because of actions import QtQuick import QtQuick.Layouts import QtQuick.Controls.Basic import QtApplicationManager import QtApplicationManager.SystemUI ApplicationWindow { width: 640 height: 480 visible: true Notification { id: notification summary: "Test Notification" body: "Choose an Action" sticky: true // we must use an action to dismiss actions: [ // this is not nice JSON - see QTBUG-118693 because an array should be of identical // objects which these are not - and can't be used as a model on the "server side" { "actionId1": "Action 1" }, { "actionId2": "Action 2" }, ] dismissOnAction: true // this doesn't work onActionTriggered: (actionId) => { actionPane.showActionTriggered(actionId) } } ListView { // notificationview anchors.fill: parent model: NotificationManager delegate: Pane { id: notificationDelegate required property string id required property string summary required property string body required property var actions required property var extended RowLayout { Pane { ColumnLayout { Label { text: notificationDelegate.summary } Label { text: notificationDelegate.body } RowLayout { // cannot dynamically create buttons here as actions // can't be used as a model Button { text: actions[0].actionId1 // see what I mean? Not nice. // and how to pass the action id into this function // is also not nice because // you can't actually access it! onClicked: NotificationManager.triggerNotificationAction( notificationDelegate.id, "actionId1") } Button { text: actions[1].actionId2 // yep. // how prone is this to error... onClicked: NotificationManager.triggerNotificationAction( notificationDelegate.id, "actionId2") } } } background: Rectangle { color: "lightgrey" border.color: "black" radius: 16 } } Label { text: "<< NOTIFICATION NOT DISMISSED ON ACTION" color: "red" visible: notificationDelegate.extended.showWarning === true } } } } Button { anchors.centerIn: parent text: "Open Notification" onClicked: notification.show() } footer: Pane { id: actionPane visible: timer.running function showActionTriggered(actionId: string) { notification.extended = {} actionLabel.text = "[" + actionId + "] triggered!" timer.restart() } Timer { id: timer interval: 2000 repeat: false onTriggered: notification.extended = { "showWarning" : true } } ColumnLayout { anchors.fill: parent Label { id: actionLabel Layout.alignment: Qt.AlignHCenter } } background: Rectangle { color: "lightgreen" border.color: "black" radius: 16 } } }