on xenial help sign in
Use a regular expression instead of two custom JavaScript-functions for the icon-label split of the action-label.
073268bMirco Müller
qml/Notifications/Notification.qml+3−12
@@ -359,6 +359,7 @@ Item {
359 visible: status == Loader.Ready
359 visible: status == Loader.Ready
360 property string actionId: id
360 property string actionId: id
361 property string actionLabel: label
361 property string actionLabel: label
362+ readonly property var splitLabel: actionLabel.match(/(^([a-z]+):)?(.*)$/)
362 Component {
363 Component {
363 id: comboEntry
364 id: comboEntry
364
365
@@ -369,16 +370,6 @@ Item {
369 width: comboButton.width
370 width: comboButton.width
370 height: comboIcon.height + units.gu(2)
371 height: comboIcon.height + units.gu(2)
371
372
372− function getComboIcon(str) {
373− var result = str.split(":")
374− return result[0]
375− }
376−
377− function getComboLabel(str) {
378− var result = str.split(":")
379− return result[1]
380− }
381−
382 onClicked: {
373 onClicked: {
383 notification.notification.invokeAction(actionId)
374 notification.notification.invokeAction(actionId)
384 }
375 }
@@ -401,7 +392,7 @@ Item {
401 width: units.gu(2)
392 width: units.gu(2)
402 height: units.gu(2)
393 height: units.gu(2)
403 color: "white"
394 color: "white"
404− name: getComboIcon(actionLabel)
395+ name: splitLabel[2]
405 }
396 }
406
397
407 Label {
398 Label {
@@ -414,7 +405,7 @@ Item {
414 }
405 }
415 fontSize: "small"
406 fontSize: "small"
416 color: "white"
407 color: "white"
417− text: getComboLabel(actionLabel)
408+ text: splitLabel[3]
418 }
409 }
419 }
410 }
420 }
411 }