summaryrefslogtreecommitdiffstats
path: root/examples/declarative/modelviews/webview
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2010-06-21 05:37:41 (GMT)
committerBea Lam <bea.lam@nokia.com>2010-06-22 01:22:35 (GMT)
commitc8968fd143e079d4d2b79c88132caaffbefedd7d (patch)
treeb16577cba1077738e8095c0ddb8faca20a17b1fb /examples/declarative/modelviews/webview
parentd9e49c4399e506c878ce5125d4edcf384b867b26 (diff)
downloadQt-c8968fd143e079d4d2b79c88132caaffbefedd7d.zip
Qt-c8968fd143e079d4d2b79c88132caaffbefedd7d.tar.gz
Qt-c8968fd143e079d4d2b79c88132caaffbefedd7d.tar.bz2
Clean up some examples
Diffstat (limited to 'examples/declarative/modelviews/webview')
-rw-r--r--examples/declarative/modelviews/webview/alerts.qml15
-rw-r--r--examples/declarative/modelviews/webview/autosize.qml14
-rw-r--r--examples/declarative/modelviews/webview/content/FieldText.qml195
-rw-r--r--examples/declarative/modelviews/webview/content/Mapping/Map.qml11
-rw-r--r--examples/declarative/modelviews/webview/content/SpinSquare.qml65
-rw-r--r--examples/declarative/modelviews/webview/googlemaps.qml (renamed from examples/declarative/modelviews/webview/googleMaps.qml)0
-rw-r--r--examples/declarative/modelviews/webview/inlinehtml.qml (renamed from examples/declarative/modelviews/webview/inline-html.qml)12
7 files changed, 33 insertions, 279 deletions
diff --git a/examples/declarative/modelviews/webview/alerts.qml b/examples/declarative/modelviews/webview/alerts.qml
index 7303450..1537411 100644
--- a/examples/declarative/modelviews/webview/alerts.qml
+++ b/examples/declarative/modelviews/webview/alerts.qml
@@ -43,7 +43,7 @@ import org.webkit 1.0
WebView {
id: webView
- width: 120
+ width: 200
height: 150
url: "alerts.html"
@@ -58,13 +58,13 @@ WebView {
y: parent.height // off "screen"
anchors.horizontalCenter: parent.horizontalCenter
- width: label.width+5
- height: label.height+5
+ width: label.width + 5
+ height: label.height + 5
opacity: 0
- function show(t) {
- label.text = t
+ function show(text) {
+ label.text = text
popup.state = "visible"
timer.start()
}
@@ -82,17 +82,20 @@ WebView {
Timer {
id: timer
interval: 1000
+
onTriggered: popup.state = ""
}
Text {
id: label
anchors.centerIn: parent
+ width: webView.width *0.75
+
color: "white"
font.pixelSize: 20
- width: webView.width*0.75
wrapMode: Text.WordWrap
horizontalAlignment: Text.AlignHCenter
+ smooth: true
}
}
}
diff --git a/examples/declarative/modelviews/webview/autosize.qml b/examples/declarative/modelviews/webview/autosize.qml
index 556b429..64e3ff1 100644
--- a/examples/declarative/modelviews/webview/autosize.qml
+++ b/examples/declarative/modelviews/webview/autosize.qml
@@ -51,6 +51,7 @@ Rectangle {
Column {
id: layout
spacing: 2
+
WebView {
html: "No width defined."
Rectangle {
@@ -58,6 +59,7 @@ Rectangle {
anchors.fill: parent
}
}
+
WebView {
width: rect.width
html: "The width is full."
@@ -66,6 +68,7 @@ Rectangle {
anchors.fill: parent
}
}
+
WebView {
width: rect.width/2
html: "The width is half."
@@ -75,24 +78,25 @@ Rectangle {
}
}
WebView {
- preferredWidth: rect.width/2
- html: "The preferredWidth is half."
+ width: rect.width/2
+ html: "The_width_is_half." // not wrapped
Rectangle {
color: "#10000000"
anchors.fill: parent
}
}
+
WebView {
preferredWidth: rect.width/2
- html: "The_preferredWidth_is_half."
+ html: "The preferredWidth is half."
Rectangle {
color: "#10000000"
anchors.fill: parent
}
}
WebView {
- width: rect.width/2
- html: "The_width_is_half."
+ preferredWidth: rect.width/2
+ html: "The_preferredWidth_is_half." // not wrapped
Rectangle {
color: "#10000000"
anchors.fill: parent
diff --git a/examples/declarative/modelviews/webview/content/FieldText.qml b/examples/declarative/modelviews/webview/content/FieldText.qml
deleted file mode 100644
index 17fa4cd..0000000
--- a/examples/declarative/modelviews/webview/content/FieldText.qml
+++ /dev/null
@@ -1,195 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import Qt 4.7
-
-Item {
- id: fieldText
- height: 30
- property string text: ""
- property string label: ""
- property bool mouseGrabbed: false
- signal confirmed
- signal cancelled
- signal startEdit
-
- function edit() {
- if (!mouseGrabbed) {
- fieldText.startEdit();
- fieldText.state='editing';
- mouseGrabbed=true;
- }
- }
-
- function confirm() {
- fieldText.state='';
- fieldText.text = textEdit.text;
- mouseGrabbed=false;
- fieldText.confirmed();
- }
-
- function reset() {
- textEdit.text = fieldText.text;
- fieldText.state='';
- mouseGrabbed=false;
- fieldText.cancelled();
- }
-
- Image {
- id: cancelIcon
- width: 22
- height: 22
- anchors.right: parent.right
- anchors.rightMargin: 4
- anchors.verticalCenter: parent.verticalCenter
- source: "pics/cancel.png"
- opacity: 0
- }
-
- Image {
- id: confirmIcon
- width: 22
- height: 22
- anchors.left: parent.left
- anchors.leftMargin: 4
- anchors.verticalCenter: parent.verticalCenter
- source: "pics/ok.png"
- opacity: 0
- }
-
- TextInput {
- id: textEdit
- text: fieldText.text
- focus: false
- anchors.left: parent.left
- anchors.leftMargin: 0
- anchors.right: parent.right
- anchors.rightMargin: 0
- anchors.verticalCenter: parent.verticalCenter
- color: "black"
- font.bold: true
- readOnly: true
- onAccepted: confirm()
- Keys.onEscapePressed: reset()
- }
-
- Text {
- id: textLabel
- x: 5
- width: parent.width-10
- anchors.verticalCenter: parent.verticalCenter
- horizontalAlignment: Text.AlignHCenter
- color: fieldText.state == "editing" ? "#505050" : "#AAAAAA"
- font.italic: true
- font.bold: true
- text: label
- opacity: textEdit.text == '' ? 1 : 0
- Behavior on opacity {
- NumberAnimation {
- property: "opacity"
- duration: 250
- }
- }
- }
-
- MouseArea {
- anchors.fill: cancelIcon
- onClicked: { reset() }
- }
-
- MouseArea {
- anchors.fill: confirmIcon
- onClicked: { confirm() }
- }
-
- MouseArea {
- id: editRegion
- anchors.fill: textEdit
- onClicked: { edit() }
- }
-
- states: [
- State {
- name: "editing"
- PropertyChanges {
- target: confirmIcon
- opacity: 1
- }
- PropertyChanges {
- target: cancelIcon
- opacity: 1
- }
- PropertyChanges {
- target: textEdit
- color: "black"
- readOnly: false
- focus: true
- }
- PropertyChanges {
- target: editRegion
- opacity: 0
- }
- PropertyChanges {
- target: textEdit.anchors
- leftMargin: 34
- }
- PropertyChanges {
- target: textEdit.anchors
- rightMargin: 34
- }
- }
- ]
-
- transitions: [
- Transition {
- from: ""
- to: "*"
- reversible: true
- NumberAnimation {
- properties: "opacity,leftMargin,rightMargin"
- duration: 200
- }
- ColorAnimation {
- property: "color"
- duration: 150
- }
- }
- ]
-}
diff --git a/examples/declarative/modelviews/webview/content/Mapping/Map.qml b/examples/declarative/modelviews/webview/content/Mapping/Map.qml
index be708ee..99f8479 100644
--- a/examples/declarative/modelviews/webview/content/Mapping/Map.qml
+++ b/examples/declarative/modelviews/webview/content/Mapping/Map.qml
@@ -43,14 +43,17 @@ import org.webkit 1.0
Item {
id: page
+
property real latitude: -34.397
property real longitude: 150.644
property string address: ""
property alias status: js.status
+
WebView {
id: map
anchors.fill: parent
url: "map.html"
+ pressGrabTime: 0
javaScriptWindowObjects: QtObject {
id: js
WebView.windowObjectName: "qml"
@@ -58,9 +61,13 @@ Item {
property real lng: page.longitude
property string address: page.address
property string status: "Loading"
- onAddressChanged: { if (map.url != "" && map.progress==1) map.evaluateJavaScript("goToAddress()") }
+
+ onAddressChanged: {
+ if (map.url != "" && map.progress == 1)
+ map.evaluateJavaScript("goToAddress()")
+ }
}
- pressGrabTime: 0
+
onLoadFinished: { evaluateJavaScript("goToAddress()"); }
}
}
diff --git a/examples/declarative/modelviews/webview/content/SpinSquare.qml b/examples/declarative/modelviews/webview/content/SpinSquare.qml
deleted file mode 100644
index ec83056..0000000
--- a/examples/declarative/modelviews/webview/content/SpinSquare.qml
+++ /dev/null
@@ -1,65 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import Qt 4.7
-
-Item {
- property variant period : 250
- property variant color : "black"
- id: root
-
- Item {
- x: root.width/2
- y: root.height/2
- Rectangle {
- color: root.color
- x: -width/2
- y: -height/2
- width: root.width
- height: width
- }
- NumberAnimation on rotation {
- from: 0
- to: 360
- loops: Animation.Infinite
- duration: root.period
- }
- }
-}
diff --git a/examples/declarative/modelviews/webview/googleMaps.qml b/examples/declarative/modelviews/webview/googlemaps.qml
index 1c99940..1c99940 100644
--- a/examples/declarative/modelviews/webview/googleMaps.qml
+++ b/examples/declarative/modelviews/webview/googlemaps.qml
diff --git a/examples/declarative/modelviews/webview/inline-html.qml b/examples/declarative/modelviews/webview/inlinehtml.qml
index 875c903..237bd8f 100644
--- a/examples/declarative/modelviews/webview/inline-html.qml
+++ b/examples/declarative/modelviews/webview/inlinehtml.qml
@@ -45,11 +45,11 @@ import org.webkit 1.0
// set on the html property.
WebView {
html:"\
- <body bgcolor=white>\
- <table border=1>\
- <tr><th><th>One<th>Two<th>Three\
- <tr><th>1<td>X<td>1<td>X\
- <tr><th>2<td>0<td>X<td>0\
- <tr><th>3<td>X<td>1<td>X\
+ <body>
+ <table border=1>
+ <tr><th><th>One<th>Two<th>Three
+ <tr><th>1<td>X<td>1<td>X
+ <tr><th>2<td>0<td>X<td>0
+ <tr><th>3<td>X<td>1<td>X
</table>"
}