1 /****************************************************************************
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the QtDeclarative module of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
11 ** Licensees holding valid Qt Commercial licenses may use this file in
12 ** accordance with the Qt Commercial License Agreement provided with the
13 ** Software or, alternatively, in accordance with the terms contained in
14 ** a written agreement between you and Nokia.
16 ** GNU Lesser General Public License Usage
17 ** Alternatively, this file may be used under the terms of the GNU Lesser
18 ** General Public License version 2.1 as published by the Free Software
19 ** Foundation and appearing in the file LICENSE.LGPL included in the
20 ** packaging of this file. Please review the following information to
21 ** ensure the GNU Lesser General Public License version 2.1 requirements
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 ** In addition, as a special exception, Nokia gives you certain additional
25 ** rights. These rights are described in the Nokia Qt LGPL Exception
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 ** GNU General Public License Usage
29 ** Alternatively, this file may be used under the terms of the GNU
30 ** General Public License version 3.0 as published by the Free Software
31 ** Foundation and appearing in the file LICENSE.GPL included in the
32 ** packaging of this file. Please review the following information to
33 ** ensure the GNU General Public License version 3.0 requirements will be
34 ** met: http://www.gnu.org/copyleft/gpl.html.
36 ** If you have questions regarding the use of this file, please contact
37 ** Nokia at qt-info@nokia.com.
40 ****************************************************************************/
48 contentWidth: Math.max(parent.width,webView.width)
49 contentHeight: Math.max(parent.height,webView.height)
50 anchors.top: headerSpace.bottom
51 anchors.bottom: parent.top
52 anchors.left: parent.left
53 anchors.right: parent.right
56 if (width > webView.width*webView.contentsScale && webView.contentsScale < 1.0)
57 webView.contentsScale = width / webView.width * webView.contentsScale;
60 property alias url: webView.url
62 function doZoom(variable) { webView.doZoom(variable,1,1) }
66 transformOrigin: Item.TopLeft
70 preferredWidth: flickable.width
71 preferredHeight: flickable.height
75 Keys.onRightPressed: {
79 function doZoom(zoom,centerX,centerY)
81 var tempX = flickable.width/2 - parent.x*zoom;
82 var tempY = flickable.height/2 - parent.y*zoom;
84 var sc = zoom*contentsScale;
86 flickVX.from = flickable.contentX
87 flickVX.to = Math.max(0,Math.min(tempX-flickable.width/2,webView.width*sc-flickable.width))
88 finalX.value = flickVX.to
89 flickVY.from = flickable.contentY
90 flickVY.to = Math.max(0,Math.min(tempY-flickable.height/2,webView.height*sc-flickable.height))
91 finalY.value = flickVY.to
96 onContentsSizeChanged: {
97 contentsScale = Math.min(1,flickable.width / contentsSize.width)
101 if (!heuristicZoom(clickX,clickY,2.5)) {
102 var zf = flickable.width / contentsSize.width
103 if (zf >= contentsScale)
104 zf = 2.0/zoomFactor // zoom in (else zooming out)
105 doZoom(zf,clickX*zf,clickY*zf)
109 SequentialAnimation {
114 property: "renderingEnabled"
121 property: "contentsScale"
122 easing.type: Easing.Linear
129 easing.type: Easing.Linear
138 easing.type: Easing.Linear
158 property: "renderingEnabled"
162 onZoomTo: doZoom(zoom,centerX,centerY)