From ac57330b72643dcf3c5bc27223c740e756838c07 Mon Sep 17 00:00:00 2001 From: kugiigi Date: Wed, 30 Dec 2020 21:10:49 +0800 Subject: [PATCH] bring back fullscreen hint --- src/app/webbrowser/Browser.qml | 28 +++++++++++++++++------ src/app/webbrowser/TabComponent.qml | 35 ++++++++++++++++------------- 2 files changed, 40 insertions(+), 23 deletions(-) diff --git a/src/app/webbrowser/Browser.qml b/src/app/webbrowser/Browser.qml index 26fa7fc42..7bdf285f0 100644 --- a/src/app/webbrowser/Browser.qml +++ b/src/app/webbrowser/Browser.qml @@ -555,7 +555,7 @@ Common.BrowserView { objectName: "recentView" anchors.fill: parent - visible: bottomEdgeHandle.dragging || tabslist.animating || (state == "shown") + visible: ((browser.currentWebview && !browser.currentWebview.isFullScreen) && bottomEdgeHandle.dragging) || tabslist.animating || (state == "shown") onVisibleChanged: { if (visible) { @@ -967,12 +967,13 @@ Common.BrowserView { (Screen.orientation == Screen.primaryOrientation) onDraggingChanged: { - if (dragging) { - if (browser.thisWindow) { - browser.thisWindow.setFullscreen(false) - } - } else { - if (stage == 1) { + if (!dragging) { + if (browser.currentWebview && browser.currentWebview.isFullScreen) { + if (browser.thisWindow) { + browser.thisWindow.setFullscreen(false) + browser.currentWebview.fullScreenCancelled() + } + } else if (stage == 1) { if (tabsModel.count > 1) { tabslist.selectAndAnimateTab(1) } else { @@ -1266,6 +1267,7 @@ Common.BrowserView { } readonly property bool hasMouse: (miceModel.count + touchPadModel.count) > 0 + readonly property bool hasKeyboard: keyboardModel.count > 0 readonly property bool hasTouchScreen: touchScreenModel.count > 0 // Ref: https://code.google.com/p/chromium/codesearch#chromium/src/components/ui/zoom/page_zoom_constants.cc @@ -1755,6 +1757,18 @@ Common.BrowserView { onActivated: currentWebview.zoomController.resetSaveFit() } + // Escape: Exit webview fullscreen + Shortcut { + sequence: "Esc" + enabled: currentWebview && currentWebview.isFullScreen + onActivated: { + if (currentWebview.isFullScreen) { + thisWindow.setFullscreen(false) + currentWebview.fullScreenCancelled() + } + } + } + Loader { id: contentHandlerLoader source: "../ContentHandler.qml" diff --git a/src/app/webbrowser/TabComponent.qml b/src/app/webbrowser/TabComponent.qml index bdb764f83..e4703865c 100644 --- a/src/app/webbrowser/TabComponent.qml +++ b/src/app/webbrowser/TabComponent.qml @@ -209,13 +209,14 @@ Component { error.onCancelled.connect(webviewimpl.resetCertificateError) } } - - //onFullscreenChanged: { - // if (fullscreen) { - // fullscreenExitHintComponent.createObject(webviewimpl) - // } - //} */ + + onIsFullScreenChanged: { + if (isFullScreen) { + fullscreenExitHintComponent.createObject(webviewimpl) + } + } + Component { id: fullscreenExitHintComponent @@ -223,7 +224,11 @@ Component { id: fullscreenExitHint objectName: "fullscreenExitHint" - anchors.centerIn: parent + anchors { + horizontalCenter: parent.horizontalCenter + top: parent.top + topMargin : units.gu(5) + } height: units.gu(6) width: Math.min(units.gu(50), parent.width - units.gu(12)) radius: units.gu(1) @@ -253,8 +258,9 @@ Component { Label { color: theme.palette.normal.background font.weight: Font.Light + textSize: Label.Large anchors.centerIn: parent - text: bottomEdgeHandle.enabled + text: bottomEdgeHandle.enabled && !internal.hasKeyboard ? i18n.tr("Swipe Up To Exit Full Screen") : i18n.tr("Press ESC To Exit Full Screen") } @@ -267,15 +273,12 @@ Component { Connections { target: webviewimpl - // onFullscreenChanged: { - // if (!webviewimpl.fullscreen) { - // fullscreenExitHint.destroy() - // } - // } + onIsFullScreenChanged: { + if (!target.isFullScreen) { + fullscreenExitHint.destroy() + } + } } - - Component.onCompleted: bottomEdgeHint.forceShow = true - Component.onDestruction: bottomEdgeHint.forceShow = false } } }