clip flickable views (menu and web view) so that they don't overshoot when scrolling
[meego-ux:meego-app-satk.git] / StkMenu.qml
1 /*
2  * satk - SIM application toolkit
3  * Copyright © 2011, Intel Corporation.
4  *
5  * This program is licensed under the terms and conditions of the
6  * Apache License, version 2.0.  The full text of the Apache License is at
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Written by - Luc Yriarte <luc.yriarte@linux.intel.com>
10  */
11
12
13 /*!
14     \file StkMenu.qml
15     \section StkMenu
16     \brief Menu list view.
17
18     \subsection Signals
19     \li itemSelected(int selection)
20     \li goBack()
21     \li endSession()
22
23     \subsection Objects
24     - \b menuView : Menu list view.
25       - Signals
26         - itemSelected(int selection)
27       - Properties
28         - menuModel
29       - Delegate roles
30         - title
31         - icon
32 */
33
34 import Qt 4.7
35 import MeeGo.Components 0.1
36
37 Rectangle {
38     id: view
39     objectName: "view"
40
41     width: stkTheme.viewWidth
42     height: stkTheme.viewHeight
43
44     Theme { id: theme }
45     StkTheming { id: stkTheme }
46     color: stkTheme.viewBackgroundColor
47
48     signal itemSelected(int selection)
49     onItemSelected: console.log("Item selected: " + selection)
50     signal goBack()
51     onGoBack: console.log("Go back")
52     signal endSession()
53     onEndSession: console.log("End session")
54
55     ListView {
56         id: menuView
57         objectName: "menuView"
58         model: menuModel
59         delegate: menuDelegate
60         highlight: Rectangle {
61             color: theme.fontColorHighlight
62             width: menuView.width
63         }
64         highlightFollowsCurrentItem: true
65         anchors.top: icon.bottom
66         anchors.topMargin: 10
67         anchors.left: parent.left
68         anchors.leftMargin: 10
69         anchors.bottom: parent.bottom
70         anchors.bottomMargin: 10
71         anchors.right: parent.right
72         anchors.rightMargin: 10
73         clip: true
74         signal itemSelected(int selection)
75         onItemSelected: {
76             currentIndex = selection;
77             view.itemSelected(selection)
78         }
79     }
80
81     Component {
82         id: menuDelegate
83         Row {
84             spacing: 10
85             Image {
86                 width: 32
87                 height: 32
88                 anchors.verticalCenter: parent.verticalCenter
89                 source: icon
90                 MouseArea {
91                     anchors.fill: parent
92                     onClicked: menuView.itemSelected(index)
93                 }
94             }
95             Text {
96                 height: 48
97                 verticalAlignment: Text.AlignVCenter
98                 color: stkTheme.menuItemFontColor
99                 font.pixelSize: stkTheme.menuItemFontPixelSize
100                 text: title
101                 MouseArea {
102                     width: menuView.width
103                     anchors.top: parent.top
104                     anchors.left: parent.left
105                     anchors.bottom: parent.bottom
106                     onClicked: menuView.itemSelected(index)
107                 }
108             }
109         }
110     }
111
112     StkPanel {
113         id: panel
114         objectName: "panel"
115         anchors.right: parent.right
116         anchors.bottom: parent.bottom
117         onGoBack: view.goBack();
118         onEndSession: view.endSession();
119     }
120
121     Label {
122         id: title
123         objectName: "title"
124         text: "SIM Application Toolkit"
125         anchors.top: parent.top
126         anchors.topMargin: 10
127         anchors.left: icon.right
128         anchors.leftMargin: 10
129         anchors.right: parent.right
130         anchors.rightMargin: 10
131         wrapMode: Text.WordWrap
132         color: stkTheme.titleFontColor
133         font.pixelSize: stkTheme.titleFontPixelSize
134     }
135
136     Image {
137         id: icon
138         objectName: "icon"
139         width: 64
140         height: 64
141         anchors.top: parent.top
142         anchors.topMargin: 10
143         anchors.left: parent.left
144         anchors.leftMargin: 10
145     }
146
147 }
148
149
150