feat(GODT-2770): proof of concept for web view as a tool window.

This commit is contained in:
Xavier Michelon
2023-07-20 18:16:44 +02:00
parent 87e79fdcba
commit 7b96a07cf5
8 changed files with 74 additions and 16 deletions

View File

@ -272,6 +272,7 @@ signals: // Signals received from the Go backend, to be forwarded to QML
void hideMainWindow(); ///< Signal for the 'hideMainWindow' gRPC stream event.
void showHelp(); ///< Signal for the 'showHelp' event (from the context menu).
void showSettings(); ///< Signal for the 'showHelp' event (from the context menu).
void showWebViewWindow(QString const &url); ///< Signal the the 'showWebViewWindow' event
void selectUser(QString const& userID, bool forceShowWindow); ///< Signal emitted in order to selected a user with a given ID in the list.
void genericError(QString const &title, QString const &description); ///< Signal for the 'genericError' gRPC stream event.
void imapLoginWhileSignedOut(QString const& username); ///< Signal for the notification of IMAP login attempt on a signed out account.

View File

@ -100,6 +100,7 @@
<file>qml/Proton/TextArea.qml</file>
<file>qml/Proton/TextField.qml</file>
<file>qml/Proton/Toggle.qml</file>
<file>qml/Proton/WebView.qml</file>
<file>qml/Proton/WebViewOverlay.qml</file>
<file>qml/QuestionItem.qml</file>
<file>qml/Resources/bug_report_flow.json</file>
@ -111,5 +112,6 @@
<file>qml/SplashScreen.qml</file>
<file>qml/Status.qml</file>
<file>qml/WelcomeGuide.qml</file>
<file>qml/WebViewWindow.qml</file>
</qresource>
</RCC>

View File

@ -69,6 +69,21 @@ QtObject {
Backend.setNormalTrayIcon();
}
}
property WebViewWindow _webviewWindow: WebViewWindow {
id: webViewWindow
flags: Qt.Tool
transientParent: mainWindow
visible: false
Connections {
function onShowWebViewWindow(url) {
webViewWindow.url = url;
webViewWindow.show();
}
target: Backend
}
}
property var title: Backend.appname
function bound(num, lowerLimit, upperLimit) {

View File

@ -104,7 +104,7 @@ SettingsView {
type: Label.Caption
onLinkActivated: function (link) {
Qt.openUrlExternally(link);
Backend.showWebViewWindow(link)
}
}
}

View File

@ -191,6 +191,16 @@ ApplicationWindow {
}
}
}
WebView {
id: webViewOverlay
anchors.fill: parent
colorScheme: root.colorScheme
overlay: true
url: ""
visible: false
}
NotificationPopups {
colorScheme: root.colorScheme
mainWindow: root
@ -200,11 +210,4 @@ ApplicationWindow {
id: splashScreen
colorScheme: root.colorScheme
}
WebViewOverlay {
id: webViewOverlay
anchors.fill: parent
colorScheme: root.colorScheme
url: ""
visible: false
}
}

View File

@ -16,41 +16,47 @@ import QtQuick.Layouts
import QtQuick.Controls
import QtQuick.Controls.impl
import QtWebView
import QtQuick.Templates as T
import "." as Proton
Item {
id: root
property ColorScheme colorScheme
property url url
property bool overlay: true
property string url: ""
function showBlankPage() {
webView.loadHtml("<!doctype html><meta charset=utf-8><title>blank</title>", "blank.html");
}
Rectangle {
anchors.fill: parent
color: "#000"
opacity: ProtonStyle.web_view_overlay_opacity
visible: overlay
}
Rectangle {
anchors.fill: parent
anchors.margins: ProtonStyle.web_view_overlay_margin
anchors.margins: overlay ? ProtonStyle.web_view_overlay_margin : 0
color: root.colorScheme.background_norm
radius: ProtonStyle.web_view_corner_radius
ColumnLayout {
anchors.bottomMargin: 0
anchors.fill: parent
anchors.leftMargin: ProtonStyle.web_view_overlay_horizontal_margin
anchors.rightMargin: ProtonStyle.web_view_overlay_horizontal_margin
anchors.topMargin: ProtonStyle.web_view_overlay_vertical_margin
anchors.leftMargin: overlay ? ProtonStyle.web_view_overlay_horizontal_margin : 0
anchors.rightMargin: overlay ? ProtonStyle.web_view_overlay_horizontal_margin : 0
anchors.topMargin: overlay ? ProtonStyle.web_view_overlay_vertical_margin : 0
spacing: 0
Rectangle {
Layout.fillHeight: true
Layout.fillWidth: true
border.color: root.colorScheme.border_norm
border.width: ProtonStyle.web_view_overley_border_width
border.width: overlay ? ProtonStyle.web_view_overley_border_width : 0
WebView {
id: webView
anchors.fill: parent
anchors.margins: ProtonStyle.web_view_overley_border_width
url: root.url
@ -63,6 +69,7 @@ Item {
Layout.topMargin: ProtonStyle.web_view_overlay_button_vertical_margin
colorScheme: root.colorScheme
text: qsTr("Close")
visible: overlay
onClicked: {
root.url = "";

View File

@ -36,4 +36,4 @@ Switch 4.0 Switch.qml
TextArea 4.0 TextArea.qml
TextField 4.0 TextField.qml
Toggle 4.0 Toggle.qml
WebViewOverlay 4.0 WebViewOverlay.qml
WebView 4.0 WebView.qml

View File

@ -0,0 +1,30 @@
// Copyright (c) 2023 Proton AG
// This file is part of Proton Mail Bridge.
// Proton Mail Bridge is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Proton Mail Bridge is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Proton Mail Bridge. If not, see <https://www.gnu.org/licenses/>.
import QtQml
import QtQuick
import QtQuick.Controls
import Proton
Window {
id: root
height: 600
width: 800
minimumWidth: 600
property string url
WebView {
anchors.fill: parent
colorScheme: ProtonStyle.currentStyle
overlay: false
url: root.url
}
}