on xenial help sign in
Add support for styling preview buttons. Remove deprecated support for icons in buttons.
commit43f2b8a9727dc829d8978f17a357137b5a44c6b3 authorMichał Sawicz <michal.sawicz@canonical.com> dateThu 14 Aug 2014, 14:01 (12 years ago) parent9b3577d
4 files changed+21−14
qml/Dash/Previews/PreviewActionButton.qml+1−4 qml/Dash/Previews/PreviewActionCombo.qml+4−2 qml/Dash/Previews/PreviewActions.qml+8 tests/qmltests/Dash/Previews/tst_PreviewActions.qml+8−8
qml/Dash/Previews/PreviewActionButton.qml+1−4
@@ -15,16 +15,13 @@
1515 */
1616
1717import QtQuick 2.0
18−import Ubuntu.Components 0.1
18+import Ubuntu.Components 1.1
1919
2020Button {
2121 signal triggeredAction(var actionData)
2222
2323 property var data: null
2424 objectName: "button" + (data && data.id || "")
25− color: Theme.palette.selected.foreground
2625 text: data && data.label || ""
27− iconSource: data && data.icon || ""
28− iconPosition: "left"
2926 onClicked: triggeredAction(data)
3027}
qml/Dash/Previews/PreviewActionCombo.qml+4−2
@@ -15,7 +15,7 @@
1515 */
1616
1717import QtQuick 2.0
18−import Ubuntu.Components 0.1
18+import Ubuntu.Components 1.1
1919
2020Item {
2121 id: root
@@ -25,6 +25,7 @@ Item {
2525 signal triggeredAction(var actionData)
2626
2727 property alias model: actionRepeater.model
28+ property color strokeColor: Theme.palette.normal.textBase
2829
2930 Button {
3031 id: moreButton
@@ -32,7 +33,7 @@ Item {
3233
3334 objectName: "moreLessButton"
3435 text: !expanded ? i18n.tr("More...") : i18n.tr("Less...")
35− color: Theme.palette.selected.foreground
36+ strokeColor: root.strokeColor
3637 onClicked: expanded = !expanded
3738 width: parent.width
3839 }
@@ -60,6 +61,7 @@ Item {
6061 data: modelData
6162 width: implicitWidth < parent.width ? parent.width : implicitWidth
6263 onClicked: root.triggeredAction(modelData)
64+ strokeColor: root.strokeColor
6365 }
6466 }
6567 }
qml/Dash/Previews/PreviewActions.qml+8
@@ -24,6 +24,8 @@ import QtQuick 2.1
2424PreviewWidget {
2525 id: root
2626
27+ property var scopeStyle: null
28+
2729 height: row.height + units.gu(1)
2830
2931 Row {
@@ -46,6 +48,11 @@ PreviewWidget {
4648 item.model = row.actions.slice(1);
4749 }
4850 }
51+ Binding {
52+ target: loader.item
53+ property: "strokeColor"
54+ value: root.scopeStyle ? root.scopeStyle.foreground : Theme.palette.normal.baseText
55+ }
4956 Connections {
5057 target: loader.item
5158 onTriggeredAction: {
@@ -59,6 +66,7 @@ PreviewWidget {
5966 visible: row.actions && row.actions.length > 0
6067 onTriggeredAction: root.triggered(root.widgetId, actionData.id, actionData)
6168 width: (root.width - units.gu(1)) / 2
69+ color: root.scopeStyle ? root.scopeStyle.previewButtonColor : Theme.palette.selected.foreground
6270 }
6371 }
6472}
tests/qmltests/Dash/Previews/tst_PreviewActions.qml+8−8
@@ -27,21 +27,21 @@ Rectangle {
2727 height: units.gu(80)
2828
2929 property var actionDataOneAction: {
30− "actions": [{"label": "Some Label", "icon": "../graphics/play_button.png", "id": "someid"}]
30+ "actions": [{"label": "Some Label", "id": "someid"}]
3131 }
3232
3333 property var actionDataTwoActions: {
34− "actions": [{"label": "Some Label A", "icon": "../graphics/icon_clear.png", "id": "someid1"},
35− {"label": "Some Label B", "icon": "../graphics/play_button.png", "id": "someid2"}
34+ "actions": [{"label": "Some Label A", "id": "someid1"},
35+ {"label": "Some Label B", "id": "someid2"}
3636 ]
3737 }
3838
3939 property var actionDataFiveActions: {
40− "actions": [{"label": "Some Label C", "icon": "../graphics/play_button.png", "id": "someid3"},
41− {"label": "Some Label D", "icon": "../graphics/icon_clear.png", "id": "someid4"},
42− {"label": "Some Label E", "icon": "../graphics/play_button.png", "id": "someid5"},
43− {"label": "Some Label F", "icon": "../graphics/icon_clear.png", "id": "someid6"},
44− {"label": "Some Label G", "icon": "../graphics/play_button.png", "id": "someid7"}
40+ "actions": [{"label": "Some Label C", "id": "someid3"},
41+ {"label": "Some Label D", "id": "someid4"},
42+ {"label": "Some Label E", "id": "someid5"},
43+ {"label": "Some Label F", "id": "someid6"},
44+ {"label": "Some Label G", "id": "someid7"}
4545 ]
4646 }
4747