Merge lp:~nik90/unav/revamp-grid-view-code into lp:unav

Proposed by Nekhelesh Ramananthan
Status: Merged
Merged at revision: 15
Proposed branch: lp:~nik90/unav/revamp-grid-view-code
Merge into: lp:unav
Prerequisite: lp:~costales/unav/submenu-for-nearbypage
Diff against target: 564 lines (+209/-251)
5 files modified
qml/CustomGridView.qml (+53/-0)
qml/Nearby.qml (+28/-84)
qml/RoutePage.qml (+37/-83)
qml/SharePage.qml (+28/-84)
qml/components/GridDelegate.qml (+63/-0)
To merge this branch: bzr merge lp:~nik90/unav/revamp-grid-view-code
Reviewer Review Type Date Requested Status
costales Approve
Review via email: mp+290704@code.launchpad.net

This proposal supersedes a proposal from 2016-04-01.

Commit message

- Converted Grid and GridDelegate into generic reuseable components
- Made grid text translatable

Description of the change

This branch essentially refactors the grid view code. I noticed that the same code was used in SharePage.qml, RoutePage.qml and NearBy.qml. So I made it into a generic component and removed a lot of duplicate code.

The same situation applied to the grid delegate which I made into a separate reusable component.

Fixed a bug in trunk where grid view text was not translatable.

To post a comment you must log in.
lp:~nik90/unav/revamp-grid-view-code updated
29. By Nekhelesh Ramananthan

Small tweak based on phone testing

30. By Nekhelesh Ramananthan

Fixed missing Popup import in Share page

Revision history for this message
costales (costales) wrote :

Working perfect for me.

@Joerg? :)

review: Approve
Revision history for this message
JkB (joergberroth) wrote :

Cannot test it right now, but i believe in you two.... :-)

m Freitag, 1. April 2016 15:43:16 CEST schrieb costales
<email address hidden>:
> Review: Approve
>
> Working perfect for me.
>
> @Joerg? :)

--
Versandt, mit Dekko von meinem Ubuntu-Gerät

Revision history for this message
costales (costales) wrote :

