diff options
author | Christian Strømme <christian.stromme@theqtcompany.com> | 2015-02-15 19:49:38 +0100 |
---|---|---|
committer | Christian Strømme <christian.stromme@theqtcompany.com> | 2015-02-15 19:49:38 +0100 |
commit | 6dfc5e7818df4c196c7ef522e17cf076fffb3d18 (patch) | |
tree | a25fd2a4fcd1b1928dd4048fedd2652c494a0ad1 /examples/webview/minibrowser | |
parent | b70821eee3673d8a4d218433a49639e96fb0871a (diff) | |
parent | 8782bdc669cdabc104044951ce4424a42cec5f4f (diff) |
Merge remote-tracking branch 'origin/5.4' into dev
Conflicts:
src/webview/qquickviewcontroller.cpp
src/webview/qquickviewcontroller_p.h
src/webview/qwebview_ios.mm
src/webview/qwebview_ios_p.h
src/webview/qwebview_p_p.h
src/webview/qwindowcontrolleritem_ios.mm
Change-Id: I0454a007bf8297064045d5d193e74a08c9703f12
Diffstat (limited to 'examples/webview/minibrowser')
-rw-r--r-- | examples/webview/minibrowser/+android/LoadProgressStyle.qml | 52 | ||||
-rw-r--r-- | examples/webview/minibrowser/LoadProgressStyle.qml | 57 | ||||
-rw-r--r-- | examples/webview/minibrowser/images/left-32.png | bin | 1799 -> 831 bytes | |||
-rw-r--r-- | examples/webview/minibrowser/images/refresh-32.png | bin | 0 -> 1301 bytes | |||
-rw-r--r-- | examples/webview/minibrowser/images/right-32.png | bin | 1804 -> 822 bytes | |||
-rw-r--r-- | examples/webview/minibrowser/images/stop-32.png | bin | 0 -> 639 bytes | |||
-rw-r--r-- | examples/webview/minibrowser/main.cpp | 9 | ||||
-rw-r--r-- | examples/webview/minibrowser/main.qml | 62 | ||||
-rw-r--r-- | examples/webview/minibrowser/qml.qrc | 4 |
9 files changed, 172 insertions, 12 deletions
diff --git a/examples/webview/minibrowser/+android/LoadProgressStyle.qml b/examples/webview/minibrowser/+android/LoadProgressStyle.qml new file mode 100644 index 0000000..31fb407 --- /dev/null +++ b/examples/webview/minibrowser/+android/LoadProgressStyle.qml @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** 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 The Qt Company Ltd 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..a334c75 --- /dev/null +++ b/examples/webview/minibrowser/LoadProgressStyle.qml @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** 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 The Qt Company Ltd 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 Binary files differindex ec4107b..28e4dda 100644 --- a/examples/webview/minibrowser/images/left-32.png +++ b/examples/webview/minibrowser/images/left-32.png diff --git a/examples/webview/minibrowser/images/refresh-32.png b/examples/webview/minibrowser/images/refresh-32.png Binary files differnew file mode 100644 index 0000000..886cad4 --- /dev/null +++ b/examples/webview/minibrowser/images/refresh-32.png diff --git a/examples/webview/minibrowser/images/right-32.png b/examples/webview/minibrowser/images/right-32.png Binary files differindex 0f6ba86..00ccf43 100644 --- a/examples/webview/minibrowser/images/right-32.png +++ b/examples/webview/minibrowser/images/right-32.png diff --git a/examples/webview/minibrowser/images/stop-32.png b/examples/webview/minibrowser/images/stop-32.png Binary files differnew file mode 100644 index 0000000..3f5fb8b --- /dev/null +++ b/examples/webview/minibrowser/images/stop-32.png diff --git a/examples/webview/minibrowser/main.cpp b/examples/webview/minibrowser/main.cpp index bc10a69..5660cac 100644 --- a/examples/webview/minibrowser/main.cpp +++ b/examples/webview/minibrowser/main.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** @@ -17,8 +17,8 @@ ** 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 +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** @@ -111,6 +111,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..fe66a4e 100644 --- a/examples/webview/minibrowser/main.qml +++ b/examples/webview/minibrowser/main.qml @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** @@ -17,8 +17,8 @@ ** 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 +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** @@ -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> |