summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVenugopal Shivashankar <venugopal.shivashankar@digia.com>2014-12-01 17:04:16 +0100
committerVenugopal Shivashankar <venugopal.shivashankar@digia.com>2015-02-09 09:41:57 +0000
commit1a3959d75260105a43bd17bec7237b58515377d1 (patch)
treeb08b35b214051301daeac63041aef537fd85aa19
parent57f79fed29fbed44f8467c34565a00dfd429454f (diff)
Example: Made a few cosmetic changes
- Added a progress bar to indicate the WebView.loadProgress - Added a ToolButton to stop/reload the web page - Replaced the ToolButton text with tooltip to reduce the space used. Change-Id: I3447af9ad2469d6460b3a6acbadb8d733845980f Reviewed-by: Christian Stromme <christian.stromme@theqtcompany.com> Reviewed-by: Caroline Chao <caroline.chao@theqtcompany.com>
-rw-r--r--examples/webview/minibrowser/+android/LoadProgressStyle.qml52
-rw-r--r--examples/webview/minibrowser/LoadProgressStyle.qml57
-rw-r--r--examples/webview/minibrowser/images/left-32.pngbin1799 -> 831 bytes
-rw-r--r--examples/webview/minibrowser/images/refresh-32.pngbin0 -> 1301 bytes
-rw-r--r--examples/webview/minibrowser/images/right-32.pngbin1804 -> 822 bytes
-rw-r--r--examples/webview/minibrowser/images/stop-32.pngbin0 -> 639 bytes
-rw-r--r--examples/webview/minibrowser/main.cpp1
-rw-r--r--examples/webview/minibrowser/main.qml54
-rw-r--r--examples/webview/minibrowser/qml.qrc4
9 files changed, 164 insertions, 4 deletions
diff --git a/examples/webview/minibrowser/+android/LoadProgressStyle.qml b/examples/webview/minibrowser/+android/LoadProgressStyle.qml
new file mode 100644
index 0000000..1ed0278
--- /dev/null
+++ b/examples/webview/minibrowser/+android/LoadProgressStyle.qml
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples 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 Digia Plc 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 QtQuick 2.2
+import QtQuick.Controls.Styles 1.2
+
+ProgressBarStyle {
+ background: Rectangle {
+ radius: 2
+ color: "transparent"
+ implicitHeight: Math.round(urlField.height / 1.3)
+ implicitWidth: urlField.width - 12
+ }
+
+}
diff --git a/examples/webview/minibrowser/LoadProgressStyle.qml b/examples/webview/minibrowser/LoadProgressStyle.qml
new file mode 100644
index 0000000..bf307e8
--- /dev/null
+++ b/examples/webview/minibrowser/LoadProgressStyle.qml
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples 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 Digia Plc 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 QtQuick 2.2
+import QtQuick.Controls.Styles 1.2
+
+ProgressBarStyle {
+ background: Rectangle {
+ radius: 2
+ color: "transparent"
+ implicitHeight: urlField.height - 2
+ implicitWidth: urlField.width
+ }
+ progress: Rectangle {
+ anchors.fill: parent
+ color: "#80c342"
+ opacity: 0.5
+ }
+
+}
diff --git a/examples/webview/minibrowser/images/left-32.png b/examples/webview/minibrowser/images/left-32.png
index ec4107b..28e4dda 100644
--- a/examples/webview/minibrowser/images/left-32.png
+++ b/examples/webview/minibrowser/images/left-32.png
Binary files differ
diff --git a/examples/webview/minibrowser/images/refresh-32.png b/examples/webview/minibrowser/images/refresh-32.png
new file mode 100644
index 0000000..886cad4
--- /dev/null
+++ b/examples/webview/minibrowser/images/refresh-32.png
Binary files differ
diff --git a/examples/webview/minibrowser/images/right-32.png b/examples/webview/minibrowser/images/right-32.png
index 0f6ba86..00ccf43 100644
--- a/examples/webview/minibrowser/images/right-32.png
+++ b/examples/webview/minibrowser/images/right-32.png
Binary files differ
diff --git a/examples/webview/minibrowser/images/stop-32.png b/examples/webview/minibrowser/images/stop-32.png
new file mode 100644
index 0000000..3f5fb8b
--- /dev/null
+++ b/examples/webview/minibrowser/images/stop-32.png
Binary files differ
diff --git a/examples/webview/minibrowser/main.cpp b/examples/webview/minibrowser/main.cpp
index 1db0bc0..99a3dcf 100644
--- a/examples/webview/minibrowser/main.cpp
+++ b/examples/webview/minibrowser/main.cpp
@@ -103,6 +103,7 @@ int main(int argc, char *argv[])
context->setContextProperty(QStringLiteral("initialY"), geometry.y());
context->setContextProperty(QStringLiteral("initialWidth"), geometry.width());
context->setContextProperty(QStringLiteral("initialHeight"), geometry.height());
+
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
return app.exec();
diff --git a/examples/webview/minibrowser/main.qml b/examples/webview/minibrowser/main.qml
index 7a82ac0..caf8e42 100644
--- a/examples/webview/minibrowser/main.qml
+++ b/examples/webview/minibrowser/main.qml
@@ -42,6 +42,8 @@ import QtQuick 2.2
import QtQuick.Controls 1.1
import QtWebView 1.0
import QtQuick.Layouts 1.1
+import QtQuick.Controls.Styles 1.2
+
ApplicationWindow {
visible: true
@@ -55,43 +57,87 @@ ApplicationWindow {
id: navigationBar
RowLayout {
anchors.fill: parent
+ spacing: 0
ToolButton {
id: backButton
- text: qsTr("Back")
- iconSource: "qrc:/images/left-32.png"
+ tooltip: qsTr("Back")
+ iconSource: "images/left-32.png"
onClicked: webView.goBack()
enabled: webView.canGoBack
+ Layout.preferredWidth: navigationBar.height
+ style: ButtonStyle {
+ background: Rectangle { color: "transparent" }
+ }
}
ToolButton {
id: forwardButton
- text: qsTr("Forward")
- iconSource: "qrc:/images/right-32.png"
+ tooltip: qsTr("Forward")
+ iconSource: "images/right-32.png"
onClicked: webView.goForward()
enabled: webView.canGoForward
+ Layout.preferredWidth: navigationBar.height
+ style: ButtonStyle {
+ background: Rectangle { color: "transparent" }
+ }
+ }
+
+ ToolButton {
+ id: reloadButton
+ tooltip: webView.loading ? qsTr("Stop"): qsTr("Refresh")
+ iconSource: webView.loading ? "images/stop-32.png" : "images/refresh-32.png"
+ onClicked: webView.loading ? webView.stop() : webView.reload()
+ Layout.preferredWidth: navigationBar.height
+ style: ButtonStyle {
+ background: Rectangle { color: "transparent" }
+ }
}
+ Item { Layout.preferredWidth: 5 }
+
TextField {
Layout.fillWidth: true
id: urlField
inputMethodHints: Qt.ImhUrlCharactersOnly | Qt.ImhPreferLowercase
text: webView.url
+
onAccepted: webView.url = utils.fromUserInput(text)
+
+ ProgressBar {
+ anchors.centerIn: parent
+ style: LoadProgressStyle { }
+ z: Qt.platform.os === "android" ? -1 : 1
+ visible: webView.loading && Qt.platform.os !== "ios"
+ minimumValue: 0
+ maximumValue: 100
+ value: webView.loadProgress > 100 ? 0 : webView.loadProgress
+ }
}
+ Item { Layout.preferredWidth: 5 }
+
ToolButton {
id: goButton
text: qsTr("Go")
+ Layout.preferredWidth: navigationBar.height
onClicked: {
+ Qt.inputMethod.commit()
+ Qt.inputMethod.hide()
webView.url = utils.fromUserInput(urlField.text)
}
+ style: ButtonStyle {
+ background: Rectangle { color: "transparent" }
+ }
}
+
+ Item { Layout.preferredWidth: 10 }
}
}
statusBar: StatusBar {
id: statusBar
+ visible: webView.loading && Qt.platform.os !== "ios"
RowLayout {
anchors.fill: parent
Label { text: webView.loadProgress == 100 ? qsTr("Done") : qsTr("Loading: ") + webView.loadProgress + "%" }
diff --git a/examples/webview/minibrowser/qml.qrc b/examples/webview/minibrowser/qml.qrc
index 16da66e..9791b21 100644
--- a/examples/webview/minibrowser/qml.qrc
+++ b/examples/webview/minibrowser/qml.qrc
@@ -2,6 +2,10 @@
<qresource prefix="/">
<file>main.qml</file>
<file>images/left-32.png</file>
+ <file>images/stop-32.png</file>
+ <file>images/refresh-32.png</file>
+ <file>LoadProgressStyle.qml</file>
+ <file>+android/LoadProgressStyle.qml</file>
<file>images/right-32.png</file>
</qresource>
</RCC>