on xenial help sign in
Allow ENTER/RETURN in a TextField to accept a snap-decision notification.
bf7825bMirco Müller
qml/Notifications/Notification.qml+1
@@ -344,6 +344,7 @@ Item {
344 objectName: "button" + index
344 objectName: "button" + index
345 width: buttonRow.width / 2 - spacing
345 width: buttonRow.width / 2 - spacing
346 text: loader.actionLabel
346 text: loader.actionLabel
347+ property string actionId: loader.actionId
347 gradient: notification.hints["x-canonical-private-button-tint"] == "true" && index == 0 ? greenGradient : darkgreyGradient
348 gradient: notification.hints["x-canonical-private-button-tint"] == "true" && index == 0 ? greenGradient : darkgreyGradient
348 onClicked: notification.notification.invokeAction(loader.actionId)
349 onClicked: notification.notification.invokeAction(loader.actionId)
349 }
350 }
qml/Notifications/NotificationMenuItemFactory.qml+19
@@ -65,6 +65,21 @@ Loader {
65 text: menuData.label
65 text: menuData.label
66 }
66 }
67
67
68+ function findChild(obj, objectName) {
69+ var childs = new Array(0);
70+ childs.push(obj)
71+ while (childs.length > 0) {
72+ if (childs[0].objectName == objectName) {
73+ return childs[0]
74+ }
75+ for (var i in childs[0]["children"]) {
76+ childs.push(childs[0]["children"][i])
77+ }
78+ childs.splice(0, 1);
79+ }
80+ return null;
81+ }
82+
68 TextField {
83 TextField {
69 id: textfield
84 id: textfield
70
85
@@ -79,6 +94,10 @@ Loader {
79 onTextChanged: {
94 onTextChanged: {
80 menuModel.changeState(menuIndex, text);
95 menuModel.changeState(menuIndex, text);
81 }
96 }
97+ onAccepted: {
98+ var accept = findChild(notification, "button0")
99+ notification.notification.invokeAction(accept.actionId)
100+ }
82 }
101 }
83
102
84 Row {
103 Row {