diff --git a/internal/frontend/bridge-gui/bridge-gui/QMLBackend.h b/internal/frontend/bridge-gui/bridge-gui/QMLBackend.h index f16e9c59..0f086f7e 100644 --- a/internal/frontend/bridge-gui/bridge-gui/QMLBackend.h +++ b/internal/frontend/bridge-gui/bridge-gui/QMLBackend.h @@ -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. diff --git a/internal/frontend/bridge-gui/bridge-gui/Resources.qrc b/internal/frontend/bridge-gui/bridge-gui/Resources.qrc index d6164b36..0016eff5 100644 --- a/internal/frontend/bridge-gui/bridge-gui/Resources.qrc +++ b/internal/frontend/bridge-gui/bridge-gui/Resources.qrc @@ -100,6 +100,7 @@ qml/Proton/TextArea.qml qml/Proton/TextField.qml qml/Proton/Toggle.qml + qml/Proton/WebView.qml qml/Proton/WebViewOverlay.qml qml/QuestionItem.qml qml/Resources/bug_report_flow.json @@ -111,5 +112,6 @@ qml/SplashScreen.qml qml/Status.qml qml/WelcomeGuide.qml + qml/WebViewWindow.qml diff --git a/internal/frontend/bridge-gui/bridge-gui/qml/Bridge.qml b/internal/frontend/bridge-gui/bridge-gui/qml/Bridge.qml index 1f1a6c4c..8ee7c5e8 100644 --- a/internal/frontend/bridge-gui/bridge-gui/qml/Bridge.qml +++ b/internal/frontend/bridge-gui/bridge-gui/qml/Bridge.qml @@ -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) { diff --git a/internal/frontend/bridge-gui/bridge-gui/qml/HelpView.qml b/internal/frontend/bridge-gui/bridge-gui/qml/HelpView.qml index 58b64831..4a604989 100644 --- a/internal/frontend/bridge-gui/bridge-gui/qml/HelpView.qml +++ b/internal/frontend/bridge-gui/bridge-gui/qml/HelpView.qml @@ -104,7 +104,7 @@ SettingsView { type: Label.Caption onLinkActivated: function (link) { - Qt.openUrlExternally(link); + Backend.showWebViewWindow(link) } } } diff --git a/internal/frontend/bridge-gui/bridge-gui/qml/MainWindow.qml b/internal/frontend/bridge-gui/bridge-gui/qml/MainWindow.qml index c5b76877..3e53999a 100644 --- a/internal/frontend/bridge-gui/bridge-gui/qml/MainWindow.qml +++ b/internal/frontend/bridge-gui/bridge-gui/qml/MainWindow.qml @@ -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 - } } diff --git a/internal/frontend/bridge-gui/bridge-gui/qml/Proton/WebViewOverlay.qml b/internal/frontend/bridge-gui/bridge-gui/qml/Proton/WebView.qml similarity index 75% rename from internal/frontend/bridge-gui/bridge-gui/qml/Proton/WebViewOverlay.qml rename to internal/frontend/bridge-gui/bridge-gui/qml/Proton/WebView.qml index 7936f59b..dc064edd 100644 --- a/internal/frontend/bridge-gui/bridge-gui/qml/Proton/WebViewOverlay.qml +++ b/internal/frontend/bridge-gui/bridge-gui/qml/Proton/WebView.qml @@ -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("blank", "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 = ""; diff --git a/internal/frontend/bridge-gui/bridge-gui/qml/Proton/qmldir b/internal/frontend/bridge-gui/bridge-gui/qml/Proton/qmldir index 1b07d385..4e6ccf3a 100644 --- a/internal/frontend/bridge-gui/bridge-gui/qml/Proton/qmldir +++ b/internal/frontend/bridge-gui/bridge-gui/qml/Proton/qmldir @@ -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 diff --git a/internal/frontend/bridge-gui/bridge-gui/qml/WebViewWindow.qml b/internal/frontend/bridge-gui/bridge-gui/qml/WebViewWindow.qml new file mode 100644 index 00000000..12ecd3c3 --- /dev/null +++ b/internal/frontend/bridge-gui/bridge-gui/qml/WebViewWindow.qml @@ -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 . +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 + } +}