diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2009-08-31 05:54:32 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2009-08-31 05:54:32 (GMT) |
commit | 98092546c0f3c7857d82711174df9ade9ea7136b (patch) | |
tree | 306c48bf07f1229f28ac8d3445f0d6181d7a9802 /demos/declarative/webbrowser/webbrowser.qml | |
parent | 07ef9e3022565017709668d637ed13d0f26b7505 (diff) | |
download | Qt-98092546c0f3c7857d82711174df9ade9ea7136b.zip Qt-98092546c0f3c7857d82711174df9ade9ea7136b.tar.gz Qt-98092546c0f3c7857d82711174df9ade9ea7136b.tar.bz2 |
Simplify zooming mechanism - put more IQ in WebView.
No animated zooming for now.
Diffstat (limited to 'demos/declarative/webbrowser/webbrowser.qml')
-rw-r--r-- | demos/declarative/webbrowser/webbrowser.qml | 69 |
1 files changed, 5 insertions, 64 deletions
diff --git a/demos/declarative/webbrowser/webbrowser.qml b/demos/declarative/webbrowser/webbrowser.qml index 278bc43..2cd9f57 100644 --- a/demos/declarative/webbrowser/webbrowser.qml +++ b/demos/declarative/webbrowser/webbrowser.qml @@ -13,21 +13,6 @@ Item { width: 640 height: 480 - Script { - function zoomOut() { - WebBrowser.state = "ZoomedOut"; - } - function toggleZoom(x,y) { - if(WebBrowser.state == "ZoomedOut") { - Flick.centerX = x - Flick.centerY = y - WebBrowser.state = "Normal"; - } else { - zoomOut(); - } - } - } - Item { id: WebPanel anchors.fill: parent @@ -183,9 +168,6 @@ Item { anchors.left: parent.left anchors.right: parent.right - property real centerX : 0 - property real centerY : 0 - WebView { id: MyWebView pixelCacheSize: 4000000 @@ -213,13 +195,14 @@ Item { focus: true preferredWidth: Flick.width - preferredHeight: Flick.height/scale - scale: (width > 0) ? Flick.width/width*zoomedOut+(1-zoomedOut) : 1 + webPageWidth: 980 onUrlChanged: { if (url != null) { WebBrowser.urlString = url.toString(); } } - onDoubleClick: { toggleZoom(clickX,clickY) } + onDoubleClick: { heuristicZoom(clickX,clickY) } + + onZooming: { Flick.viewportX=Math.min(MyWebView.width-Flick.width,Math.max(0,centerX-Flick.width/2)); + Flick.viewportY=Math.max(0,Math.min(MyWebView.height-Flick.height,centerY-Flick.height/2)) } - property real zoomedOut : 1 } Rectangle { id: WebViewTint @@ -347,46 +330,4 @@ Item { } } } - states: [ - State { - name: "Normal" - PropertyChanges { target: MyWebView; zoomedOut: 0 } - PropertyChanges { target: Flick; explicit: true; viewportX: Math.min(MyWebView.width-Flick.width,Math.max(0,Flick.centerX-Flick.width/2)) } - PropertyChanges { target: Flick; explicit: true; viewportY: Math.min(MyWebView.height-Flick.height,Math.max(0,Flick.centerY-Flick.height/2)) } - }, - State { - name: "ZoomedOut" - PropertyChanges { target: MyWebView; zoomedOut: 1 } - } - ] - transitions: [ - Transition { - SequentialAnimation { - PropertyAction { - target: MyWebView - property: "smooth" - value: false - } - ParallelAnimation { - NumberAnimation { - target: MyWebView - properties: "zoomedOut" - easing: "easeInOutQuad" - duration: 200 - } - NumberAnimation { - target: Flick - properties: "viewportX,viewportY" - easing: "easeInOutQuad" - duration: 200 - } - } - PropertyAction { - target: MyWebView - property: "smooth" - value: !Flick.moving - } - } - } - ] } |