on xenial help sign in
Use a regular expression instead of two custom JavaScript-functions for the icon-label split of the action-label.
commit073268b2d2b2969d8d9bb534cda94486332560f7 authorMirco Müller <mirco.mueller@ubuntu.com> dateMon 23 Jun 2014, 16:25 (12 years ago) parenta5b7060
1 file changed+3−12
qml/Notifications/Notification.qml+3−12
qml/Notifications/Notification.qml+3−12
@@ -359,6 +359,7 @@ Item {
359359 visible: status == Loader.Ready
360360 property string actionId: id
361361 property string actionLabel: label
362+ readonly property var splitLabel: actionLabel.match(/(^([a-z]+):)?(.*)$/)
362363 Component {
363364 id: comboEntry
364365
@@ -369,16 +370,6 @@ Item {
369370 width: comboButton.width
370371 height: comboIcon.height + units.gu(2)
371372
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−
382373 onClicked: {
383374 notification.notification.invokeAction(actionId)
384375 }
@@ -401,7 +392,7 @@ Item {
401392 width: units.gu(2)
402393 height: units.gu(2)
403394 color: "white"
404− name: getComboIcon(actionLabel)
395+ name: splitLabel[2]
405396 }
406397
407398 Label {
@@ -414,7 +405,7 @@ Item {
414405 }
415406 fontSize: "small"
416407 color: "white"
417− text: getComboLabel(actionLabel)
408+ text: splitLabel[3]
418409 }
419410 }
420411 }