diff --git a/applets/notifications/package/contents/ui/NotificationDelegate.qml b/applets/notifications/package/contents/ui/NotificationDelegate.qml --- a/applets/notifications/package/contents/ui/NotificationDelegate.qml +++ b/applets/notifications/package/contents/ui/NotificationDelegate.qml @@ -33,6 +33,9 @@ opacity: 1-Math.abs(x)/width + enabled: true + checked: notificationItem.containsMouse + Timer { interval: 10*60*1000 repeat: false @@ -66,6 +69,14 @@ } } + onClicked: { + if (model.hasDefaultAction) { + executeAction(model.source, "default") + } else { + notification.close(); + } + } + SequentialAnimation { id: removeAnimation property bool exitFromRight: true @@ -142,7 +153,7 @@ configureNotification(model.appRealName, model.eventId) } onAction: { - executeAction(source, actionId) + executeAction(model.source, actionId) actions.clear() } onOpenUrl: { diff --git a/applets/notifications/package/contents/ui/NotificationItem.qml b/applets/notifications/package/contents/ui/NotificationItem.qml --- a/applets/notifications/package/contents/ui/NotificationItem.qml +++ b/applets/notifications/package/contents/ui/NotificationItem.qml @@ -55,6 +55,8 @@ property ListModel actions: ListModel { } + property bool hasDefaultAction: false; + function pressedAction() { for (var i = 0, count = actionRepeater.count; i < count; ++i) { var item = actionRepeater.itemAt(i) @@ -74,6 +76,10 @@ return settingsButton } + if (closeButton.pressed) { + return closeButton + } + return null } diff --git a/applets/notifications/package/contents/ui/NotificationPopup.qml b/applets/notifications/package/contents/ui/NotificationPopup.qml --- a/applets/notifications/package/contents/ui/NotificationPopup.qml +++ b/applets/notifications/package/contents/ui/NotificationPopup.qml @@ -89,8 +89,13 @@ return } - closeNotification(notificationProperties.source) - // the popup will be closed in response to sourceRemoved + if (notificationItem.hasDefaultAction) { + // the notifications was clicked, trigger the default action if set + notificationItem.action("default") + } else { + closeNotification(notificationProperties.source) + // the popup will be closed in response to sourceRemoved + } } onContainsMouseChanged: { if (containsMouse) { @@ -120,6 +125,7 @@ // explicit true/false or else it complains about assigning undefined to bool configurable: notificationProperties.configurable && !Settings.isMobile ? true : false urls: notificationProperties.urls || [] + hasDefaultAction: notificationProperties.hasDefaultAction width: Math.round(23 * units.gridUnit) maximumTextHeight: theme.mSize(theme.defaultFont).height * 10 diff --git a/applets/notifications/package/contents/ui/Notifications.qml b/applets/notifications/package/contents/ui/Notifications.qml --- a/applets/notifications/package/contents/ui/Notifications.qml +++ b/applets/notifications/package/contents/ui/Notifications.qml @@ -176,12 +176,17 @@ onNewData: { var _data = data; // Temp copy to avoid lots of context switching var actions = [] + _data["hasDefaultAction"] = false if (data["actions"] && data["actions"].length % 2 == 0) { for (var i = 0; i < data["actions"].length; i += 2) { - actions.push({ - id: data["actions"][i], - text: data["actions"][i+1] - }) + if (data["actions"][i] == "default") { // The default action is not shown, but we want to know it's there + _data["hasDefaultAction"] = true + } else { + actions.push({ + id: data["actions"][i], + text: data["actions"][i+1] + }) + } } } _data["source"] = sourceName