on xenial help sign in
Add support for styling preview buttons. Remove deprecated support for icons in buttons.
43f2b8aMichał Sawicz
qml/Dash/Previews/PreviewActionButton.qml+1−4
@@ -15,16 +15,13 @@
15 */
15 */
16
16
17import QtQuick 2.0
17import QtQuick 2.0
18−import Ubuntu.Components 0.1
18+import Ubuntu.Components 1.1
19
19
20Button {
20Button {
21 signal triggeredAction(var actionData)
21 signal triggeredAction(var actionData)
22
22
23 property var data: null
23 property var data: null
24 objectName: "button" + (data && data.id || "")
24 objectName: "button" + (data && data.id || "")
25− color: Theme.palette.selected.foreground
26 text: data && data.label || ""
25 text: data && data.label || ""
27− iconSource: data && data.icon || ""
28− iconPosition: "left"
29 onClicked: triggeredAction(data)
26 onClicked: triggeredAction(data)
30}
27}
qml/Dash/Previews/PreviewActionCombo.qml+4−2
@@ -15,7 +15,7 @@
15 */
15 */
16
16
17import QtQuick 2.0
17import QtQuick 2.0
18−import Ubuntu.Components 0.1
18+import Ubuntu.Components 1.1
19
19
20Item {
20Item {
21 id: root
21 id: root
@@ -25,6 +25,7 @@ Item {
25 signal triggeredAction(var actionData)
25 signal triggeredAction(var actionData)
26
26
27 property alias model: actionRepeater.model
27 property alias model: actionRepeater.model
28+ property color strokeColor: Theme.palette.normal.textBase
28
29
29 Button {
30 Button {
30 id: moreButton
31 id: moreButton
@@ -32,7 +33,7 @@ Item {
32
33
33 objectName: "moreLessButton"
34 objectName: "moreLessButton"
34 text: !expanded ? i18n.tr("More...") : i18n.tr("Less...")
35 text: !expanded ? i18n.tr("More...") : i18n.tr("Less...")
35− color: Theme.palette.selected.foreground
36+ strokeColor: root.strokeColor
36 onClicked: expanded = !expanded
37 onClicked: expanded = !expanded
37 width: parent.width
38 width: parent.width
38 }
39 }
@@ -60,6 +61,7 @@ Item {
60 data: modelData
61 data: modelData
61 width: implicitWidth < parent.width ? parent.width : implicitWidth
62 width: implicitWidth < parent.width ? parent.width : implicitWidth
62 onClicked: root.triggeredAction(modelData)
63 onClicked: root.triggeredAction(modelData)
64+ strokeColor: root.strokeColor
63 }
65 }
64 }
66 }
65 }
67 }
qml/Dash/Previews/PreviewActions.qml+8
@@ -24,6 +24,8 @@ import QtQuick 2.1
24PreviewWidget {
24PreviewWidget {
25 id: root
25 id: root
26
26
27+ property var scopeStyle: null
28+
27 height: row.height + units.gu(1)
29 height: row.height + units.gu(1)
28
30
29 Row {
31 Row {
@@ -46,6 +48,11 @@ PreviewWidget {
46 item.model = row.actions.slice(1);
48 item.model = row.actions.slice(1);
47 }
49 }
48 }
50 }
51+ Binding {
52+ target: loader.item
53+ property: "strokeColor"
54+ value: root.scopeStyle ? root.scopeStyle.foreground : Theme.palette.normal.baseText
55+ }
49 Connections {
56 Connections {
50 target: loader.item
57 target: loader.item
51 onTriggeredAction: {
58 onTriggeredAction: {
@@ -59,6 +66,7 @@ PreviewWidget {
59 visible: row.actions && row.actions.length > 0
66 visible: row.actions && row.actions.length > 0
60 onTriggeredAction: root.triggered(root.widgetId, actionData.id, actionData)
67 onTriggeredAction: root.triggered(root.widgetId, actionData.id, actionData)
61 width: (root.width - units.gu(1)) / 2
68 width: (root.width - units.gu(1)) / 2
69+ color: root.scopeStyle ? root.scopeStyle.previewButtonColor : Theme.palette.selected.foreground
62 }
70 }
63 }
71 }
64}
72}
tests/qmltests/Dash/Previews/tst_PreviewActions.qml+8−8
@@ -27,21 +27,21 @@ Rectangle {
27 height: units.gu(80)
27 height: units.gu(80)
28
28
29 property var actionDataOneAction: {
29 property var actionDataOneAction: {
30− "actions": [{"label": "Some Label", "icon": "../graphics/play_button.png", "id": "someid"}]
30+ "actions": [{"label": "Some Label", "id": "someid"}]
31 }
31 }
32
32
33 property var actionDataTwoActions: {
33 property var actionDataTwoActions: {
34− "actions": [{"label": "Some Label A", "icon": "../graphics/icon_clear.png", "id": "someid1"},
34+ "actions": [{"label": "Some Label A", "id": "someid1"},
35− {"label": "Some Label B", "icon": "../graphics/play_button.png", "id": "someid2"}
35+ {"label": "Some Label B", "id": "someid2"}
36 ]
36 ]
37 }
37 }
38
38
39 property var actionDataFiveActions: {
39 property var actionDataFiveActions: {
40− "actions": [{"label": "Some Label C", "icon": "../graphics/play_button.png", "id": "someid3"},
40+ "actions": [{"label": "Some Label C", "id": "someid3"},
41− {"label": "Some Label D", "icon": "../graphics/icon_clear.png", "id": "someid4"},
41+ {"label": "Some Label D", "id": "someid4"},
42− {"label": "Some Label E", "icon": "../graphics/play_button.png", "id": "someid5"},
42+ {"label": "Some Label E", "id": "someid5"},
43− {"label": "Some Label F", "icon": "../graphics/icon_clear.png", "id": "someid6"},
43+ {"label": "Some Label F", "id": "someid6"},
44− {"label": "Some Label G", "icon": "../graphics/play_button.png", "id": "someid7"}
44+ {"label": "Some Label G", "id": "someid7"}
45 ]
45 ]
46 }
46 }
47
47