From 02118d951ca82d114b29c791848ff02e07b27372 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Tinkl?= Date: Thu, 21 Nov 2019 13:49:40 +0100 Subject: [webbrowser] implement a sample web browser app based on Qt WebEngine Change-Id: I58ecd3c40e0d3da0cf3424cf57542f7b1dfb7dc4 Reviewed-by: Georg Leugner --- com.luxoft.webbrowser/Main.qml | 62 ++++++++++++++ com.luxoft.webbrowser/UrlField.qml | 89 ++++++++++++++++++++ com.luxoft.webbrowser/WBView.qml | 107 ++++++++++++++++++++++++ com.luxoft.webbrowser/com.luxoft.webbrowser.pro | 16 ++++ com.luxoft.webbrowser/icon.png | Bin 0 -> 1034 bytes com.luxoft.webbrowser/info.yaml | 11 +++ qt-auto-extra-apps.pro | 4 +- 7 files changed, 288 insertions(+), 1 deletion(-) create mode 100644 com.luxoft.webbrowser/Main.qml create mode 100644 com.luxoft.webbrowser/UrlField.qml create mode 100644 com.luxoft.webbrowser/WBView.qml create mode 100644 com.luxoft.webbrowser/com.luxoft.webbrowser.pro create mode 100644 com.luxoft.webbrowser/icon.png create mode 100644 com.luxoft.webbrowser/info.yaml diff --git a/com.luxoft.webbrowser/Main.qml b/com.luxoft.webbrowser/Main.qml new file mode 100644 index 0000000..1225d0b --- /dev/null +++ b/com.luxoft.webbrowser/Main.qml @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Neptune 3 IVI UI. +** +** $QT_BEGIN_LICENSE:GPL-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: GPL-3.0 +** +****************************************************************************/ + +import QtQuick 2.8 +import application.windows 1.0 +import shared.utils 1.0 + +import "." + +ApplicationCCWindow { + id: root + + MultiPointTouchArea { + anchors.fill: parent + anchors.margins: 30 + touchPoints: [ TouchPoint { id: touchPoint1 } ] + + property int count: 0 + onReleased: { + count += 1; + root.setWindowProperty("activationCount", count); + } + } + + WBView { + x: root.exposedRect.x + y: root.exposedRect.y + width: root.exposedRect.width + height: root.exposedRect.height + + state: root.neptuneState + bottomWidgetHide: root.exposedRect.height === root.targetHeight + } +} diff --git a/com.luxoft.webbrowser/UrlField.qml b/com.luxoft.webbrowser/UrlField.qml new file mode 100644 index 0000000..4ff0dd2 --- /dev/null +++ b/com.luxoft.webbrowser/UrlField.qml @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Neptune 3 IVI UI. +** +** $QT_BEGIN_LICENSE:GPL-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: GPL-3.0 +** +****************************************************************************/ + +import QtQuick 2.12 +import QtQuick.Controls 2.12 +import QtQuick.Layouts 1.12 +import QtQuick.VirtualKeyboard 2.4 + +import shared.controls 1.0 +import shared.utils 1.0 +import shared.Style 1.0 +import shared.Sizes 1.0 + +TextField { + id: root + font.family: Style.fontFamily + font.pixelSize: Sizes.fontSizeM + color: Style.contrastColor + selectedTextColor: Style.contrastColor + leftPadding: Sizes.dp(18) + rightPadding: Sizes.dp(70) + horizontalAlignment: TextInput.AlignLeft + inputMethodHints: Qt.ImhNoAutoUppercase | Qt.ImhUrlCharactersOnly + EnterKeyAction.enabled: !!text + EnterKeyAction.actionId: EnterKeyAction.Go + + property alias busy: searchBusyIndicator.running + + signal urlRequested(string url) + + onActiveFocusChanged: { + if (activeFocus) selectAll() + } + + onAccepted: { + var pattern = /^((http|https|ftp):\/\/)/; + var result = text; + + if (!pattern.test(result)) { + result = "http://" + result; + } + + root.urlRequested(result); + } + + background: Rectangle { + border.color: Style.buttonColor + border.width: Sizes.dp(1) + color: "transparent" + radius: height/2 + BusyIndicator { + id: searchBusyIndicator + anchors.right: parent.right + anchors.rightMargin: Sizes.dp(18) + anchors.verticalCenter: parent.verticalCenter + height: parent.height + width: height + visible: running + } + } +} diff --git a/com.luxoft.webbrowser/WBView.qml b/com.luxoft.webbrowser/WBView.qml new file mode 100644 index 0000000..bf8f89f --- /dev/null +++ b/com.luxoft.webbrowser/WBView.qml @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Neptune 3 IVI UI. +** +** $QT_BEGIN_LICENSE:GPL-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: GPL-3.0 +** +****************************************************************************/ + +import QtQuick 2.12 +import QtQuick.Controls 2.12 +import QtQuick.Layouts 1.12 +import QtWebEngine 1.8 + +import shared.animations 1.0 +import shared.controls 1.0 +import shared.utils 1.0 +import shared.Style 1.0 +import shared.Sizes 1.0 + +Item { + id: root + + property bool bottomWidgetHide: false + + // Top content background + Image { + id: topContentBg + anchors.left: parent.left + anchors.right: parent.right + anchors.top: parent.top + height: Sizes.dp(436) + source: Style.image("app-fullscreen-top-bg") + visible: root.state === "Maximized" + } + + ColumnLayout { + anchors.fill: parent + + ToolBar { + id: toolbar + Layout.fillWidth: true + Layout.preferredHeight: Sizes.dp(66) + padding: Sizes.dp(9) + RowLayout { + anchors.fill: parent + ToolButton { + id: btnBack + icon.name: LayoutMirroring.enabled ? "ic_forward" : "ic_back" + onClicked: webview.goBack() + enabled: webview.canGoBack + } + ToolButton { + id: btnForward + icon.name: LayoutMirroring.enabled ? "ic_back" : "ic_forward" + onClicked: webview.goForward() + enabled: webview.canGoForward + } + ToolButton { + id: btnStopReload + icon.name: webview.loading ? "ic-close" : "ic-update" + onClicked: webview.loading ? webview.stop() : webview.reload() + } + UrlField { + id: urlField + Layout.fillWidth: true + busy: webview.loading + onUrlRequested: webview.url = url + } + } + } + + WebEngineView { + Layout.fillWidth: true + Layout.fillHeight: true + id: webview + url: "https://www.luxoft.com/automotive/" + onLoadingChanged: { + if (loadRequest.status === WebEngineLoadRequest.LoadSucceededStatus) { + urlField.text = loadRequest.url; + } + } + } + } +} diff --git a/com.luxoft.webbrowser/com.luxoft.webbrowser.pro b/com.luxoft.webbrowser/com.luxoft.webbrowser.pro new file mode 100644 index 0000000..a147e3a --- /dev/null +++ b/com.luxoft.webbrowser/com.luxoft.webbrowser.pro @@ -0,0 +1,16 @@ +TEMPLATE = aux + +FILES += info.yaml \ + icon.png \ + Main.qml \ + UrlField.qml \ + WBView.qml + +app.files = $$FILES +app.path = /apps/com.luxoft.webbrowser +INSTALLS += app + +AM_MANIFEST = info.yaml +AM_PACKAGE_DIR = $$app.path + +load(am-app) diff --git a/com.luxoft.webbrowser/icon.png b/com.luxoft.webbrowser/icon.png new file mode 100644 index 0000000..2734956 Binary files /dev/null and b/com.luxoft.webbrowser/icon.png differ diff --git a/com.luxoft.webbrowser/info.yaml b/com.luxoft.webbrowser/info.yaml new file mode 100644 index 0000000..54ae9e8 --- /dev/null +++ b/com.luxoft.webbrowser/info.yaml @@ -0,0 +1,11 @@ +formatVersion: 1 +formatType: am-application +--- +id: 'com.luxoft.webbrowser' +icon: 'icon.png' +code: 'Main.qml' +runtime: 'qml' +name: + en: 'Web Browser' + +categories: [ 'productivity', 'widget' ] diff --git a/qt-auto-extra-apps.pro b/qt-auto-extra-apps.pro index a4ec8fe..d1f8056 100644 --- a/qt-auto-extra-apps.pro +++ b/qt-auto-extra-apps.pro @@ -1,4 +1,6 @@ TEMPLATE = subdirs SUBDIRS = com.pelagicore.camera \ com.pelagicore.spotify \ - com.pelagicore.netflix + com.pelagicore.netflix \ + com.luxoft.webbrowser + -- cgit v1.2.3