Merged then! :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'qml/CustomGridView.qml'
--- qml/CustomGridView.qml 1970-01-01 00:00:00 +0000
+++ qml/CustomGridView.qml 2016-04-01 11:46:32 +0000
@@ -0,0 +1,53 @@
1/*
2 * Copyright (C) 2016 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.4
18
19/*
20 This component provide a grid view similar to the ubuntu settings app. It was adapted from the ubuntu-settings-app found at
21 http://bazaar.launchpad.net/~system-settings-touch/ubuntu-system-settings/trunk/view/head:/src/qml/CategoryGrid.qml
22*/
23
24Grid {
25 id: gridView
26
27 // Public APIs
28 property alias model: repeater.model
29 property alias delegate: repeater.delegate
30
31 //from system-settings (lp:ubuntu-system-settings)
32 property int itemWidth: units.gu(12)
33
34 // The amount of whitespace, including column spacing
35 property int space: Math.min(units.gu(5), parent.width - columns * itemWidth)
36
37 // The column spacing is 1/n of the left/right margins
38 property int n: 1
39
40 rowSpacing: units.gu(6)
41 columnSpacing: space / ((2 * n) + (columns - 1))
42 width: (columns * itemWidth) + columnSpacing * (columns - 1)
43
44 columns: {
45 var items = Math.floor(parent.width / itemWidth)
46 var count = repeater.count
47 return count < items ? count : items
48 }
49
50 Repeater {
51 id: repeater
52 }
53}
054
=== modified file 'qml/Nearby.qml'
--- qml/Nearby.qml 2016-04-01 11:46:32 +0000
+++ qml/Nearby.qml 2016-04-01 11:46:32 +0000
@@ -17,8 +17,7 @@
1717
18import QtQuick 2.418import QtQuick 2.4
19import Ubuntu.Components 1.319import Ubuntu.Components 1.3
20import Ubuntu.Components.Popups 1.320import "components"
21import Ubuntu.Components.ListItems 1.3 as ListItem
2221
23Page {22Page {
24 id: nearbyPage23 id: nearbyPage
@@ -31,7 +30,6 @@
31 iconName: "back"30 iconName: "back"
32 text: i18n.tr("Back")31 text: i18n.tr("Back")
33 shortcut: "Escape"32 shortcut: "Escape"
34 enabled: header === standardHeader
35 onTriggered: {33 onTriggered: {
36 mainPageStack.pop(nearbyPage)34 mainPageStack.pop(nearbyPage)
37 mainPageStack.push(Qt.resolvedUrl("RoutePage.qml"))35 mainPageStack.push(Qt.resolvedUrl("RoutePage.qml"))
@@ -41,98 +39,44 @@
4139
42 Flickable {40 Flickable {
43 id: flickable41 id: flickable
44 anchors.fill: parent42
45 anchors.topMargin: units.gu(6)43 anchors { fill: parent; topMargin: units.gu(4); margins: units.gu(2) }
46 height: contentItem.childrenRect.height44 height: contentItem.childrenRect.height
47 boundsBehavior: (contentHeight > nearbyPage.height) ? Flickable.DragAndOvershootBounds : Flickable.StopAtBounds45 boundsBehavior: (contentHeight > nearbyPage.height) ? Flickable.DragAndOvershootBounds : Flickable.StopAtBounds
4846
49 ListModel {47 ListModel {
50 id: nearbyPageModel48 id: nearbyPageModel
51 ListElement {section: 0 ; text: "Current"; source: "../nav/img/pages/share/current.svg" }49
52 ListElement {section: 1 ; text: "Destination"; source: "../nav/img/pages/share/destination.svg"}50 Component.onCompleted: initialize()
53 ListElement {section: 2 ; text: "From Map"; source: "../nav/img/pages/share/fromMap.svg" }51
52 function initialize() {
53 nearbyPageModel.append({mode: "CURRENT", text: i18n.tr("Current"), source: "../nav/img/pages/share/current.svg", visible: (mainPageStack.center_onpos !== 0 && mainPageStack.currentLat !== "null" && mainPageStack.currentLng !== "null") })
54 nearbyPageModel.append({mode: "DESTINATION", text: i18n.tr("Destination"), source: "../nav/img/pages/share/destination.svg", visible: (mainPageStack.routeState !== 'no' && mainPageStack.endLat !== "null" && mainPageStack.endLng !== "null") })
55 nearbyPageModel.append({mode: "MAP", text: i18n.tr("From Map"), source: "../nav/img/pages/share/fromMap.svg", visible: true })
56 }
54 }57 }
5558
56 Grid {59 CustomGridView {
57 id: nearbyPageGrid60 id: nearbyPageGrid
58 //from system-settings (lp:ubuntu-system-settings)61
59 property int itemWidth: units.gu(14)62 model: nearbyPageModel
60 // The amount of whitespace, including column spacing63 delegate: GridDelegate {
61 property int space: parent.width - columns * itemWidth64 id: delegate
62 // The column spacing is 1/n of the left/right margins65
63 property int n: 166 visible: model.visible
6467 title: model.text
65 columnSpacing: space / ((2 * n) + (columns - 1))68 icon: model.source
66 rowSpacing: units.gu(6)69
67 width: (columns * itemWidth) + columnSpacing * (columns - 1)70 onClicked: {
68 anchors.horizontalCenter: parent.horizontalCenter71 mainPageStack.pop(nearbyPage);
69 columns: {72 if (model.mode === "CURRENT") {
70 var items = Math.floor(parent.width / itemWidth)73 mainPageStack.push(Qt.resolvedUrl("./PoiPage.qml"), {"fromPage": "Nearby.qml", "lat": mainPageStack.currentLat, "lng": mainPageStack.currentLng})
71 var count = repeater.count74 } else if (model.mode === "DESTINATION") {
72 return count < items ? count : items75 mainPageStack.push(Qt.resolvedUrl("./PoiPage.qml"), {"fromPage": "Nearby.qml", "lat": mainPageStack.endLat, "lng": mainPageStack.endLng})
73 }
74
75 Repeater {
76 id: repeater
77 model: nearbyPageModel
78 delegate: Component {
79 id: buttonComponent
80 AbstractButton {
81 id: button
82 width: col.width
83 visible: ((model.section === 0 && (mainPageStack.center_onpos !== 0 && mainPageStack.currentLat !== "null" && mainPageStack.currentLng !== "null")) ||
84 (model.section === 1 && (mainPageStack.routeState !== 'no' && mainPageStack.endLat !== "null" && mainPageStack.endLng !== "null")) ||
85 (model.section === 2))
86 onClicked: {
87 mainPageStack.pop(nearbyPage);
88 if (model.text === "Current") {
89 mainPageStack.push(Qt.resolvedUrl("./PoiPage.qml"), {"fromPage": "Nearby.qml", "lat": mainPageStack.currentLat, "lng": mainPageStack.currentLng})
90 } else if (model.text === "Destination") {
91 mainPageStack.push(Qt.resolvedUrl("./PoiPage.qml"), {"fromPage": "Nearby.qml", "lat": mainPageStack.endLat, "lng": mainPageStack.endLng})
92 }
93 }
94
95 height: col.height
96
97 Column {
98 id: col
99 width: units.gu (14)
100 height: units.gu (8)
101 anchors.left: parent.left
102 anchors.right: parent.right
103
104 Icon {
105 id: icon
106 anchors.horizontalCenter: parent.horizontalCenter
107 width: height
108 height: units.gu(4)
109 source: model.source
110 }
111
112 Label {
113 anchors.horizontalCenter: parent.horizontalCenter
114 anchors.bottom: parent.bottom
115 text: i18n.tr(model.text)
116 width: col.width
117 horizontalAlignment: Text.AlignHCenter
118 fontSize: "small"
119 wrapMode: Text.WrapAtWordBoundaryOrAnywhere
120 }
121 }
122
123 UbuntuShape {
124 z: -1
125 visible: button.pressed
126 anchors{
127 fill: col
128 margins: -units.gu(0.25)
129 }
130 backgroundColor: UbuntuColors.darkGrey
131 opacity: 0.15
132 }
133 }76 }
134 }77 }
135 }78 }
136 }79 }
137 }80 }
138}81}
82
13983
=== modified file 'qml/RoutePage.qml'
--- qml/RoutePage.qml 2016-04-01 11:46:32 +0000
+++ qml/RoutePage.qml 2016-04-01 11:46:32 +0000
@@ -17,6 +17,7 @@
1717
18import QtQuick 2.418import QtQuick 2.4
19import Ubuntu.Components 1.319import Ubuntu.Components 1.3
20import "components"
2021
21Page {22Page {
22 id: routePage23 id: routePage
@@ -31,97 +32,50 @@
31 Flickable {32 Flickable {
32 id: flickable33 id: flickable
3334
34 anchors { fill: parent; margins: units.gu(2); topMargin: units.gu(6) }35 anchors { fill: parent; margins: units.gu(2); topMargin: units.gu(4) }
35 height: contentItem.childrenRect.height36 height: contentItem.childrenRect.height
36 boundsBehavior: (contentHeight > routePage.height) ? Flickable.DragAndOvershootBounds : Flickable.StopAtBounds37 boundsBehavior: (contentHeight > routePage.height) ? Flickable.DragAndOvershootBounds : Flickable.StopAtBounds
3738
38 ListModel {39 ListModel {
39 id: routePageModel40 id: routePageModel
40 ListElement {section: 0 ; text: "Search"; iconName: "../nav/img/pages/route/search.svg" }41 Component.onCompleted: initialize()
41 ListElement {section: 0 ; text: "Favorites"; iconName: "../nav/img/pages/route/favorites.svg" }42
42 ListElement {section: 0 ; text: "Nearby"; iconName: "../nav/img/pages/route/nearby.svg"}43 function initialize() {
43 ListElement {section: 0 ; text: "Coordinates"; iconName: "../nav/img/pages/route/coordinates.svg"}44 routePageModel.append({mode: "SEARCH", text: i18n.tr("Search"), source: "../nav/img/pages/route/search.svg", visible: true})
44 ListElement {section: 0 ; text: "Share"; iconName: "../nav/img/pages/route/share.svg"}45 routePageModel.append({mode: "FAVORITES", text: i18n.tr("Favorites"), source: "../nav/img/pages/route/favorites.svg", visible: true})
45 ListElement {section: 1 ; text: "Cancel Route"; iconName: "../nav/img/pages/route/cancel.svg" }46 routePageModel.append({mode: "NEARBY", text: i18n.tr("Nearby"), source: "../nav/img/pages/route/nearby.svg", visible: true})
47 routePageModel.append({mode: "COORDINATES", text: i18n.tr("Coordinates"), source: "../nav/img/pages/route/coordinates.svg", visible: true})
48 routePageModel.append({mode: "SHARE", text: i18n.tr("Share"), source: "../nav/img/pages/route/share.svg", visible: true})
49 routePageModel.append({mode: "CANCEL", text: i18n.tr("Cancel Route"), source: "../nav/img/pages/route/cancel.svg", visible: mainPageStack.routeState !== 'no'})
50 }
46 }51 }
4752
48 Grid {53 CustomGridView {
49 id: routePageGrid54 id: routePageGrid
50 //from system-settings (lp:ubuntu-system-settings)55
51 property int itemWidth: units.gu(14)56 model: routePageModel
52 // The amount of whitespace, including column spacing57 delegate: GridDelegate {
53 property int space: parent.width - columns * itemWidth58 id: delegate
54 // The column spacing is 1/n of the left/right margins59
55 property int n: 160 title: model.text
5661 icon: model.source
57 columnSpacing: space / ((2 * n) + (columns - 1))62 visible: model.visible
58 rowSpacing: units.gu(6)63
59 width: (columns * itemWidth) + columnSpacing * (columns - 1)64 onClicked: {
60 anchors.horizontalCenter: parent.horizontalCenter65 mainPageStack.pop(routePage)
61 columns: {66 if (model.mode === "FAVORITES") {
62 var items = Math.floor(parent.width / itemWidth)67 mainPageStack.push(Qt.resolvedUrl("FavoritesPage.qml"))
63 var count = repeater.count68 } else if (model.mode === "SEARCH") {
64 return count < items ? count : items69 mainPageStack.push(Qt.resolvedUrl("SearchPage.qml"))
65 }70 } else if (model.mode === "NEARBY") {
6671 mainPageStack.push(Qt.resolvedUrl("Nearby.qml"))
67 Repeater {72 } else if (model.mode === "COORDINATES") {
68 id: repeater73 mainPageStack.push(Qt.resolvedUrl("Coordinate.qml"))
6974 } else if (model.mode === "SHARE") {
70 model: routePageModel75 mainPageStack.push(Qt.resolvedUrl("SharePage.qml"))
7176 } else if (model.mode === "CANCEL") {
72 delegate: AbstractButton {77 mainPageStack.routeState = 'no';
73 id: button78 mainPageStack.executeJavaScript("click_cancel_route();")
74
75 width: col.width
76 height: col.height
77 visible: (model.section === 0 || (model.section === 1 && mainPageStack.routeState !== 'no'))
78
79 UbuntuShape {
80 opacity: 0.15
81 visible: button.pressed
82 anchors { fill: col; margins: -units.gu(1) }
83 backgroundColor: UbuntuColors.darkGrey
84 }
85
86 Column {
87 id: col
88
89 spacing: units.gu(2)
90 width: units.gu (14)
91
92 Icon {
93 width: height
94 height: units.gu(4)
95 source: model.iconName
96 anchors.horizontalCenter: parent.horizontalCenter
97 }
98
99 Label {
100 width: col.width
101 fontSize: "small"
102 text: i18n.tr(model.text)
103 horizontalAlignment: Text.AlignHCenter
104 wrapMode: Text.WrapAtWordBoundaryOrAnywhere
105 anchors.horizontalCenter: parent.horizontalCenter
106 }
107 }
108
109 onClicked: {
110 mainPageStack.pop(routePage)
111 if (model.text === "Favorites") {
112 mainPageStack.push(Qt.resolvedUrl("FavoritesPage.qml"))
113 } else if (model.text === "Search") {
114 mainPageStack.push(Qt.resolvedUrl("SearchPage.qml"))
115 } else if (model.text === "Nearby") {
116 mainPageStack.push(Qt.resolvedUrl("Nearby.qml"))
117 } else if (model.text === "Coordinates") {
118 mainPageStack.push(Qt.resolvedUrl("Coordinate.qml"))
119 } else if (model.text === "Share") {
120 mainPageStack.push(Qt.resolvedUrl("SharePage.qml"))
121 } else if (model.text === "Cancel Route") {
122 mainPageStack.routeState = 'no';
123 mainPageStack.executeJavaScript("click_cancel_route();")
124 }
125 }79 }
126 }80 }
127 }81 }
12882
=== modified file 'qml/SharePage.qml'
--- qml/SharePage.qml 2016-04-01 11:46:32 +0000
+++ qml/SharePage.qml 2016-04-01 11:46:32 +0000
@@ -18,7 +18,7 @@
18import QtQuick 2.418import QtQuick 2.4
19import Ubuntu.Components 1.319import Ubuntu.Components 1.3
20import Ubuntu.Components.Popups 1.320import Ubuntu.Components.Popups 1.3
21import Ubuntu.Components.ListItems 1.3 as ListItem21import "components"
2222
23Page {23Page {
24 id: sharePage24 id: sharePage
@@ -31,7 +31,6 @@
31 iconName: "back"31 iconName: "back"
32 text: i18n.tr("Back")32 text: i18n.tr("Back")
33 shortcut: "Escape"33 shortcut: "Escape"
34 enabled: header === standardHeader
35 onTriggered: {34 onTriggered: {
36 mainPageStack.pop(sharePage)35 mainPageStack.pop(sharePage)
37 mainPageStack.push(Qt.resolvedUrl("RoutePage.qml"))36 mainPageStack.push(Qt.resolvedUrl("RoutePage.qml"))
@@ -41,96 +40,41 @@
4140
42 Flickable {41 Flickable {
43 id: flickable42 id: flickable
44 anchors.fill: parent43
45 anchors.topMargin: units.gu(6)44 anchors { fill: parent; topMargin: units.gu(4); margins: units.gu(2) }
46 height: contentItem.childrenRect.height45 height: contentItem.childrenRect.height
47 boundsBehavior: (contentHeight > sharePage.height) ? Flickable.DragAndOvershootBounds : Flickable.StopAtBounds46 boundsBehavior: (contentHeight > sharePage.height) ? Flickable.DragAndOvershootBounds : Flickable.StopAtBounds
4847
49 ListModel {48 ListModel {
50 id: sharePageModel49 id: sharePageModel
51 ListElement {section: 0 ; text: "Current"; source: "../nav/img/pages/share/current.svg" }50
52 ListElement {section: 1 ; text: "Destination"; source: "../nav/img/pages/share/destination.svg"}51 Component.onCompleted: initialize()
53 ListElement {section: 2 ; text: "From Map"; source: "../nav/img/pages/share/fromMap.svg" }52
53 function initialize() {
54 sharePageModel.append({mode: "CURRENT", text: i18n.tr("Current"), source: "../nav/img/pages/share/current.svg", visible: (mainPageStack.center_onpos !== 0 && mainPageStack.currentLat !== "null" && mainPageStack.currentLng !== "null") })
55 sharePageModel.append({mode: "DESTINATION", text: i18n.tr("Destination"), source: "../nav/img/pages/share/destination.svg", visible: (mainPageStack.routeState !== 'no' && mainPageStack.endLat !== "null" && mainPageStack.endLng !== "null") })
56 sharePageModel.append({mode: "MAP", text: i18n.tr("From Map"), source: "../nav/img/pages/share/fromMap.svg", visible: true })
57 }
54 }58 }
5559
56 Grid {60 CustomGridView {
57 id: sharePageGrid61 id: sharePageGrid
58 //from system-settings (lp:ubuntu-system-settings)62
59 property int itemWidth: units.gu(14)63 model: sharePageModel
60 // The amount of whitespace, including column spacing64 delegate: GridDelegate {
61 property int space: parent.width - columns * itemWidth65 id: delegate
62 // The column spacing is 1/n of the left/right margins66
63 property int n: 167 title: model.text
6468 icon: model.source
65 columnSpacing: space / ((2 * n) + (columns - 1))69 visible: model.visible
66 rowSpacing: units.gu(6)70
67 width: (columns * itemWidth) + columnSpacing * (columns - 1)71 onClicked: {
68 anchors.horizontalCenter: parent.horizontalCenter72 if (model.mode === "CURRENT") {
69 columns: {73 PopupUtils.open(Qt.resolvedUrl("./Share.qml"), navApp, {"lat": mainPageStack.currentLat, "lon": mainPageStack.currentLng})
70 var items = Math.floor(parent.width / itemWidth)74 } else if (model.model === "DESTINATION") {
71 var count = repeater.count75 PopupUtils.open(Qt.resolvedUrl("./Share.qml"), navApp, {"lat": mainPageStack.endLat, "lon": mainPageStack.endLng})
72 return count < items ? count : items76 } else if (model.mode === "MAP") {
73 }77 mainPageStack.pop(sharePage); // Show map
74
75 Repeater {
76 id: repeater
77 model: sharePageModel
78 delegate: Component {
79 id: buttonComponent
80 AbstractButton {
81 id: button
82 width: col.width
83 visible: ((model.section === 0 && (mainPageStack.center_onpos !== 0 && mainPageStack.currentLat !== "null" && mainPageStack.currentLng !== "null")) ||
84 (model.section === 1 && (mainPageStack.routeState !== 'no' && mainPageStack.endLat !== "null" && mainPageStack.endLng !== "null")) ||
85 (model.section === 2))
86 onClicked: {
87 if (model.text === "Current") {
88 PopupUtils.open(Qt.resolvedUrl("./Share.qml"), navApp, {"lat": mainPageStack.currentLat, "lon": mainPageStack.currentLng})
89 } else if (model.text === "Destination") {
90 PopupUtils.open(Qt.resolvedUrl("./Share.qml"), navApp, {"lat": mainPageStack.endLat, "lon": mainPageStack.endLng})
91 } else if (model.text === "From Map") {
92 mainPageStack.pop(sharePage); // Show map
93 }
94 }
95
96 height: col.height
97
98 Column {
99 id: col
100 width: units.gu (14)
101 height: units.gu (8)
102 anchors.left: parent.left
103 anchors.right: parent.right
104
105 Icon {
106 id: icon
107 anchors.horizontalCenter: parent.horizontalCenter
108 width: height
109 height: units.gu(4)
110 source: model.source
111 }
112
113 Label {
114 anchors.horizontalCenter: parent.horizontalCenter
115 anchors.bottom: parent.bottom
116 text: i18n.tr(model.text)
117 width: col.width
118 horizontalAlignment: Text.AlignHCenter
119 fontSize: "small"
120 wrapMode: Text.WrapAtWordBoundaryOrAnywhere
121 }
122 }
123
124 UbuntuShape {
125 z: -1
126 visible: button.pressed
127 anchors{
128 fill: col
129 margins: -units.gu(0.25)
130 }
131 backgroundColor: UbuntuColors.darkGrey
132 opacity: 0.15
133 }
134 }78 }
135 }79 }
136 }80 }
13781
=== added file 'qml/components/GridDelegate.qml'
--- qml/components/GridDelegate.qml 1970-01-01 00:00:00 +0000
+++ qml/components/GridDelegate.qml 2016-04-01 11:46:32 +0000
@@ -0,0 +1,63 @@
1/*
2 * uNav http://launchpad.net/unav
3 * Copyright (C) 2016 Nekhelesh Ramananthan https://launchpad.net/~nik90
4 *
5 * uNav is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * uNav is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16import QtQuick 2.4
17import Ubuntu.Components 1.3
18
19AbstractButton {
20 id: gridDelegate
21
22 // Public APIs
23 property string title
24 property alias icon: _icon.source
25
26 width: delegateColumn.width
27 height: delegateColumn.height
28
29 Loader {
30 sourceComponent: gridDelegate.pressed ? backgroundComponent : undefined
31 anchors { fill: delegateColumn; margins: -units.gu(1) }
32 }
33
34 Component {
35 id: backgroundComponent
36 UbuntuShape {
37 opacity: 0.15
38 backgroundColor: UbuntuColors.darkGrey
39 }
40 }
41
42 Column {
43 id: delegateColumn
44
45 width: units.gu(12)
46 spacing: units.gu(2)
47
48 Icon {
49 id: _icon
50 width: height
51 height: units.gu(4)
52 anchors.horizontalCenter: parent.horizontalCenter
53 }
54
55 Label {
56 width: parent.width
57 textSize: Label.Small
58 text: title
59 horizontalAlignment: Text.AlignHCenter
60 wrapMode: Text.WrapAtWordBoundaryOrAnywhere
61 }
62 }
63}

Subscribers

People subscribed via source and target branches