mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 18:41:10 +02:00
Fix browser history in goto "i" pages on tablet
This commit is contained in:
parent
88dc6b5f61
commit
1b26ba22cb
1 changed files with 22 additions and 59 deletions
|
@ -23,16 +23,14 @@ Item {
|
||||||
property bool keyboardRaised: false
|
property bool keyboardRaised: false
|
||||||
property bool punctuationMode: false
|
property bool punctuationMode: false
|
||||||
property bool isDesktop: false
|
property bool isDesktop: false
|
||||||
property string initialPage: ""
|
|
||||||
property bool startingUp: true
|
|
||||||
property alias webView: webview
|
property alias webView: webview
|
||||||
property alias profile: webview.profile
|
property alias profile: webview.profile
|
||||||
property bool remove: false
|
property bool remove: false
|
||||||
property var urlList: []
|
|
||||||
property var forwardList: []
|
// 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 int currentPage: -1 // used as a model for repeater
|
property var history: []
|
||||||
property alias pagesModel: pagesModel
|
property int historyIndex: -1
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: buttons
|
id: buttons
|
||||||
|
@ -53,7 +51,7 @@ Item {
|
||||||
id: back
|
id: back
|
||||||
enabledColor: hifi.colors.darkGray
|
enabledColor: hifi.colors.darkGray
|
||||||
disabledColor: hifi.colors.lightGrayText
|
disabledColor: hifi.colors.lightGrayText
|
||||||
enabled: webview.canGoBack || web.urlList.length > 0 || web.forwardList.length > 0
|
enabled: historyIndex > 0
|
||||||
text: "BACK"
|
text: "BACK"
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
|
@ -76,7 +74,6 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
RalewaySemiBold {
|
RalewaySemiBold {
|
||||||
id: displayUrl
|
id: displayUrl
|
||||||
color: hifi.colors.baseGray
|
color: hifi.colors.baseGray
|
||||||
|
@ -91,7 +88,6 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
preventStealing: true
|
preventStealing: true
|
||||||
|
@ -99,24 +95,10 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ListModel {
|
|
||||||
id: pagesModel
|
|
||||||
onCountChanged: {
|
|
||||||
currentPage = count - 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function goBack() {
|
function goBack() {
|
||||||
if (webview.canGoBack) {
|
if (historyIndex > 0) {
|
||||||
forwardList.push(webview.url);
|
historyIndex--;
|
||||||
webview.goBack();
|
loadUrl(history[historyIndex]);
|
||||||
} 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 = [];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,19 +115,12 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
function goForward() {
|
function goForward() {
|
||||||
if (currentPage < pagesModel.count - 1) {
|
if (historyIndex < history.length - 1) {
|
||||||
currentPage++;
|
historyIndex++;
|
||||||
|
loadUrl(history[historyIndex]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function gotoPage(url) {
|
|
||||||
urlAppend(url)
|
|
||||||
}
|
|
||||||
|
|
||||||
function isUrlLoaded(url) {
|
|
||||||
return (pagesModel.get(currentPage).webUrl === url);
|
|
||||||
}
|
|
||||||
|
|
||||||
function reloadPage() {
|
function reloadPage() {
|
||||||
view.reloadAndBypassCache()
|
view.reloadAndBypassCache()
|
||||||
view.setActiveFocusOnPress(true);
|
view.setActiveFocusOnPress(true);
|
||||||
|
@ -157,24 +132,8 @@ Item {
|
||||||
web.url = webview.url;
|
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: {
|
onUrlChanged: {
|
||||||
loadUrl(url);
|
loadUrl(url);
|
||||||
if (startingUp) {
|
|
||||||
web.initialPage = webview.url;
|
|
||||||
startingUp = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QtObject {
|
QtObject {
|
||||||
|
@ -242,6 +201,16 @@ Item {
|
||||||
grantFeaturePermission(securityOrigin, feature, true);
|
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: {
|
onLoadingChanged: {
|
||||||
keyboardRaised = false;
|
keyboardRaised = false;
|
||||||
punctuationMode = false;
|
punctuationMode = false;
|
||||||
|
@ -261,17 +230,11 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WebEngineView.LoadSucceededStatus == loadRequest.status) {
|
if (WebEngineView.LoadSucceededStatus == loadRequest.status) {
|
||||||
if (startingUp) {
|
|
||||||
web.initialPage = webview.url;
|
|
||||||
startingUp = false;
|
|
||||||
}
|
|
||||||
webview.forceActiveFocus();
|
webview.forceActiveFocus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onNewViewRequested: {
|
onNewViewRequested: {
|
||||||
var currentUrl = webview.url;
|
|
||||||
urlAppend(currentUrl);
|
|
||||||
request.openIn(webview);
|
request.openIn(webview);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue