From 88dc6b5f61b7fb679611bda87ff682dbd57847de Mon Sep 17 00:00:00 2001 From: David Rowe Date: Fri, 5 May 2017 17:24:36 +1200 Subject: [PATCH 1/3] Fix tablet Web view "back" button not greying out when disabled --- .../qml/controls/TabletWebButton.qml | 8 +++--- .../resources/qml/controls/TabletWebView.qml | 28 ++++--------------- 2 files changed, 10 insertions(+), 26 deletions(-) diff --git a/interface/resources/qml/controls/TabletWebButton.qml b/interface/resources/qml/controls/TabletWebButton.qml index a5876d08dd..d016f71f2d 100644 --- a/interface/resources/qml/controls/TabletWebButton.qml +++ b/interface/resources/qml/controls/TabletWebButton.qml @@ -17,26 +17,26 @@ Rectangle { property alias pixelSize: label.font.pixelSize; property bool selected: false property bool hovered: false - property bool enabled: false property int spacing: 2 property var action: function () {} property string enabledColor: hifi.colors.blueHighlight property string disabledColor: hifi.colors.blueHighlight - property string highlightColor: hifi.colors.blueHighlight; width: label.width + 64 height: 32 color: hifi.colors.white + enabled: false + HifiConstants { id: hifi } + RalewaySemiBold { id: label; - color: enabledColor + color: enabled ? enabledColor : disabledColor font.pixelSize: 15; anchors { horizontalCenter: parent.horizontalCenter; verticalCenter: parent.verticalCenter; } } - Rectangle { id: indicator diff --git a/interface/resources/qml/controls/TabletWebView.qml b/interface/resources/qml/controls/TabletWebView.qml index d288872289..3a6643964b 100644 --- a/interface/resources/qml/controls/TabletWebView.qml +++ b/interface/resources/qml/controls/TabletWebView.qml @@ -8,6 +8,7 @@ import "../styles" as HifiStyles import "../styles-uit" import "../" import "." + Item { id: web HifiConstants { id: hifi } @@ -29,7 +30,6 @@ Item { property bool remove: false property var urlList: [] property var forwardList: [] - property int currentPage: -1 // used as a model for repeater property alias pagesModel: pagesModel @@ -51,21 +51,22 @@ Item { TabletWebButton { id: back - enabledColor: hifi.colors.baseGray - enabled: false + enabledColor: hifi.colors.darkGray + disabledColor: hifi.colors.lightGrayText + enabled: webview.canGoBack || web.urlList.length > 0 || web.forwardList.length > 0 text: "BACK" MouseArea { anchors.fill: parent onClicked: goBack() - hoverEnabled: true - } } TabletWebButton { id: close enabledColor: hifi.colors.darkGray + disabledColor: hifi.colors.lightGrayText + enabled: true text: "CLOSE" MouseArea { @@ -102,11 +103,6 @@ Item { id: pagesModel onCountChanged: { currentPage = count - 1; - if (currentPage > 0) { - back.enabledColor = hifi.colors.darkGray; - } else { - back.enabledColor = hifi.colors.baseGray; - } } } @@ -165,24 +161,12 @@ Item { return (url === webview.url); } - function urlAppend(url) { var lurl = decodeURIComponent(url) if (lurl[lurl.length - 1] !== "/") { lurl = lurl + "/" } web.urlList.push(url); - setBackButtonStatus(); - } - - function setBackButtonStatus() { - if (web.urlList.length > 0 || webview.canGoBack) { - back.enabledColor = hifi.colors.darkGray; - back.enabled = true; - } else { - back.enabledColor = hifi.colors.baseGray; - back.enabled = false; - } } onUrlChanged: { From 1b26ba22cbc323f1f46aebf09608981fad9dac96 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sat, 6 May 2017 11:13:13 +1200 Subject: [PATCH 2/3] Fix browser history in goto "i" pages on tablet --- .../resources/qml/controls/TabletWebView.qml | 81 +++++-------------- 1 file changed, 22 insertions(+), 59 deletions(-) diff --git a/interface/resources/qml/controls/TabletWebView.qml b/interface/resources/qml/controls/TabletWebView.qml index 3a6643964b..a718c59659 100644 --- a/interface/resources/qml/controls/TabletWebView.qml +++ b/interface/resources/qml/controls/TabletWebView.qml @@ -23,16 +23,14 @@ Item { property bool keyboardRaised: false property bool punctuationMode: false property bool isDesktop: false - property string initialPage: "" - property bool startingUp: true property alias webView: webview property alias profile: webview.profile property bool remove: false - property var urlList: [] - property var forwardList: [] - - property int currentPage: -1 // used as a model for repeater - property alias pagesModel: pagesModel + + // Manage own browse history because WebEngineView history is wiped when a new URL is loaded via + // onNewViewRequested, e.g., as happens when a social media share button is clicked. + property var history: [] + property int historyIndex: -1 Rectangle { id: buttons @@ -53,7 +51,7 @@ Item { id: back enabledColor: hifi.colors.darkGray disabledColor: hifi.colors.lightGrayText - enabled: webview.canGoBack || web.urlList.length > 0 || web.forwardList.length > 0 + enabled: historyIndex > 0 text: "BACK" MouseArea { @@ -76,7 +74,6 @@ Item { } } - RalewaySemiBold { id: displayUrl color: hifi.colors.baseGray @@ -91,7 +88,6 @@ Item { } } - MouseArea { anchors.fill: parent preventStealing: true @@ -99,24 +95,10 @@ Item { } } - ListModel { - id: pagesModel - onCountChanged: { - currentPage = count - 1; - } - } - function goBack() { - if (webview.canGoBack) { - forwardList.push(webview.url); - webview.goBack(); - } else if (web.urlList.length > 0) { - var url = web.urlList.pop(); - loadUrl(url); - } else if (web.forwardList.length > 0) { - var url = web.forwardList.pop(); - loadUrl(url); - web.forwardList = []; + if (historyIndex > 0) { + historyIndex--; + loadUrl(history[historyIndex]); } } @@ -133,19 +115,12 @@ Item { } function goForward() { - if (currentPage < pagesModel.count - 1) { - currentPage++; + if (historyIndex < history.length - 1) { + historyIndex++; + loadUrl(history[historyIndex]); } } - function gotoPage(url) { - urlAppend(url) - } - - function isUrlLoaded(url) { - return (pagesModel.get(currentPage).webUrl === url); - } - function reloadPage() { view.reloadAndBypassCache() view.setActiveFocusOnPress(true); @@ -157,24 +132,8 @@ Item { web.url = webview.url; } - function onInitialPage(url) { - return (url === webview.url); - } - - function urlAppend(url) { - var lurl = decodeURIComponent(url) - if (lurl[lurl.length - 1] !== "/") { - lurl = lurl + "/" - } - web.urlList.push(url); - } - onUrlChanged: { loadUrl(url); - if (startingUp) { - web.initialPage = webview.url; - startingUp = false; - } } QtObject { @@ -242,6 +201,16 @@ Item { grantFeaturePermission(securityOrigin, feature, true); } + onUrlChanged: { + // Record history, skipping null and duplicate items. + var urlString = url + ""; + if (urlString.length > 0 && (historyIndex === -1 || urlString !== history[historyIndex])) { + historyIndex++; + history = history.slice(0, historyIndex); + history.push(urlString); + } + } + onLoadingChanged: { keyboardRaised = false; punctuationMode = false; @@ -261,17 +230,11 @@ Item { } if (WebEngineView.LoadSucceededStatus == loadRequest.status) { - if (startingUp) { - web.initialPage = webview.url; - startingUp = false; - } webview.forceActiveFocus(); } } onNewViewRequested: { - var currentUrl = webview.url; - urlAppend(currentUrl); request.openIn(webview); } } From 116175cf9fe422d8d525dc5ba9fa391f369dc75e Mon Sep 17 00:00:00 2001 From: David Rowe Date: Tue, 9 May 2017 09:03:48 +1200 Subject: [PATCH 3/3] Fix going back from Twitter password recovery page --- interface/resources/qml/controls/TabletWebView.qml | 1 + 1 file changed, 1 insertion(+) diff --git a/interface/resources/qml/controls/TabletWebView.qml b/interface/resources/qml/controls/TabletWebView.qml index a718c59659..d939e088a8 100644 --- a/interface/resources/qml/controls/TabletWebView.qml +++ b/interface/resources/qml/controls/TabletWebView.qml @@ -204,6 +204,7 @@ Item { onUrlChanged: { // Record history, skipping null and duplicate items. var urlString = url + ""; + urlString = urlString.replace(/\//g, "%2F"); // Consistent representation of "/"s to avoid false differences. if (urlString.length > 0 && (historyIndex === -1 || urlString !== history[historyIndex])) { historyIndex++; history = history.slice(0, historyIndex);