diff options
34 files changed, 266 insertions, 1 deletions
diff --git a/basicsuite/shared/engine.h b/basicsuite/shared/engine.h index 1600fc6..43713c8 100644 --- a/basicsuite/shared/engine.h +++ b/basicsuite/shared/engine.h @@ -20,6 +20,8 @@ #include <QObject> #include <QSize> +#include <QString> +#include <QUrl> class QQmlEngine; class QQuickItem; @@ -36,6 +38,7 @@ class DummyEngine : public QObject public: explicit DummyEngine(QObject *parent = 0); + Q_INVOKABLE QUrl fromUserInput(const QString &userInput) { return QUrl::fromUserInput(userInput); } Q_INVOKABLE int smallFontSize() const { return qMax<int>(m_dpcm * 0.4, 10); } Q_INVOKABLE int fontSize() const { return qMax<int>(m_dpcm * 0.6, 14); } Q_INVOKABLE int titleFontSize() const { return qMax<int>(m_dpcm * 0.9, 20); } diff --git a/basicsuite/shared/main.cpp b/basicsuite/shared/main.cpp index d33b09c..d5b203f 100644 --- a/basicsuite/shared/main.cpp +++ b/basicsuite/shared/main.cpp @@ -34,14 +34,27 @@ #include <QtQml/QQmlContext> #include <QtQml/QQmlComponent> -#include "engine.h" +#if defined(USE_QTWEBENGINE) +#include <qtwebengineglobal.h> +#endif +#include "engine.h" int main(int argc, char **argv) { //qputenv("QT_IM_MODULE", QByteArray("qtvkb")); QApplication app(argc, argv); + + +#if defined(USE_QTWEBENGINE) + // This is currently needed by all QtWebEngine applications using the HW accelerated QQuickWebView. + // It enables sharing the QOpenGLContext of all QQuickWindows of the application. + // We have to do so until we expose a public API for it in Qt or choose to enable it + // by default earliest in Qt 5.4.0. + QWebEngine::initialize(); +#endif + QString path = app.applicationDirPath(); QPalette pal; diff --git a/basicsuite/shared/shared.pri b/basicsuite/shared/shared.pri index 8f66b7d..0d7392d 100644 --- a/basicsuite/shared/shared.pri +++ b/basicsuite/shared/shared.pri @@ -1,6 +1,11 @@ # widget dependecy is required by QtCharts demo QT += quick widgets +qtHaveModule(webengine) { + DEFINES += USE_QTWEBENGINE + QT += webengine +} + DESTPATH = /data/user/$$TARGET target.path = $$DESTPATH diff --git a/experimental/webgl/helloqt.html b/basicsuite/webengine/content/webgl/helloqt.html index 56c336c..56c336c 100644 --- a/experimental/webgl/helloqt.html +++ b/basicsuite/webengine/content/webgl/helloqt.html diff --git a/experimental/webgl/helloqt.js b/basicsuite/webengine/content/webgl/helloqt.js index d0ae216..d0ae216 100644 --- a/experimental/webgl/helloqt.js +++ b/basicsuite/webengine/content/webgl/helloqt.js diff --git a/experimental/webgl/qtlogo.js b/basicsuite/webengine/content/webgl/qtlogo.js index e2eba96..e2eba96 100644 --- a/experimental/webgl/qtlogo.js +++ b/basicsuite/webengine/content/webgl/qtlogo.js diff --git a/experimental/webgl/three.min.js b/basicsuite/webengine/content/webgl/three.min.js index 95b938c..95b938c 100644 --- a/experimental/webgl/three.min.js +++ b/basicsuite/webengine/content/webgl/three.min.js diff --git a/basicsuite/webengine/description.txt b/basicsuite/webengine/description.txt new file mode 100644 index 0000000..e725f8b --- /dev/null +++ b/basicsuite/webengine/description.txt @@ -0,0 +1,3 @@ +This example demonstrates the use of the QtWebEngine WebView with Qt Quick. + +Demo can be used to browse the internet (working network connection required) or run the off-line WebGL demo diff --git a/basicsuite/webengine/exclude.txt b/basicsuite/webengine/exclude.txt new file mode 100644 index 0000000..9372368 --- /dev/null +++ b/basicsuite/webengine/exclude.txt @@ -0,0 +1,2 @@ +android-emulator +linux-emulator diff --git a/basicsuite/webengine/main.qml b/basicsuite/webengine/main.qml new file mode 100644 index 0000000..299d779 --- /dev/null +++ b/basicsuite/webengine/main.qml @@ -0,0 +1,225 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: For any questions to Digia, please use the contact form at +** http://qt.digia.com/ +** +** This file is part of the examples of the Qt Enterprise Embedded. +** +** $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.1 +import QtQuick.Controls 1.1 +import QtQuick.Layouts 1.1 +import QtWebEngine 0.9 + +Rectangle { + id: root + z: 0 + visible: true + color: "black" + + width: 1280 + height: 800 + + property url defaultUrl: "content/webgl/helloqt.html" + + WebEngineView { + id: mainWebView + anchors.fill: parent + url: Qt.resolvedUrl(defaultUrl) + onLoadingChanged: { + if (!loading) { + addressBar.cursorPosition = 0 + toolBar.state = "address" + } + } + } + + MultiPointTouchArea { + z: showToolBarButton.z + width: parent.width + height: showToolBarButton.height + 15 + enabled: toolBar.state == "hidden" + + anchors.top: parent.top + onGestureStarted: { + showToolBarButton.clicked() + } + onReleased: { + showToolBarButton.clicked() + } + } + + Rectangle { + z: 1 + id: toolBar + color: "black" + opacity: 1 + + height: addressBar.height + showToolBarButton.height + 50 + y: 0 + + Behavior on y { + enabled: toolBar.state != "" + NumberAnimation { duration: 250 } + } + + Behavior on opacity { + enabled: toolBar.state != "" + NumberAnimation { duration: 250 } + } + + anchors { + left: parent.left + right: parent.right + } + + Timer { + id: hideTimer + interval: 3000 + running: (toolBar.state == "address" || toolBar.state == "") && !addressBar.activeFocus + onTriggered: { + if (toolBar.state == "address") + toolBar.state = "hidden" + if (toolBar.state == "") + toolBar.state = "address" + } + } + + state: "" + + states: [ + State { + name: "hidden" + PropertyChanges { target: toolBar; y: showToolBarButton.height - toolBar.height } + PropertyChanges { target: toolBar; opacity: 0.5 } + }, + State { + name: "address" + PropertyChanges { target: toolBar; y: 0 } + PropertyChanges { target: toolBar; opacity: 1 } + } + ] + + RowLayout { + id: addressRow + height: 65 + anchors { + top: parent.top + bottom: showToolBarButton.top + left: parent.left + right: parent.right + margins: 10 + topMargin: 40 + } + ToolButton { + id: backButton + Layout.fillHeight: true + iconSource: "ui/icons/go-previous.png" + onClicked: mainWebView.goBack() + enabled: mainWebView.canGoBack + } + ToolButton { + id: forwardButton + Layout.fillHeight: true + iconSource: "ui/icons/go-next.png" + onClicked: mainWebView.goForward() + enabled: mainWebView.canGoForward + } + ToolButton { + id: reloadButton + Layout.fillHeight: true + iconSource: mainWebView.loading ? "ui/icons/process-stop.png" : "ui/icons/view-refresh.png" + onClicked: mainWebView.loading ? mainWebView.stop() : mainWebView.reload() + } + TextField { + id: addressBar + focus: true + textColor: "black" + implicitHeight: 40 + font.pointSize: 10 + inputMethodHints: Qt.ImhUrlCharactersOnly | Qt.ImhNoPredictiveText + Image { + anchors { + right: parent.right + verticalCenter: addressBar.verticalCenter + rightMargin: 5 + } + verticalAlignment: Image.AlignLeft + z: 2 + id: faviconImage + width: 20; height: 20 + source: mainWebView.icon + } + Layout.fillWidth: true + text: mainWebView.url + onAccepted: { + mainWebView.url = engine.fromUserInput(text) + } + } + } + + ToolButton { + id: showToolBarButton + height: 25 + iconSource: (toolBar.state == "hidden") ? "ui/icons/down.png" : "ui/icons/up.png" + onClicked: { + if (toolBar.state == "hidden") + toolBar.state = "address" + else + toolBar.state = "hidden" + } + anchors { + bottom: parent.bottom + horizontalCenter: parent.horizontalCenter + bottomMargin: (toolBar.state == "hidden") ? 0 : 5 + } + } + } + ProgressBar { + id: progressBar + height: 5 + z: toolBar.z + 1 + visible: value != 0 + anchors { + top: toolBar.bottom + left: parent.left + right: parent.right + } + minimumValue: 0 + maximumValue: 100 + value: (mainWebView.loadProgress < 100) ? mainWebView.loadProgress : 0 + } +} diff --git a/basicsuite/webengine/preview_l.jpg b/basicsuite/webengine/preview_l.jpg Binary files differnew file mode 100644 index 0000000..963258a --- /dev/null +++ b/basicsuite/webengine/preview_l.jpg diff --git a/basicsuite/webengine/title.txt b/basicsuite/webengine/title.txt new file mode 100644 index 0000000..25a9f76 --- /dev/null +++ b/basicsuite/webengine/title.txt @@ -0,0 +1 @@ +011. QtWebEngine Web Browser Demo diff --git a/basicsuite/webengine/ui/icons/busy.png b/basicsuite/webengine/ui/icons/busy.png Binary files differnew file mode 100644 index 0000000..3b60d26 --- /dev/null +++ b/basicsuite/webengine/ui/icons/busy.png diff --git a/basicsuite/webengine/ui/icons/cube.png b/basicsuite/webengine/ui/icons/cube.png Binary files differnew file mode 100644 index 0000000..a5b337b --- /dev/null +++ b/basicsuite/webengine/ui/icons/cube.png diff --git a/basicsuite/webengine/ui/icons/down.png b/basicsuite/webengine/ui/icons/down.png Binary files differnew file mode 100644 index 0000000..cabd356 --- /dev/null +++ b/basicsuite/webengine/ui/icons/down.png diff --git a/basicsuite/webengine/ui/icons/go-next.png b/basicsuite/webengine/ui/icons/go-next.png Binary files differnew file mode 100644 index 0000000..c8b9b76 --- /dev/null +++ b/basicsuite/webengine/ui/icons/go-next.png diff --git a/basicsuite/webengine/ui/icons/go-previous.png b/basicsuite/webengine/ui/icons/go-previous.png Binary files differnew file mode 100644 index 0000000..7a71d7d --- /dev/null +++ b/basicsuite/webengine/ui/icons/go-previous.png diff --git a/basicsuite/webengine/ui/icons/grid.png b/basicsuite/webengine/ui/icons/grid.png Binary files differnew file mode 100644 index 0000000..2959d1d --- /dev/null +++ b/basicsuite/webengine/ui/icons/grid.png diff --git a/basicsuite/webengine/ui/icons/home.png b/basicsuite/webengine/ui/icons/home.png Binary files differnew file mode 100644 index 0000000..92d01d1 --- /dev/null +++ b/basicsuite/webengine/ui/icons/home.png diff --git a/basicsuite/webengine/ui/icons/list.png b/basicsuite/webengine/ui/icons/list.png Binary files differnew file mode 100644 index 0000000..6cbc8b3 --- /dev/null +++ b/basicsuite/webengine/ui/icons/list.png diff --git a/basicsuite/webengine/ui/icons/pin-checked.png b/basicsuite/webengine/ui/icons/pin-checked.png Binary files differnew file mode 100644 index 0000000..aa50f2b --- /dev/null +++ b/basicsuite/webengine/ui/icons/pin-checked.png diff --git a/basicsuite/webengine/ui/icons/pin-unchecked.png b/basicsuite/webengine/ui/icons/pin-unchecked.png Binary files differnew file mode 100644 index 0000000..c11411b --- /dev/null +++ b/basicsuite/webengine/ui/icons/pin-unchecked.png diff --git a/basicsuite/webengine/ui/icons/pin.png b/basicsuite/webengine/ui/icons/pin.png Binary files differnew file mode 100644 index 0000000..4439f04 --- /dev/null +++ b/basicsuite/webengine/ui/icons/pin.png diff --git a/basicsuite/webengine/ui/icons/plus.png b/basicsuite/webengine/ui/icons/plus.png Binary files differnew file mode 100644 index 0000000..33b03d2 --- /dev/null +++ b/basicsuite/webengine/ui/icons/plus.png diff --git a/basicsuite/webengine/ui/icons/process-stop.png b/basicsuite/webengine/ui/icons/process-stop.png Binary files differnew file mode 100644 index 0000000..8399059 --- /dev/null +++ b/basicsuite/webengine/ui/icons/process-stop.png diff --git a/basicsuite/webengine/ui/icons/settings.png b/basicsuite/webengine/ui/icons/settings.png Binary files differnew file mode 100644 index 0000000..347a0e5 --- /dev/null +++ b/basicsuite/webengine/ui/icons/settings.png diff --git a/basicsuite/webengine/ui/icons/stack.png b/basicsuite/webengine/ui/icons/stack.png Binary files differnew file mode 100644 index 0000000..d631adc --- /dev/null +++ b/basicsuite/webengine/ui/icons/stack.png diff --git a/basicsuite/webengine/ui/icons/up.png b/basicsuite/webengine/ui/icons/up.png Binary files differnew file mode 100644 index 0000000..8a2e626 --- /dev/null +++ b/basicsuite/webengine/ui/icons/up.png diff --git a/basicsuite/webengine/ui/icons/view-refresh.png b/basicsuite/webengine/ui/icons/view-refresh.png Binary files differnew file mode 100644 index 0000000..265585b --- /dev/null +++ b/basicsuite/webengine/ui/icons/view-refresh.png diff --git a/basicsuite/webengine/ui/icons/wifi-off.png b/basicsuite/webengine/ui/icons/wifi-off.png Binary files differnew file mode 100644 index 0000000..4c0490d --- /dev/null +++ b/basicsuite/webengine/ui/icons/wifi-off.png diff --git a/basicsuite/webengine/ui/icons/wifi-on.png b/basicsuite/webengine/ui/icons/wifi-on.png Binary files differnew file mode 100644 index 0000000..8bdc553 --- /dev/null +++ b/basicsuite/webengine/ui/icons/wifi-on.png diff --git a/basicsuite/webengine/ui/icons/wifi.png b/basicsuite/webengine/ui/icons/wifi.png Binary files differnew file mode 100644 index 0000000..8a0d9e0 --- /dev/null +++ b/basicsuite/webengine/ui/icons/wifi.png diff --git a/basicsuite/webengine/ui/icons/window.png b/basicsuite/webengine/ui/icons/window.png Binary files differnew file mode 100644 index 0000000..a06602b --- /dev/null +++ b/basicsuite/webengine/ui/icons/window.png diff --git a/basicsuite/webengine/webengine.pro b/basicsuite/webengine/webengine.pro new file mode 100644 index 0000000..2a1bd91 --- /dev/null +++ b/basicsuite/webengine/webengine.pro @@ -0,0 +1,13 @@ +TARGET = webengine + +include(../shared/shared.pri) +b2qtdemo_deploy_defaults() + +content.files = \ + ui \ + *.qml +content.path = $$DESTPATH + +OTHER_FILES += $${content.files} + +INSTALLS += target content |