From 17052299fb095f56229dac722b957463e2bf0b87 Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Fri, 11 Jun 2021 11:39:23 +0200 Subject: [PATCH] Fix webview clipping on OSX --- nymea-app/ui/mainviews/dashboard/Dashboard.qml | 2 -- .../mainviews/dashboard/DashboardWebViewDelegate.qml | 12 +++++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/nymea-app/ui/mainviews/dashboard/Dashboard.qml b/nymea-app/ui/mainviews/dashboard/Dashboard.qml index b7b10c1c..d8be4856 100644 --- a/nymea-app/ui/mainviews/dashboard/Dashboard.qml +++ b/nymea-app/ui/mainviews/dashboard/Dashboard.qml @@ -129,13 +129,11 @@ Item { target: loader.item property: "bottomClip" value: loader.bottomClip - when: ["android", "ios"].indexOf(Qt.platform.os) >= 0 } Binding { target: loader.item property: "topClip" value: loader.topClip - when: ["android", "ios"].indexOf(Qt.platform.os) >= 0 } Connections { target: loader.item diff --git a/nymea-app/ui/mainviews/dashboard/DashboardWebViewDelegate.qml b/nymea-app/ui/mainviews/dashboard/DashboardWebViewDelegate.qml index fd30d39f..3fee6313 100644 --- a/nymea-app/ui/mainviews/dashboard/DashboardWebViewDelegate.qml +++ b/nymea-app/ui/mainviews/dashboard/DashboardWebViewDelegate.qml @@ -64,10 +64,16 @@ DashboardDelegateBase { } } - property bool needsHack: ["android", "ios"].indexOf(Qt.platform.os) >= 0 + // Some platforms cannot embed webviews inside an app. In those cases, a platform native + // Browser will be overlaid on top of the app. As we can't draw on top of that, we'll need to be + // clever in resizing and hding... + property bool needsHack: ["android", "ios", "osx"].indexOf(Qt.platform.os) >= 0 property bool webViewVisible: !needsHack || (!app.mainMenu.visible && !root.editMode && root.topClip < root.height && root.bottomClip < height && !pageStack.busy) + property int topClip: needsHack ? root.topClip : 0 + property int bottomClip: needsHack ? root.bottomClip : 0 + property string webViewString: ' import QtQuick 2.8; @@ -77,8 +83,8 @@ DashboardDelegateBase { WebView { id: webView anchors.fill: parent - anchors.bottomMargin: root.bottomClip + Style.smallMargins - anchors.topMargin: root.topClip + Style.smallMargins + anchors.bottomMargin: delegateRoot.bottomClip + Style.smallMargins + anchors.topMargin: delegateRoot.topClip + Style.smallMargins url: root.item.url enabled: root.item.interactive visible: delegateRoot.webViewVisible