From a8bb320ef213d60e02cb88f72b6ecec4461000a2 Mon Sep 17 00:00:00 2001 From: dano6 Date: Thu, 17 Sep 2020 13:21:17 +0200 Subject: [PATCH 01/10] Show previews when running with hidpi, but scaled down --- src/app/webbrowser/TabPreview.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/webbrowser/TabPreview.qml b/src/app/webbrowser/TabPreview.qml index 9c9191fc0..40222cef9 100644 --- a/src/app/webbrowser/TabPreview.qml +++ b/src/app/webbrowser/TabPreview.qml @@ -107,10 +107,10 @@ Item { anchors { left: parent.left top: parent.top + right: parent.right topMargin: -chrome.height } - height: sourceSize.height - fillMode: Image.Pad + fillMode: Image.PreserveAspectFit source: tabPreview.tab ? tabPreview.tab.preview : "" asynchronous: true cache: false From 6f28527a1289917dcb0da5fa2921adcc3f41fee5 Mon Sep 17 00:00:00 2001 From: Chris Clime Date: Mon, 13 Jul 2020 08:13:29 +0200 Subject: [PATCH 02/10] 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 9815bb4c5..1ed5cf379 100644 --- a/src/app/webbrowser/Browser.qml +++ b/src/app/webbrowser/Browser.qml @@ -553,9 +553,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 b0049e41c7125a8a8af85dd7b1a3b8978b41eb1e Mon Sep 17 00:00:00 2001 From: dano6 Date: Tue, 22 Sep 2020 18:56:14 +0200 Subject: [PATCH 03/10] Implement swipe to close tab and improve tab previews --- src/app/webbrowser/Browser.qml | 6 +- src/app/webbrowser/BrowserTab.qml | 19 ++-- src/app/webbrowser/TabPreview.qml | 169 ++++++++++++++---------------- src/app/webbrowser/TabsList.qml | 14 +-- 4 files changed, 101 insertions(+), 107 deletions(-) diff --git a/src/app/webbrowser/Browser.qml b/src/app/webbrowser/Browser.qml index 1ed5cf379..c083e8c63 100644 --- a/src/app/webbrowser/Browser.qml +++ b/src/app/webbrowser/Browser.qml @@ -556,9 +556,13 @@ Common.BrowserView { if (visible) { currentWebview.hideContextMenu(); chrome.state = "hidden"; + currentWebview.visible = false; + newTabViewLoader.visible = false; } else { chrome.state = "shown"; + currentWebview.visible = true; + newTabViewLoader.visible = true; } } @@ -846,7 +850,7 @@ Common.BrowserView { Connections { target: browser.currentWebview onLoadingChanged: { - if (browser.currentWebview.loading) { + if (browser.currentWebview.loading && !recentView.visible) { chrome.state = "shown" } else if (browser.currentWebview.isFullScreen) { chrome.state = "hidden" diff --git a/src/app/webbrowser/BrowserTab.qml b/src/app/webbrowser/BrowserTab.qml index 2c3f20155..80abc6400 100644 --- a/src/app/webbrowser/BrowserTab.qml +++ b/src/app/webbrowser/BrowserTab.qml @@ -197,7 +197,7 @@ FocusScope { visible = false PreviewManager.saveToDisk(result, url) - }) + },Qt.size(webview.width*Screen.devicePixelRatio,webview.height*Screen.devicePixelRatio)); } } @@ -208,21 +208,24 @@ FocusScope { id: delayedCapture interval: 500 onTriggered: { + if (recentView.visible) + return if (webview && current && visible && !internal.hiding) { webview.grabToImage(function(result) { PreviewManager.saveToDisk(result, url) - }) + },Qt.size(webview.width*Screen.devicePixelRatio,webview.height*Screen.devicePixelRatio)) } } } Connections { target: incognito ? null : webview -// onLoadEvent: { -// if ((event.type == Oxide.LoadEvent.TypeSucceeded) || -// (event.type == Oxide.LoadEvent.TypeFailed)) { -// delayedCapture.restart() -// } -// } + onLoadingChanged: { + if (!webview.loading) + delayedCapture.restart() + } + //onScrollPositionChanged: { + // delayedCapture.restart() + //} } onAboutToShow: { diff --git a/src/app/webbrowser/TabPreview.qml b/src/app/webbrowser/TabPreview.qml index 40222cef9..184fcded0 100644 --- a/src/app/webbrowser/TabPreview.qml +++ b/src/app/webbrowser/TabPreview.qml @@ -18,8 +18,9 @@ import QtQuick 2.4 import Ubuntu.Components 1.3 +import QtQuick.Controls 2.2 as QQC2 -Item { +QQC2.SwipeDelegate { id: tabPreview property alias title: chrome.title @@ -28,6 +29,21 @@ Item { property var tab readonly property url url: tab ? tab.url : "" + background: Rectangle { + anchors.fill: parent + color: "transparent" + } + padding: 0 + swipe.enabled: true + swipe.behind: Rectangle { + width: tabPreview.width + height: tabPreview.height + color: "transparent" + } + + swipe.onCompleted: closed() + onClicked: tabPreview.selected() + // The first preview in the tabs list is a special case. // Since it’s the current tab, instead of displaying a // capture, the webview below it is displayed. @@ -36,113 +52,90 @@ Item { signal selected() signal closed() - TabChrome { - id: chrome + contentItem: Item { - anchors { - top: parent.top - left: parent.left - right: parent.right - } - tabWidth: units.gu(26) - - onSelected: tabPreview.selected() - onClosed: tabPreview.closed() - } + TabChrome { + id: chrome - Item { - anchors { - top: chrome.bottom - topMargin: units.dp(-1) - left: parent.left - right: parent.right - } - height: parent.height - clip: true - - Rectangle { - anchors.fill: parent - color: theme.palette.normal.foreground - visible: showContent - } - - Image { - visible: showContent && !previewContainer.visible - source: "assets/tab-artwork.png" - asynchronous: true - fillMode: Image.PreserveAspectFit - width: parent.width / 5 - height: width anchors { + top: parent.top + left: parent.left right: parent.right - rightMargin: -width / 5 - bottom: parent.bottom - bottomMargin: -height / 10 } + tabWidth: units.gu(26) + + onSelected: tabPreview.selected() + onClosed: tabPreview.closed() } - Rectangle { + Item { anchors { - top: parent.top + top: chrome.bottom + topMargin: units.dp(-1) left: parent.left right: parent.right } - height: units.dp(1) + height: parent.height + clip: true - color: theme.palette.normal.base - } - - Label { - visible: showContent && !previewContainer.visible - text: i18n.tr("Tap to view") - anchors { - centerIn: parent - verticalCenterOffset: units.gu(-2) + Rectangle { + anchors.fill: parent + color: theme.palette.normal.foreground + visible: showContent } - } - Image { - id: previewContainer - visible: showContent && source.toString() && (status == Image.Ready) - anchors { - left: parent.left - top: parent.top - right: parent.right - topMargin: -chrome.height + Image { + visible: showContent && !previewContainer.visible + source: "assets/tab-artwork.png" + asynchronous: true + fillMode: Image.PreserveAspectFit + width: parent.width / 5 + height: width + anchors { + right: parent.right + rightMargin: -width / 5 + bottom: parent.bottom + bottomMargin: -height / 10 + } } - fillMode: Image.PreserveAspectFit - source: tabPreview.tab ? tabPreview.tab.preview : "" - asynchronous: true - cache: false - onStatusChanged: { - if (status == Image.Error) { - // The cached preview doesn’t exist any longer - tabPreview.tab.preview = "" + + Rectangle { + anchors { + top: parent.top + left: parent.left + right: parent.right } + height: units.dp(1) + + color: theme.palette.normal.base } - } - MouseArea { - objectName: "selectArea" - anchors.fill: parent - acceptedButtons: Qt.AllButtons - - // 'clicked' events are emitted even if the cursor has been dragged - // (http://doc.qt.io/qt-5/qml-qtquick-mousearea.html#clicked-signal), - // but we don’t want a drag gesture to select the tab (when e.g. the - // user has reached the top/bottom of the tabs view and starts another - // gesture to drag further beyond the boundaries of the view). - property point pos - onPressed: { - if (mouse.button == Qt.LeftButton) { - pos = Qt.point(mouse.x, mouse.y) + Label { + visible: showContent && !previewContainer.visible + text: i18n.tr("Tap to view") + anchors { + centerIn: parent + verticalCenterOffset: units.gu(-2) } } - onReleased: { - if (mouse.button == Qt.LeftButton) { - var d = Math.sqrt(Math.pow(mouse.x - pos.x, 2) + Math.pow(mouse.y - pos.y, 2)) - if (d < units.gu(1)) { - tabPreview.selected() + + Image { + id: previewContainer + visible: showContent && source.toString() && (status == Image.Ready) + anchors { + left: parent.left + top: parent.top + topMargin: units.dp(1) + right: parent.right + } + fillMode: Image.PreserveAspectFit + source: tabPreview.tab ? tabPreview.tab.preview : "" + asynchronous: true + cache: false + onStatusChanged: { + if (status == Image.Error) { + // The cached preview doesn’t exist any longer + tabPreview.tab.preview = "" } } } diff --git a/src/app/webbrowser/TabsList.qml b/src/app/webbrowser/TabsList.qml index b33541e08..09840c325 100644 --- a/src/app/webbrowser/TabsList.qml +++ b/src/app/webbrowser/TabsList.qml @@ -44,13 +44,8 @@ Item { } Rectangle { - anchors { - top: parent.top - left: parent.left - right: parent.right - } - height: invisibleTabChrome.height - color: theme.palette.normal.backgroundText + anchors.fill: parent + color: theme.palette.normal.base } Flickable { @@ -74,7 +69,7 @@ Item { width: flickable.contentWidth - height: (index == (repeater.model.count - 1)) ? flickable.height : delegateHeight + height: (index == (repeater.model.count - 1)) || index == 0 ? flickable.height : delegateHeight Behavior on height { UbuntuNumberAnimation { duration: UbuntuAnimation.BriskDuration @@ -108,8 +103,7 @@ Item { icon: delegate.icon incognito: tabslist.incognito tab: model.tab - showContent: ((index > 0) && (delegate.y > flickable.contentY)) || - !(tab && tab.webview && tab.webview.visible) + showContent: true /* Binding { // Change the height of the location bar controller From ead1f4d8ce4b1819f31e427003a47d985afba1e1 Mon Sep 17 00:00:00 2001 From: dano6 Date: Sat, 3 Oct 2020 19:20:30 +0200 Subject: [PATCH 04/10] Improve tab switching animations --- src/app/webbrowser/Browser.qml | 7 ++++++- src/app/webbrowser/BrowserTab.qml | 9 ++++++--- src/app/webbrowser/TabsList.qml | 5 +++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/app/webbrowser/Browser.qml b/src/app/webbrowser/Browser.qml index c083e8c63..1117396aa 100644 --- a/src/app/webbrowser/Browser.qml +++ b/src/app/webbrowser/Browser.qml @@ -40,6 +40,11 @@ Common.BrowserView { currentWebview: tabsModel && tabsModel.currentTab ? tabsModel.currentTab.webview : null + TabChrome { + id: invisibleTabChrome + visible: false + } + property bool incognito: false property var tabsModel: TabsModel { @@ -692,8 +697,8 @@ Common.BrowserView { property bool hidden: false Behavior on y { - enabled: recentView.visible NumberAnimation { + from: -chrome.height + invisibleTabChrome.height duration: UbuntuAnimation.FastDuration } } diff --git a/src/app/webbrowser/BrowserTab.qml b/src/app/webbrowser/BrowserTab.qml index 80abc6400..6ba977e39 100644 --- a/src/app/webbrowser/BrowserTab.qml +++ b/src/app/webbrowser/BrowserTab.qml @@ -223,9 +223,12 @@ FocusScope { if (!webview.loading) delayedCapture.restart() } - //onScrollPositionChanged: { - // delayedCapture.restart() - //} + onScrollPositionChanged: { + delayedCapture.restart() + } + onWidthChanged: { + delayedCapture.restart() + } } onAboutToShow: { diff --git a/src/app/webbrowser/TabsList.qml b/src/app/webbrowser/TabsList.qml index 09840c325..575dd3aea 100644 --- a/src/app/webbrowser/TabsList.qml +++ b/src/app/webbrowser/TabsList.qml @@ -69,7 +69,8 @@ Item { width: flickable.contentWidth - height: (index == (repeater.model.count - 1)) || index == 0 ? flickable.height : delegateHeight + height: (index == (repeater.model.count - 1)) || index == 0 || (animating && index == selectedAnimation.index) + ? flickable.height : delegateHeight Behavior on height { UbuntuNumberAnimation { duration: UbuntuAnimation.BriskDuration @@ -126,7 +127,7 @@ Item { property int index: 0 target: flickable property: "contentY" - to: index * delegateHeight - chromeHeight + invisibleTabChrome.height + to: index * delegateHeight duration: UbuntuAnimation.FastDuration onStopped: { // Delay switching the tab until after the animation has completed. From 0dde4a57c0ef50424f44567aabababdd604f0914 Mon Sep 17 00:00:00 2001 From: dano6 Date: Wed, 21 Oct 2020 17:59:22 +0200 Subject: [PATCH 05/10] Change curent page snapshoting strategy --- src/app/webbrowser/Browser.qml | 5 +---- src/app/webbrowser/BrowserTab.qml | 30 ++++++------------------------ 2 files changed, 7 insertions(+), 28 deletions(-) diff --git a/src/app/webbrowser/Browser.qml b/src/app/webbrowser/Browser.qml index 1117396aa..b2a49ef77 100644 --- a/src/app/webbrowser/Browser.qml +++ b/src/app/webbrowser/Browser.qml @@ -559,15 +559,12 @@ Common.BrowserView { visible: bottomEdgeHandle.dragging || tabslist.animating || (state == "shown") onVisibleChanged: { if (visible) { + currentWebview.hideContextMenu(); chrome.state = "hidden"; - currentWebview.visible = false; - newTabViewLoader.visible = false; } else { chrome.state = "shown"; - currentWebview.visible = true; - newTabViewLoader.visible = true; } } diff --git a/src/app/webbrowser/BrowserTab.qml b/src/app/webbrowser/BrowserTab.qml index 6ba977e39..592ac334d 100644 --- a/src/app/webbrowser/BrowserTab.qml +++ b/src/app/webbrowser/BrowserTab.qml @@ -201,35 +201,17 @@ FocusScope { } } - // Take a capture of the current page shortly after it has finished - // loading to give rendering an opportunity to complete. There is - // unfortunately no signal to notify us when rendering has completed. - Timer { - id: delayedCapture - interval: 500 - onTriggered: { - if (recentView.visible) - return - if (webview && current && visible && !internal.hiding) { + Connections { + target: recentView + onVisibleChanged: { + if(visible && current && !empty && !webview.incognito) { + preview = "" webview.grabToImage(function(result) { PreviewManager.saveToDisk(result, url) - },Qt.size(webview.width*Screen.devicePixelRatio,webview.height*Screen.devicePixelRatio)) + },Qt.size(webview.width*Screen.devicePixelRatio,webview.height*Screen.devicePixelRatio)); } } } - Connections { - target: incognito ? null : webview - onLoadingChanged: { - if (!webview.loading) - delayedCapture.restart() - } - onScrollPositionChanged: { - delayedCapture.restart() - } - onWidthChanged: { - delayedCapture.restart() - } - } onAboutToShow: { if (!current) { From e54b7e14e9926108090f0a10e43da3b752b48437 Mon Sep 17 00:00:00 2001 From: dano6 Date: Sun, 25 Oct 2020 00:21:04 +0200 Subject: [PATCH 06/10] Improve animations --- src/app/webbrowser/BrowserTab.qml | 7 +++++-- src/app/webbrowser/TabPreview.qml | 23 +++++++++++++++++------ src/app/webbrowser/TabsList.qml | 13 ++++++++++++- 3 files changed, 34 insertions(+), 9 deletions(-) diff --git a/src/app/webbrowser/BrowserTab.qml b/src/app/webbrowser/BrowserTab.qml index 592ac334d..b0156980c 100644 --- a/src/app/webbrowser/BrowserTab.qml +++ b/src/app/webbrowser/BrowserTab.qml @@ -44,6 +44,7 @@ FocusScope { readonly property real lastCurrent: internal.lastCurrent property bool incognito readonly property bool empty: !url.toString() && !initialUrl.toString() && !restoreState && !request + property bool loadingPreview: false visible: false // Used as a workaround for https://launchpad.net/bugs/1502675 : @@ -197,7 +198,7 @@ FocusScope { visible = false PreviewManager.saveToDisk(result, url) - },Qt.size(webview.width*Screen.devicePixelRatio,webview.height*Screen.devicePixelRatio)); + },Qt.size(webview.width*Math.max(Screen.devicePixelRatio/2,1),webview.height*Math.max(Screen.devicePixelRatio/2,1))); } } @@ -206,9 +207,11 @@ FocusScope { onVisibleChanged: { if(visible && current && !empty && !webview.incognito) { preview = "" + loadingPreview = true webview.grabToImage(function(result) { PreviewManager.saveToDisk(result, url) - },Qt.size(webview.width*Screen.devicePixelRatio,webview.height*Screen.devicePixelRatio)); + },Qt.size(webview.width*Math.max(Screen.devicePixelRatio/2,1),webview.height*Math.max(Screen.devicePixelRatio/2,1))); + loadingPreview = false } } } diff --git a/src/app/webbrowser/TabPreview.qml b/src/app/webbrowser/TabPreview.qml index 184fcded0..c6d22ed37 100644 --- a/src/app/webbrowser/TabPreview.qml +++ b/src/app/webbrowser/TabPreview.qml @@ -75,6 +75,23 @@ QQC2.SwipeDelegate { left: parent.left right: parent.right } + onVisibleChanged: { + if (visible && tab.current) + tabShowing.start() + } + + PropertyAnimation { + id: tabShowing + target: parent + property: "opacity" + from: 0 + to: 1 + duration: UbuntuAnimation.FastDuration + } + + + + visible: !tab.loadingPreview height: parent.height clip: true @@ -132,12 +149,6 @@ QQC2.SwipeDelegate { source: tabPreview.tab ? tabPreview.tab.preview : "" asynchronous: true cache: false - onStatusChanged: { - if (status == Image.Error) { - // The cached preview doesn’t exist any longer - tabPreview.tab.preview = "" - } - } } } } diff --git a/src/app/webbrowser/TabsList.qml b/src/app/webbrowser/TabsList.qml index 575dd3aea..fcc6a3059 100644 --- a/src/app/webbrowser/TabsList.qml +++ b/src/app/webbrowser/TabsList.qml @@ -44,9 +44,20 @@ Item { } Rectangle { - anchors.fill: parent + id: backrect + width: parent.width + height: dealayBackground.running ? invisibleTabChrome.height : parent.height color: theme.palette.normal.base } + onVisibleChanged: { + if (visible) + dealayBackground.start() + } + + Timer { + id: dealayBackground + interval: 300 + } Flickable { id: flickable From d0565cbc73b0c6248494e5623c2c2be62f17af95 Mon Sep 17 00:00:00 2001 From: dano6 Date: Thu, 29 Oct 2020 09:45:50 +0100 Subject: [PATCH 07/10] Polish code a bit --- src/app/webbrowser/BrowserTab.qml | 6 ++++-- src/app/webbrowser/TabPreview.qml | 12 +++--------- src/app/webbrowser/TabsList.qml | 1 - 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/app/webbrowser/BrowserTab.qml b/src/app/webbrowser/BrowserTab.qml index b0156980c..c9e3ba426 100644 --- a/src/app/webbrowser/BrowserTab.qml +++ b/src/app/webbrowser/BrowserTab.qml @@ -45,6 +45,8 @@ FocusScope { property bool incognito readonly property bool empty: !url.toString() && !initialUrl.toString() && !restoreState && !request property bool loadingPreview: false + readonly property size previewSize: Qt.size(webview.width*Math.max(Screen.devicePixelRatio/2,1), + webview.height*Math.max(Screen.devicePixelRatio/2,1)) visible: false // Used as a workaround for https://launchpad.net/bugs/1502675 : @@ -198,7 +200,7 @@ FocusScope { visible = false PreviewManager.saveToDisk(result, url) - },Qt.size(webview.width*Math.max(Screen.devicePixelRatio/2,1),webview.height*Math.max(Screen.devicePixelRatio/2,1))); + },previewSize); } } @@ -210,7 +212,7 @@ FocusScope { loadingPreview = true webview.grabToImage(function(result) { PreviewManager.saveToDisk(result, url) - },Qt.size(webview.width*Math.max(Screen.devicePixelRatio/2,1),webview.height*Math.max(Screen.devicePixelRatio/2,1))); + },previewSize); loadingPreview = false } } diff --git a/src/app/webbrowser/TabPreview.qml b/src/app/webbrowser/TabPreview.qml index c6d22ed37..88bca91e3 100644 --- a/src/app/webbrowser/TabPreview.qml +++ b/src/app/webbrowser/TabPreview.qml @@ -44,11 +44,6 @@ QQC2.SwipeDelegate { swipe.onCompleted: closed() onClicked: tabPreview.selected() - // The first preview in the tabs list is a special case. - // Since it’s the current tab, instead of displaying a - // capture, the webview below it is displayed. - property bool showContent: true - signal selected() signal closed() @@ -98,11 +93,10 @@ QQC2.SwipeDelegate { Rectangle { anchors.fill: parent color: theme.palette.normal.foreground - visible: showContent } Image { - visible: showContent && !previewContainer.visible + visible: !previewContainer.visible source: "assets/tab-artwork.png" asynchronous: true fillMode: Image.PreserveAspectFit @@ -128,7 +122,7 @@ QQC2.SwipeDelegate { } Label { - visible: showContent && !previewContainer.visible + visible: !previewContainer.visible text: i18n.tr("Tap to view") anchors { centerIn: parent @@ -138,7 +132,7 @@ QQC2.SwipeDelegate { Image { id: previewContainer - visible: showContent && source.toString() && (status == Image.Ready) + visible: source.toString() && (status == Image.Ready) anchors { left: parent.left top: parent.top diff --git a/src/app/webbrowser/TabsList.qml b/src/app/webbrowser/TabsList.qml index fcc6a3059..14f4c5ba5 100644 --- a/src/app/webbrowser/TabsList.qml +++ b/src/app/webbrowser/TabsList.qml @@ -115,7 +115,6 @@ Item { icon: delegate.icon incognito: tabslist.incognito tab: model.tab - showContent: true /* Binding { // Change the height of the location bar controller From 59f0fd7075b05bfcc2849a7e9c0f3f5bed267561 Mon Sep 17 00:00:00 2001 From: dano6 Date: Mon, 2 Nov 2020 14:12:53 +0100 Subject: [PATCH 08/10] Do not save large previews to disk to increase performance --- src/app/webbrowser/BrowserTab.qml | 41 ++++++++++++++----------------- src/app/webbrowser/TabPreview.qml | 18 ++++---------- 2 files changed, 24 insertions(+), 35 deletions(-) diff --git a/src/app/webbrowser/BrowserTab.qml b/src/app/webbrowser/BrowserTab.qml index c9e3ba426..8d87c7967 100644 --- a/src/app/webbrowser/BrowserTab.qml +++ b/src/app/webbrowser/BrowserTab.qml @@ -45,27 +45,18 @@ FocusScope { property bool incognito readonly property bool empty: !url.toString() && !initialUrl.toString() && !restoreState && !request property bool loadingPreview: false - readonly property size previewSize: Qt.size(webview.width*Math.max(Screen.devicePixelRatio/2,1), - webview.height*Math.max(Screen.devicePixelRatio/2,1)) + readonly property size previewSize: Qt.size(webview.width*Screen.devicePixelRatio, + webview.height*Screen.devicePixelRatio) + readonly property size previewThumbnailSize: Qt.size(webview.width/2, + webview.height/2) + //store reference to preview to avoid clearing by garbage collector + property var previewCache visible: false // Used as a workaround for https://launchpad.net/bugs/1502675 : // invoke this on a tab shortly before it is set current. signal aboutToShow() - Connections { - target: PreviewManager - onPreviewSaved: { - if (pageUrl !== url) return - if (preview == previewUrl) { - // Ensure that the preview URL actually changes, - // for the image to be reloaded - preview = "" - } - preview = previewUrl - } - } - FaviconFetcher { id: faviconFetcher shouldCache: !tab.incognito @@ -193,14 +184,16 @@ FocusScope { internal.hiding = true webview.grabToImage(function(result) { - if (!internal.hiding) { - return - } - internal.hiding = false visible = false + preview = result.url + previewCache = result + },previewSize); + //save previews to disk for newtabpage and tab during grabbing + webview.grabToImage(function(result) { + internal.hiding = false PreviewManager.saveToDisk(result, url) - },previewSize); + },previewThumbnailSize); } } @@ -211,9 +204,13 @@ FocusScope { preview = "" loadingPreview = true webview.grabToImage(function(result) { - PreviewManager.saveToDisk(result, url) + preview = result.url + previewCache = result },previewSize); - loadingPreview = false + + webview.grabToImage(function(result) { + PreviewManager.saveToDisk(result, url) + },previewThumbnailSize); } } } diff --git a/src/app/webbrowser/TabPreview.qml b/src/app/webbrowser/TabPreview.qml index 88bca91e3..e713bc4ce 100644 --- a/src/app/webbrowser/TabPreview.qml +++ b/src/app/webbrowser/TabPreview.qml @@ -70,19 +70,6 @@ QQC2.SwipeDelegate { left: parent.left right: parent.right } - onVisibleChanged: { - if (visible && tab.current) - tabShowing.start() - } - - PropertyAnimation { - id: tabShowing - target: parent - property: "opacity" - from: 0 - to: 1 - duration: UbuntuAnimation.FastDuration - } @@ -143,6 +130,11 @@ QQC2.SwipeDelegate { source: tabPreview.tab ? tabPreview.tab.preview : "" asynchronous: true cache: false + onStatusChanged: { + if (status != Image.Loading) { + tab.loadingPreview = false + } + } } } } From 14a111961ea395d9e81d1f32bbccf320db8c6169 Mon Sep 17 00:00:00 2001 From: dano6 Date: Fri, 6 Nov 2020 04:27:26 +0100 Subject: [PATCH 09/10] Last previews change --- src/app/webbrowser/Browser.qml | 2 +- src/app/webbrowser/BrowserTab.qml | 4 ++-- src/app/webbrowser/TabPreview.qml | 14 ++++++-------- src/app/webbrowser/TabsList.qml | 8 +------- 4 files changed, 10 insertions(+), 18 deletions(-) diff --git a/src/app/webbrowser/Browser.qml b/src/app/webbrowser/Browser.qml index b2a49ef77..60bdf061c 100644 --- a/src/app/webbrowser/Browser.qml +++ b/src/app/webbrowser/Browser.qml @@ -93,7 +93,7 @@ Common.BrowserView { state.url = tab.url.toString() state.title = tab.title state.icon = tab.icon.toString() - state.preview = tab.preview.toString() + state.preview = Qt.resolvedUrl(PreviewManager.previewPathFromUrl(tab.url)) state.savedState = tab.webview ? tab.webview.currentState : tab.restoreState return state } diff --git a/src/app/webbrowser/BrowserTab.qml b/src/app/webbrowser/BrowserTab.qml index 8d87c7967..e101b480c 100644 --- a/src/app/webbrowser/BrowserTab.qml +++ b/src/app/webbrowser/BrowserTab.qml @@ -47,8 +47,8 @@ FocusScope { property bool loadingPreview: false readonly property size previewSize: Qt.size(webview.width*Screen.devicePixelRatio, webview.height*Screen.devicePixelRatio) - readonly property size previewThumbnailSize: Qt.size(webview.width/2, - webview.height/2) + readonly property size previewThumbnailSize: Qt.size(webview.width/1.5, + webview.height/1.5) //store reference to preview to avoid clearing by garbage collector property var previewCache visible: false diff --git a/src/app/webbrowser/TabPreview.qml b/src/app/webbrowser/TabPreview.qml index e713bc4ce..7b0bb7856 100644 --- a/src/app/webbrowser/TabPreview.qml +++ b/src/app/webbrowser/TabPreview.qml @@ -112,20 +112,18 @@ QQC2.SwipeDelegate { visible: !previewContainer.visible text: i18n.tr("Tap to view") anchors { - centerIn: parent - verticalCenterOffset: units.gu(-2) + top: parent.top + topMargin: units.gu(12) + horizontalCenter: parent.horizontalCenter } } Image { id: previewContainer visible: source.toString() && (status == Image.Ready) - anchors { - left: parent.left - top: parent.top - topMargin: units.dp(1) - right: parent.right - } + anchors.fill: parent + anchors.topMargin: units.dp(1) + verticalAlignment: Image.AlignTop fillMode: Image.PreserveAspectFit source: tabPreview.tab ? tabPreview.tab.preview : "" asynchronous: true diff --git a/src/app/webbrowser/TabsList.qml b/src/app/webbrowser/TabsList.qml index 14f4c5ba5..85dc6a2be 100644 --- a/src/app/webbrowser/TabsList.qml +++ b/src/app/webbrowser/TabsList.qml @@ -80,13 +80,7 @@ Item { width: flickable.contentWidth - height: (index == (repeater.model.count - 1)) || index == 0 || (animating && index == selectedAnimation.index) - ? flickable.height : delegateHeight - Behavior on height { - UbuntuNumberAnimation { - duration: UbuntuAnimation.BriskDuration - } - } + height: flickable.height y: Math.max(flickable.contentY, index * delegateHeight) Behavior on y { From 68940180739a34911c623f106472f27d60598ab1 Mon Sep 17 00:00:00 2001 From: dano6 Date: Tue, 24 Nov 2020 10:45:32 +0100 Subject: [PATCH 10/10] Fix some warnings --- src/app/webbrowser/BrowserTab.qml | 8 ++++---- src/app/webbrowser/TabPreview.qml | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/app/webbrowser/BrowserTab.qml b/src/app/webbrowser/BrowserTab.qml index e101b480c..1aea6afea 100644 --- a/src/app/webbrowser/BrowserTab.qml +++ b/src/app/webbrowser/BrowserTab.qml @@ -45,10 +45,10 @@ FocusScope { property bool incognito readonly property bool empty: !url.toString() && !initialUrl.toString() && !restoreState && !request property bool loadingPreview: false - readonly property size previewSize: Qt.size(webview.width*Screen.devicePixelRatio, - webview.height*Screen.devicePixelRatio) - readonly property size previewThumbnailSize: Qt.size(webview.width/1.5, - webview.height/1.5) + readonly property size previewSize: webview ? Qt.size(webview.width*Screen.devicePixelRatio, + webview.height*Screen.devicePixelRatio) : Qt.size(0,0) + readonly property size previewThumbnailSize: webview ? Qt.size(webview.width/1.5, + webview.height/1.5) : Qt.size(0,0) //store reference to preview to avoid clearing by garbage collector property var previewCache visible: false diff --git a/src/app/webbrowser/TabPreview.qml b/src/app/webbrowser/TabPreview.qml index 7b0bb7856..c5b2e6af6 100644 --- a/src/app/webbrowser/TabPreview.qml +++ b/src/app/webbrowser/TabPreview.qml @@ -30,7 +30,6 @@ QQC2.SwipeDelegate { readonly property url url: tab ? tab.url : "" background: Rectangle { - anchors.fill: parent color: "transparent" } padding: 0