on 14dd930 help sign in
unity8/Panel/Menus/Overview/OverviewGrid.qml
135 lines 3.9 kB history raw
1/*
2 * Copyright (C) 2013 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
17import QtQuick 2.0
18import Ubuntu.Components 0.1
20import "../../../Components/ListItems" as ListItems
22Item {
23 id: overviewGrid
25 height: childrenRect.height
27 property var model
29 UbuntuShape {
30 id: gridBackground
31 anchors.fill: grid
32 color: "#282421"
33 radius: "medium"
34 }
36 GridView {
37 id: grid
38 objectName: "overviewGrid"
40 property int columnCount: 3
41 property int rowCount: Math.ceil(model.count / columnCount)
43 anchors {
44 top: parent.top
45 left: parent.left
46 right: parent.right
47 topMargin: units.gu(3)
48 leftMargin: units.gu(2)
49 rightMargin: units.gu(2)
50 }
51 height: cellWidth * rowCount
52 cellWidth: Math.floor((width) / columnCount)
53 cellHeight: cellWidth
54 model: overviewGrid.model
55 visible: opacity != 0
56 interactive: false
57 delegate:
58 AbstractButton {
59 objectName: "overviewGridButton" + index
60 width: grid.cellWidth
61 height: grid.cellHeight
63 Loader {
64 id: loader
65 source: widgetSource
67 width: units.gu(5)
68 height: units.gu(5)
69 anchors.centerIn: parent
70 anchors.verticalCenterOffset: -units.gu(1)
72 onLoaded: {
73 for(var pName in indicatorProperties) {
74 if (item.hasOwnProperty(pName)) {
75 item[pName] = indicatorProperties[pName]
76 }
77 }
78 }
79 }
81 Label {
82 text: title
83 color: "#f3f3e7"
84 fontSize: "small"
85 anchors {
86 left: parent.left
87 right: parent.right
88 bottom: parent.bottom
89 leftMargin: units.gu(0.5)
90 rightMargin: units.gu(0.5)
91 bottomMargin: units.gu(1.5)
92 }
93 elide: Text.ElideRight
94 horizontalAlignment: Text.AlignHCenter
96 }
97 onClicked: overview.menuSelected(index)
98 }
99 }
101 Item {
102 id: gridOverlay
103 anchors.fill: grid
105 Column {
106 anchors {
107 left: parent.left
108 right: parent.right
109 }
110 spacing: grid.cellHeight
111 y: grid.cellHeight - units.dp(1)
112 Repeater {
113 model: grid.rowCount - 1
114 ListItems.ThinDivider {
115 anchors.margins: units.dp(1)
116 }
117 }
118 }
120 Row {
121 anchors {
122 top: parent.top
123 bottom: parent.bottom
124 }
125 spacing: grid.cellWidth - units.dp(1)
126 x: grid.cellWidth - units.dp(1)
127 Repeater {
128 model: grid.columnCount - 1
129 ListItems.VerticalThinDivider {
130 anchors.margins: units.dp(1)
131 }
132 }
133 }
134 }