clip flickable views (menu and web view) so that they don't overshoot when scrolling
[meego-ux:meego-app-satk.git] / StkWebView.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 StkWebView.qml
15     \section StkWebView
16     \brief Web browser box, dismissable.
17
18     \subsection Signals
19     \li accepted()
20
21     \subsection Objects
22     - \b browserView : Web browser view.
23       - Properties
24         - url:  "http://127.0.0.1/"
25     - \b okRect : "Ok" button.
26       - Signals
27         - accepted()
28       - Properties
29         - text: "Ok"
30 */
31
32 import Qt 4.7
33 import QtWebKit 1.0
34 import MeeGo.Components 0.1
35
36 Rectangle {
37     id: view
38     objectName: "view"
39
40     width: stkTheme.viewWidth
41     height: stkTheme.viewHeight
42
43     Theme { id: theme }
44     StkTheming { id: stkTheme }
45     color: stkTheme.viewBackgroundColor
46
47     signal accepted()
48     onAccepted: console.log("Accepted")
49
50     Flickable {
51         id: browserView
52         objectName: "browserView"
53         anchors.top: title.bottom
54         anchors.topMargin: 10
55         anchors.left: parent.left
56         anchors.leftMargin: 10
57         anchors.bottom: okRect.top
58         anchors.bottomMargin: 10
59         anchors.right: parent.right
60         anchors.rightMargin: 10
61         contentWidth: childrenRect.width
62         contentHeight: childrenRect.height
63         clip: true
64         property alias url: browserContent.url
65         WebView {
66             id: browserContent
67             objectName: "browserContent"
68             preferredWidth: parent.width
69             preferredHeight: parent.height
70             url: "http://127.0.0.1/"
71             onWidthChanged: browserView.contentWidth = width
72             onHeightChanged: browserView.contentHeight = height
73             onLoadFinished: browserView.contentY = -1 // redraw browserView
74         }
75     }
76
77     Label {
78         id: title
79         objectName: "title"
80         text: "SIM Application Toolkit"
81         anchors.top: parent.top
82         anchors.topMargin: 10
83         anchors.left: icon.right
84         anchors.leftMargin: 10
85         anchors.right: parent.right
86         anchors.rightMargin: 10
87         wrapMode: Text.WordWrap
88         color: stkTheme.titleFontColor
89         font.pixelSize: stkTheme.titleFontPixelSize
90     }
91
92     Image {
93         id: icon
94         objectName: "icon"
95         width: 64
96         height: 64
97         anchors.top: parent.top
98         anchors.topMargin: 10
99         anchors.left: parent.left
100         anchors.leftMargin: 10
101     }
102
103     StkButton {
104         id: okRect
105         objectName: "okRect"
106         anchors.horizontalCenter: parent.horizontalCenter
107         anchors.bottom: parent.bottom
108         anchors.bottomMargin: 10
109         text: qsTr( "Ok")
110         onClicked: {
111             view.accepted()
112         }
113     }
114 }
115
116
117