summaryrefslogtreecommitdiffstats
path: root/demos
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2009-11-10 05:06:04 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2009-11-10 05:06:04 (GMT)
commit6ac64e4b8d7cb86394936a4d5723625bcabf2f59 (patch)
tree442f408c9f4071445628c3035470288049fccc95 /demos
parent5471328d6565ca1759ea8008421a31dde2a0f036 (diff)
downloadQt-6ac64e4b8d7cb86394936a4d5723625bcabf2f59.zip
Qt-6ac64e4b8d7cb86394936a4d5723625bcabf2f59.tar.gz
Qt-6ac64e4b8d7cb86394936a4d5723625bcabf2f59.tar.bz2
Remove WebView::pagewidth and tidy up - it's not needed and interfered
with zoomFactor.
Diffstat (limited to 'demos')
-rw-r--r--demos/declarative/webbrowser/webbrowser.qml43
1 files changed, 26 insertions, 17 deletions
diff --git a/demos/declarative/webbrowser/webbrowser.qml b/demos/declarative/webbrowser/webbrowser.qml
index 6be3e09..8a01af5 100644
--- a/demos/declarative/webbrowser/webbrowser.qml
+++ b/demos/declarative/webbrowser/webbrowser.qml
@@ -191,15 +191,37 @@ Item {
}
url: fixUrl(webBrowser.urlString)
- smooth: true
+ smooth: false // We don't want smooth scaling, since we only scale during (fast) transitions
+ smoothCache: true // We do want smooth rendering
fillColor: "white"
focus: true
+ function doZoom(zoom,centerX,centerY)
+ {
+ if (centerX) {
+ var sc = zoom/zoomFactor;
+ scaleAnim.to = sc;
+ flickVX.from = flickable.viewportX
+ flickVX.to = Math.min(Math.max(0,centerX-flickable.width/2),webView.width*sc-flickable.width)
+ finalX.value = Math.min(Math.max(0,centerX-flickable.width/2),webView.width*sc-flickable.width)
+ flickVY.from = flickable.viewportY
+ flickVY.to = Math.min(Math.max(0,centerY-flickable.height/2),webView.height*sc-flickable.height)
+ finalY.value = Math.min(Math.max(0,centerY-flickable.height/2),webView.height*sc-flickable.height)
+ finalZoom.value = zoom
+ quickZoom.start()
+ }
+ }
+
preferredWidth: flickable.width
- webPageWidth: 980
+ preferredHeight: flickable.height
+ zoomFactor: flickable.width > 980 ? flickable.width : flickable.width/980
onUrlChanged: { if (url != null) { webBrowser.urlString = url.toString(); } }
- onDoubleClick: { heuristicZoom(clickX,clickY) }
+ onDoubleClick: { if (!heuristicZoom(clickX,clickY,2.5)) {
+ var zf = flickable.width > 980 ? flickable.width : flickable.width/980;
+ doZoom(zf,clickX/zoomFactor*zf,clickY/zoomFactor*zf)
+ }
+ }
SequentialAnimation {
id: quickZoom
@@ -269,20 +291,7 @@ Item {
value: true
}
}
- onZooming: {
- if (centerX) {
- var sc = zoom/zoomFactor;
- scaleAnim.to = sc;
- flickVX.from = flickable.viewportX
- flickVX.to = Math.min(Math.max(0,centerX-flickable.width/2),webView.width*sc-flickable.width)
- finalX.value = Math.min(Math.max(0,centerX-flickable.width/2),webView.width*sc-flickable.width)
- flickVY.from = flickable.viewportY
- flickVY.to = Math.min(Math.max(0,centerY-flickable.height/2),webView.height*sc-flickable.height)
- finalY.value = Math.min(Math.max(0,centerY-flickable.height/2),webView.height*sc-flickable.height)
- finalZoom.value = zoom
- quickZoom.start()
- }
- }
+ onZoomTo: doZoom(zoom,centerX,centerY)
}
Rectangle {
id: webViewTint