~unity-team/unity8/trunk

« back to all changes in this revision

Viewing changes to Panel/Menus/Overview/OverviewGrid.qml

  • Committer: Michał Sawicz
  • Date: 2013-06-05 22:03:08 UTC
  • Revision ID: michal.sawicz@canonical.com-20130605220308-yny8fv3futtr04fg
Inital unity8 commit.

Previous history can be found at https://code.launchpad.net/~unity-team/unity/phablet

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 */
 
16
 
 
17
import QtQuick 2.0
 
18
import Ubuntu.Components 0.1
 
19
 
 
20
import "../../../Components/ListItems" as ListItems
 
21
 
 
22
Item {
 
23
    id: overviewGrid
 
24
 
 
25
    height: childrenRect.height
 
26
 
 
27
    property var model
 
28
 
 
29
    UbuntuShape {
 
30
        id: gridBackground
 
31
        anchors.fill: grid
 
32
        color: "#282421"
 
33
        radius: "medium"
 
34
    }
 
35
 
 
36
    GridView {
 
37
        id: grid
 
38
        objectName: "overviewGrid"
 
39
 
 
40
        property int columnCount: 3
 
41
        property int rowCount: Math.ceil(model.count / columnCount)
 
42
 
 
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
 
62
                Image {
 
63
                    id: imageIcon
 
64
                    objectName: "overviewGridButtonImage"
 
65
                    source: iconSource
 
66
                    width: units.gu(4)
 
67
                    height: units.gu(4)
 
68
                    anchors {
 
69
                        centerIn: parent
 
70
                        verticalCenterOffset: -units.gu(1)
 
71
                    }
 
72
                    sourceSize.width: width
 
73
                    sourceSize.height: height
 
74
                    visible: labelIcon.text === ""
 
75
                }
 
76
 
 
77
                Label {
 
78
                    id: labelIcon
 
79
                    text: label
 
80
                    color: "#f3f3e7"
 
81
                    opacity: 0.8
 
82
                    font.family: "Ubuntu"
 
83
                    fontSize: "large"
 
84
                    anchors {
 
85
                        centerIn: parent
 
86
                        verticalCenterOffset: -units.gu(1)
 
87
                    }
 
88
                }
 
89
 
 
90
                Label {
 
91
                    text: title
 
92
                    color: "#f3f3e7"
 
93
                    fontSize: "small"
 
94
                    anchors {
 
95
                        left: parent.left
 
96
                        right: parent.right
 
97
                        bottom: parent.bottom
 
98
                        leftMargin: units.gu(0.5)
 
99
                        rightMargin: units.gu(0.5)
 
100
                        bottomMargin: units.gu(1.5)
 
101
                    }
 
102
                    elide: Text.ElideRight
 
103
                    horizontalAlignment: Text.AlignHCenter
 
104
 
 
105
                }
 
106
                onClicked: overview.menuSelected(index)
 
107
            }
 
108
    }
 
109
 
 
110
    Item {
 
111
        id: gridOverlay
 
112
        anchors.fill: grid
 
113
 
 
114
        Column {
 
115
            anchors {
 
116
                left: parent.left
 
117
                right: parent.right
 
118
            }
 
119
            spacing: grid.cellHeight
 
120
            y: grid.cellHeight - units.dp(1)
 
121
            Repeater {
 
122
                model: grid.rowCount - 1
 
123
                ListItems.ThinDivider {
 
124
                    anchors.margins: units.dp(1)
 
125
                }
 
126
            }
 
127
        }
 
128
 
 
129
        Row {
 
130
            anchors {
 
131
                top: parent.top
 
132
                bottom: parent.bottom
 
133
            }
 
134
            spacing: grid.cellWidth - units.dp(1)
 
135
            x: grid.cellWidth - units.dp(1)
 
136
            Repeater {
 
137
                model: grid.columnCount - 1
 
138
                ListItems.VerticalThinDivider {
 
139
                    anchors.margins: units.dp(1)
 
140
                }
 
141
            }
 
142
        }
 
143
    }
 
144
}