e992e1ebbab76a3bdb2157b42192584dbca3df1c
[feedingit] / psa_harmattan / feedingit / deb_dist / feedingit-0.1.0 / 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: "http://www.viedemerde.fr/inclassable/5873986?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+viedemerde+%28Vie+de+merde%29"
25             url: "/home/ymarcoz/.feedingit/361f6abe590be9c681b5489e5d48331c.d/1b1033c75378fb19a8a70151d764cd33.html"
26             preferredWidth: flickable.width
27             preferredHeight: flickable.height
28             settings.defaultFontSize: 32
29             scale: slider.value;
30             //smooth: false
31             //width: 200
32             //width: parent.width; height: parent.height;
33 //            Rectangle {
34 //                             color: "#10000000"
35 //                             anchors.fill: parent
36 //            }
37             //onLoadFinished: {console.log("Hello"); url="javascript:void(document.body.style.background='red');" }
38             onLoadFinished: {console.log(url);/* url="javascript:(function() { " +
39                                                               "document.getElementsByTagName('body')[0].style.background = 'red'; " +
40                                                               "})()"; console.log(url);*/ /*heuristicZoom(0,0,100)*/ }
41         }
42     }
43         Common.Slider {
44             id: slider; visible: true
45             minimum: 0.2;
46             maximum: 2;
47             value: 1
48             property real prevScale: 1
49             anchors {
50                 bottom: parent.bottom; bottomMargin: 65
51                 left: parent.left; leftMargin: 25
52                 right: parent.right; rightMargin: 25
53             }
54             onValueChanged: {
55                 if (webView.width * value > flickable.width) {
56                     var xoff = (flickable.width/2 + flickable.contentX) * value / prevScale;
57                     flickable.contentX = xoff - flickable.width/2;
58                 }
59                 if (webView.height * value > flickable.height) {
60                     var yoff = (flickable.height/2 + flickable.contentY) * value / prevScale;
61                     flickable.contentY = yoff - flickable.height/2;
62                 }
63                 prevScale = value;
64             }
65             Component.onCompleted: { value=0; value=1; }
66         }
67 }