0.9.1-2 for extras-devel
[feedingit] / psa_harmattan / feedingit / deb_dist / feedingit-0.1.0 / debian / feedingit / usr / share / feedingit / qml / TestWebview.qml
1 import Qt 4.7
2 import QtWebKit 1.0
3 import "common" as Common
4
5 Rectangle {
6     width: 380
7     height: 480
8
9     //anchors.top: parent.top; anchors.bottom: parent.bottom;
10     color: "white";
11
12     property string url: "";
13     Flickable {
14         id: flickable
15         //anchors.fill: screen;
16         height: parent.height;
17         width: parent.width;
18         contentWidth: webView.width*scale; //Math.max(screen.width,webView.width*webView.scale)
19         contentHeight: Math.max(parent.height,webView.height*webView.scale)
20
21         WebView {
22             id: webView
23             url: "http://www.google.com";
24             //url: "/home/user/.feedingit/640fb167aca8bf5318ed721c5162f5eb.d/56a86b6b1675716ab54db83b1a78ab4c.html"
25             preferredWidth: flickable.width
26             preferredHeight: flickable.height
27             settings.defaultFontSize: 32
28             scale: slider.value;
29             //smooth: false
30             //width: 200
31             //width: parent.width; height: parent.height;
32 //            Rectangle {
33 //                             color: "#10000000"
34 //                             anchors.fill: parent
35 //            }
36             //onLoadFinished: {console.log("Hello"); url="javascript:void(document.body.style.background='red');" }
37             onLoadFinished: {console.log(url);/* url="javascript:(function() { " +
38                                                               "document.getElementsByTagName('body')[0].style.background = 'red'; " +
39                                                               "})()"; console.log(url);*/ /*heuristicZoom(0,0,100)*/ }
40         }
41     }
42         Common.Slider {
43             id: slider; visible: true
44             minimum: 0.2;
45             maximum: 2;
46             value: 1
47             property real prevScale: 1
48             anchors {
49                 bottom: parent.bottom; bottomMargin: 65
50                 left: parent.left; leftMargin: 25
51                 right: parent.right; rightMargin: 25
52             }
53             onValueChanged: {
54                 if (webView.width * value > flickable.width) {
55                     var xoff = (flickable.width/2 + flickable.contentX) * value / prevScale;
56                     flickable.contentX = xoff - flickable.width/2;
57                 }
58                 if (webView.height * value > flickable.height) {
59                     var yoff = (flickable.height/2 + flickable.contentY) * value / prevScale;
60                     flickable.contentY = yoff - flickable.height/2;
61                 }
62                 prevScale = value;
63             }
64             Component.onCompleted: { value=0; value=1; }
65         }
66 }