summaryrefslogtreecommitdiffstats
path: root/demos/declarative
diff options
context:
space:
mode:
authorYann Bodson <yann.bodson@nokia.com>2009-09-01 02:16:29 (GMT)
committerYann Bodson <yann.bodson@nokia.com>2009-09-01 02:16:29 (GMT)
commite9e9b0bcb2cc413871eb9e4596750635c11ddee4 (patch)
tree95dccb6ea88f5502d538d96ea18e460fbbdcc054 /demos/declarative
parentb6fa0efb754723fd3fe33254e322ad5d7bf1f19f (diff)
parent5db9309f372b4aec16c2206fccde0c4c3e19fdc2 (diff)
downloadQt-e9e9b0bcb2cc413871eb9e4596750635c11ddee4.zip
Qt-e9e9b0bcb2cc413871eb9e4596750635c11ddee4.tar.gz
Qt-e9e9b0bcb2cc413871eb9e4596750635c11ddee4.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'demos/declarative')
-rw-r--r--demos/declarative/webbrowser/webbrowser.qml133
1 files changed, 68 insertions, 65 deletions
diff --git a/demos/declarative/webbrowser/webbrowser.qml b/demos/declarative/webbrowser/webbrowser.qml
index 278bc43..4c4ad7c 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
@@ -208,18 +190,81 @@ Item {
}
url: fixUrl(WebBrowser.urlString)
- smooth: !Flick.moving
+ smooth: false
fillColor: "white"
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) }
+
+ SequentialAnimation {
+ id: QuickZoom
- property real zoomedOut : 1
+ PropertyAction {
+ target: MyWebView
+ property: "renderingEnabled"
+ value: false
+ }
+ ParallelAnimation {
+ NumberAnimation {
+ id: ScaleAnim
+ target: MyWebView
+ property: "scale"
+ from: 1
+ to: 0 // set before calling
+ easing: "easeInOutQuad"
+ duration: 200
+ }
+ NumberAnimation {
+ id: FlickVX
+ target: Flick
+ property: "viewportX"
+ easing: "easeInOutQuad"
+ duration: 200
+ from: 0 // set before calling
+ to: 0 // set before calling
+ }
+ NumberAnimation {
+ id: FlickVY
+ target: Flick
+ property: "viewportY"
+ easing: "easeInOutQuad"
+ duration: 200
+ from: 0 // set before calling
+ to: 0 // set before calling
+ }
+ }
+ PropertyAction {
+ target: MyWebView
+ property: "scale"
+ value: 1.0
+ }
+ PropertyAction {
+ id: FinalZoom
+ target: MyWebView
+ property: "zoomFactor"
+ }
+ PropertyAction {
+ target: MyWebView
+ property: "renderingEnabled"
+ value: true
+ }
+ }
+ onZooming: {
+ if (centerX) {
+ sc = zoom/zoomFactor;
+ ScaleAnim.to = sc;
+ FlickVX.from = Flick.viewportX
+ FlickVX.to = Math.min(Math.max(0,centerX-Flick.width/2),MyWebView.width*sc-Flick.width)
+ FlickVY.from = Flick.viewportY
+ FlickVY.to = Math.min(Math.max(0,centerY-Flick.height/2),MyWebView.height*sc-Flick.height)
+ FinalZoom.value = zoom
+ QuickZoom.start()
+ }
+ }
}
Rectangle {
id: WebViewTint
@@ -347,46 +392,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
- }
- }
- }
- ]
}