From 533704dfe1d02544b0440e6964fd57abd0209685 Mon Sep 17 00:00:00 2001 From: Chris Clime Date: Thu, 9 Jul 2020 17:54:45 +0200 Subject: [PATCH 1/5] adapt ChromeStateTracker / ScrollTracker for QtWebEngine --- src/app/ChromeStateTracker.qml | 12 ++++++----- src/app/ScrollTracker.qml | 38 +++++++++++++++------------------- 2 files changed, 24 insertions(+), 26 deletions(-) diff --git a/src/app/ChromeStateTracker.qml b/src/app/ChromeStateTracker.qml index 54e239f67..84ab6e6bb 100644 --- a/src/app/ChromeStateTracker.qml +++ b/src/app/ChromeStateTracker.qml @@ -28,13 +28,13 @@ ScrollTracker { active: webview && !webview.fullscreen onScrolledUp: { - if (!header.moving && chromeStateChangeTimer.settled) { + if (chromeStateChangeTimer.settled) { delayedAutoHideTimer.up = true delayedAutoHideTimer.restart() } } onScrolledDown: { - if (!header.moving && chromeStateChangeTimer.settled) { + if (chromeStateChangeTimer.settled) { delayedAutoHideTimer.up = false delayedAutoHideTimer.restart() } @@ -69,14 +69,16 @@ ScrollTracker { // See https://bugs.launchpad.net/morph-browser/+bug/1354700. Timer { id: chromeStateChangeTimer - interval: 50 - running: !chromeStateTracker.header.moving + interval: 150 onTriggered: settled = true property bool settled: true } Connections { target: chromeStateTracker.header - onMovingChanged: chromeStateChangeTimer.settled = false + onStateChanged: { + chromeStateChangeTimer.settled = false; + chromeStateChangeTimer.restart(); + } } } diff --git a/src/app/ScrollTracker.qml b/src/app/ScrollTracker.qml index d04fb29c3..b3727918b 100644 --- a/src/app/ScrollTracker.qml +++ b/src/app/ScrollTracker.qml @@ -24,8 +24,8 @@ Item { property var webview property var header - readonly property bool nearTop: webview ? webview.contentY < (internal.headerHeight / internal.contentRatio) : false - readonly property bool nearBottom: webview ? (webview.contentY + internal.viewportHeight + internal.headerHeight / internal.contentRatio) > internal.contentHeight : false + readonly property bool nearTop: webview ? (webview.scrollPosition.y / webview.scaleFactor) < units.gu(4) : false + readonly property bool nearBottom: webview ? ((webview.contentsSize.height - webview.scrollPosition.y) / webview.scaleFactor - webview.height) < units.gu(4) : false property bool active: true @@ -37,29 +37,25 @@ Item { QtObject { id: internal - - readonly property real headerHeight: scrollTracker.header ? scrollTracker.header.height : 0 - readonly property real headerVisibleHeight: scrollTracker.header ? scrollTracker.header.visibleHeight : 0 - - readonly property real contentHeight: scrollTracker.webview ? scrollTracker.webview.contentHeight + headerVisibleHeight : 0.0 - readonly property real viewportHeight: scrollTracker.webview ? scrollTracker.webview.viewportHeight + headerVisibleHeight : 0.0 - readonly property real maxContentY: scrollTracker.webview ? scrollTracker.webview.contentHeight - scrollTracker.webview.viewportHeight : 0.0 - - readonly property real contentRatio: scrollTracker.webview ? scrollTracker.webview.viewportHeight / scrollTracker.webview.contentHeight : 1.0 - - readonly property real currentScrollFraction: (maxContentY == 0.0) ? 0.0 : (scrollTracker.webview.contentY / maxContentY) - property real previousScrollFraction: 0.0 + property real previousScrollPositionY: 0.0 } Connections { target: scrollTracker.active ? scrollTracker.webview : null - onContentYChanged: { - var old = internal.previousScrollFraction - internal.previousScrollFraction = internal.currentScrollFraction - if (internal.currentScrollFraction < old) { - scrollTracker.scrolledUp() - } else if (internal.currentScrollFraction > old) { - scrollTracker.scrolledDown() + enabled: ! header.moving + onScrollPositionChanged: { + + if (scrollTracker.webview.scrollPosition.y === internal.previousScrollPositionY) { + return; + } + + var oldScrollPosition = internal.previousScrollPositionY; + internal.previousScrollPositionY = scrollTracker.webview.scrollPosition.y; + + if (internal.previousScrollPositionY < oldScrollPosition) { + scrollTracker.scrolledUp() + } else if (internal.previousScrollPositionY > oldScrollPosition) { + scrollTracker.scrolledDown() } } } From cbb2dce64a673d3ba06cd05c83dd1a5b456a5b09 Mon Sep 17 00:00:00 2001 From: Chris Clime Date: Thu, 9 Jul 2020 18:24:21 +0200 Subject: [PATCH 2/5] hide chrome while recent view (tab list) is visible --- src/app/webbrowser/Browser.qml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/app/webbrowser/Browser.qml b/src/app/webbrowser/Browser.qml index 96d81eeef..7640c0036 100644 --- a/src/app/webbrowser/Browser.qml +++ b/src/app/webbrowser/Browser.qml @@ -551,9 +551,12 @@ Common.BrowserView { anchors.fill: parent visible: bottomEdgeHandle.dragging || tabslist.animating || (state == "shown") onVisibleChanged: { - if (visible) - { - currentWebview.hideContextMenu() + if (visible) { + currentWebview.hideContextMenu(); + chrome.state = "hidden"; + } + else { + chrome.state = "shown"; } } From bb4a50d9aa15299a3cae13fbf4425103e5953e58 Mon Sep 17 00:00:00 2001 From: Chris Clime Date: Sun, 13 Jun 2021 14:53:59 +0200 Subject: [PATCH 3/5] - no longer use "Connections.enabled" property because of error "Connection.enabled is not available in QtQuick 2.4." - only trigger scrolledUp / scrolledDown while the webview is not loading --- src/app/ScrollTracker.qml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/app/ScrollTracker.qml b/src/app/ScrollTracker.qml index b3727918b..5c74dbf61 100644 --- a/src/app/ScrollTracker.qml +++ b/src/app/ScrollTracker.qml @@ -41,8 +41,7 @@ Item { } Connections { - target: scrollTracker.active ? scrollTracker.webview : null - enabled: ! header.moving + target: scrollTracker.active && !header.moving && !scrollTracker.webview.loading ? scrollTracker.webview : null onScrollPositionChanged: { if (scrollTracker.webview.scrollPosition.y === internal.previousScrollPositionY) { From 409725a5d8ba79e821c2c39b4f32fd1c7fba30b2 Mon Sep 17 00:00:00 2001 From: Chris Clime Date: Sun, 13 Jun 2021 18:39:43 +0200 Subject: [PATCH 4/5] move !webview.loading to ChromeStateTracker --- src/app/ChromeStateTracker.qml | 2 +- src/app/ScrollTracker.qml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/ChromeStateTracker.qml b/src/app/ChromeStateTracker.qml index 84ab6e6bb..b7ba904d9 100644 --- a/src/app/ChromeStateTracker.qml +++ b/src/app/ChromeStateTracker.qml @@ -25,7 +25,7 @@ import QtQuick 2.4 ScrollTracker { id: chromeStateTracker - active: webview && !webview.fullscreen + active: webview && !webview.fullscreen && !webview.loading onScrolledUp: { if (chromeStateChangeTimer.settled) { diff --git a/src/app/ScrollTracker.qml b/src/app/ScrollTracker.qml index 5c74dbf61..7479b7026 100644 --- a/src/app/ScrollTracker.qml +++ b/src/app/ScrollTracker.qml @@ -41,7 +41,7 @@ Item { } Connections { - target: scrollTracker.active && !header.moving && !scrollTracker.webview.loading ? scrollTracker.webview : null + target: scrollTracker.active && !header.moving ? scrollTracker.webview : null onScrollPositionChanged: { if (scrollTracker.webview.scrollPosition.y === internal.previousScrollPositionY) { From 4bc1782234de5a29f90d82c5f65d7698fe3896d2 Mon Sep 17 00:00:00 2001 From: Chris Clime Date: Sun, 20 Jun 2021 20:07:50 +0200 Subject: [PATCH 5/5] move check 'header.moving' to function --- src/app/ScrollTracker.qml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/app/ScrollTracker.qml b/src/app/ScrollTracker.qml index 7479b7026..8d3d19cfe 100644 --- a/src/app/ScrollTracker.qml +++ b/src/app/ScrollTracker.qml @@ -41,9 +41,13 @@ Item { } Connections { - target: scrollTracker.active && !header.moving ? scrollTracker.webview : null + target: scrollTracker.active ? scrollTracker.webview : null onScrollPositionChanged: { + if (header.moving) { + return; + } + if (scrollTracker.webview.scrollPosition.y === internal.previousScrollPositionY) { return; }