psa: using 2 flickables
[feedingit] / psa_harmattan / feedingit / deb_dist / feedingit-0.1.0 / qml / ArticleDisplay.qml
1 import Qt 4.7
2 import QtWebKit 1.0
3 import "common" as Common
4
5 Rectangle {
6     /*x: parent.width; height: parent.height;*/
7     width: flickable.width;
8     height: parent.height
9     property alias zoomEnabled: slider.visible;
10     property alias value: slider.value;
11     //anchors.top: parent.top; anchors.bottom: parent.bottom;
12     color: "white";
13
14     Flickable {
15         id: flickable
16         //anchors.fill: screen;
17         height: parent.height;
18         width: webView.width;
19         contentWidth: webView.width*webView.scale; //Math.max(screen.width,webView.width*webView.scale)
20         contentHeight: Math.max(articleView.height,webView.height*webView.scale)
21         //contentWidth: childrenRect.width; contentHeight: childrenRect.height
22         interactive: parent.vertPanningEnabled;
23
24         flickDeceleration: 1500;
25         flickableDirection: Flickable.VerticalFlick
26         WebView {
27             id: webView
28             //url: flipItem.url;
29             html: flipItem.html;
30             preferredWidth: articleView.width
31             //preferredHeight: articleView.height
32             //scale: 1.25;
33             transformOrigin: Item.TopLeft
34             scale: slider.value;
35             settings.defaultFontSize: articleView.webviewFontSize
36         }
37
38 //        onFlickStarted: {
39 //            console.log("start contentx"+contentX)
40 //            console.log("start contenty"+contentY)
41 //        }
42     }
43
44     Common.Slider {
45         id: slider; visible: false
46         minimum: 0.2;
47         maximum: 2;
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 }