mirror of
https://github.com/overte-org/overte.git
synced 2025-07-23 23:04:03 +02:00
working on cleaner navigation
This commit is contained in:
parent
9f33af479d
commit
c205bf0980
1 changed files with 40 additions and 65 deletions
|
@ -23,6 +23,7 @@ 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 bool startingUp: true
|
||||||
property bool removingPage: false
|
property bool removingPage: false
|
||||||
property alias webView: webview
|
property alias webView: webview
|
||||||
|
@ -32,6 +33,7 @@ Item {
|
||||||
property bool loadingStarted: false
|
property bool loadingStarted: false
|
||||||
property bool loadingFinished: false
|
property bool loadingFinished: false
|
||||||
property var urlList: []
|
property var urlList: []
|
||||||
|
property var forwardList: []
|
||||||
|
|
||||||
|
|
||||||
property int currentPage: -1 // used as a model for repeater
|
property int currentPage: -1 // used as a model for repeater
|
||||||
|
@ -103,15 +105,15 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
function goBack() {
|
function goBack() {
|
||||||
if (webview.canGoBack && !isUrlLoaded(webview.url)) {
|
if (webview.canGoBack) {
|
||||||
if (currentPage > 0) {
|
forwardList.push(webview.url);
|
||||||
removingPage = true;
|
|
||||||
pagesModel.remove(currentPage);
|
|
||||||
}
|
|
||||||
webview.goBack();
|
webview.goBack();
|
||||||
} else if (currentPage > 0) {
|
} else if (web.urlList.length > 0) {
|
||||||
removingPage = true;
|
removingPage = true;
|
||||||
pagesModel.remove(currentPage);
|
var url = web.urlList.pop();
|
||||||
|
loadUrl(url);
|
||||||
|
} else if (fowardList.length == 1) {
|
||||||
|
console.log("--------------> going foward <---------------");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,52 +150,42 @@ Item {
|
||||||
view.setEnabled(true);
|
view.setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function shouldLoadUrl(url) {
|
function loadUrl(url) {
|
||||||
switch (url) {
|
webview.url = url
|
||||||
case "https://twitter.com/intent/sessions":
|
web.url = webview.url;
|
||||||
return true;
|
web.address = webview.url;
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function urlAppend(url) {
|
function onInitialPage(url) {
|
||||||
console.log(url);
|
return (url === webview.url);
|
||||||
if (removingPage || shouldLoadUrl(url)) {
|
|
||||||
removingPage = false;
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function urlAppend(url) {
|
||||||
var lurl = decodeURIComponent(url)
|
var lurl = decodeURIComponent(url)
|
||||||
if (lurl[lurl.length - 1] !== "/") {
|
if (lurl[lurl.length - 1] !== "/") {
|
||||||
lurl = lurl + "/"
|
lurl = lurl + "/"
|
||||||
}
|
}
|
||||||
console.log("-------> trying to append url <------------");
|
web.urlList.push(url);
|
||||||
console.log(currentPage);
|
setBackButtonStatus();
|
||||||
console.log(pagesModel.get(currentPage).webUrl !== lurl);
|
|
||||||
if (currentPage === -1 || (pagesModel.get(currentPage).webUrl !== lurl)) {
|
|
||||||
timer.start();
|
|
||||||
console.log("---------> appending url <-------------");
|
|
||||||
pagesModel.append({webUrl: lurl});
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onCurrentPageChanged: {
|
function setBackButtonStatus() {
|
||||||
if (currentPage >= 0 && currentPage < pagesModel.count && removingPage) {
|
if (web.urlList.length > 0 || webview.canGoBack) {
|
||||||
timer.start();
|
back.enabledColor = hifi.colors.darkGray;
|
||||||
webview.url = pagesModel.get(currentPage).webUrl;
|
back.enabled = true;
|
||||||
web.url = webview.url;
|
} else {
|
||||||
web.address = webview.url;
|
back.enabledColor = hifi.colors.baseGray;
|
||||||
removingPage = false;
|
back.enabled = false;
|
||||||
} else if (startingUp) {
|
|
||||||
webview.url = pagesModel.get(currentPage).webUrl;
|
|
||||||
web.url = webview.url;
|
|
||||||
web.address = webview.url;
|
|
||||||
startingUp = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onUrlChanged: {
|
onUrlChanged: {
|
||||||
gotoPage(url)
|
loadUrl(url);
|
||||||
|
if (startingUp) {
|
||||||
|
web.initialPage = webview.url;
|
||||||
|
startingUp = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QtObject {
|
QtObject {
|
||||||
|
@ -202,17 +194,6 @@ Item {
|
||||||
property var eventBridge;
|
property var eventBridge;
|
||||||
}
|
}
|
||||||
|
|
||||||
Timer {
|
|
||||||
id: timer
|
|
||||||
interval: 200
|
|
||||||
running: false
|
|
||||||
repeat: false
|
|
||||||
onTriggered: timer.stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
WebEngineView {
|
WebEngineView {
|
||||||
id: webview
|
id: webview
|
||||||
objectName: "webEngineView"
|
objectName: "webEngineView"
|
||||||
|
@ -280,9 +261,6 @@ Item {
|
||||||
// Required to support clicking on "hifi://" links
|
// Required to support clicking on "hifi://" links
|
||||||
if (WebEngineView.LoadStartedStatus == loadRequest.status) {
|
if (WebEngineView.LoadStartedStatus == loadRequest.status) {
|
||||||
var url = loadRequest.url.toString();
|
var url = loadRequest.url.toString();
|
||||||
web.urlList.push(url);
|
|
||||||
//urlAppend(url);
|
|
||||||
web.loadingStarted = true;
|
|
||||||
if (urlHandler.canHandleUrl(url)) {
|
if (urlHandler.canHandleUrl(url)) {
|
||||||
if (urlHandler.handleUrl(url)) {
|
if (urlHandler.handleUrl(url)) {
|
||||||
root.stop();
|
root.stop();
|
||||||
|
@ -295,19 +273,16 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WebEngineView.LoadSucceededStatus == loadRequest.status) {
|
if (WebEngineView.LoadSucceededStatus == loadRequest.status) {
|
||||||
console.log
|
web.address = webview.url;
|
||||||
urlList = [];
|
if (startingUp) {
|
||||||
|
web.initialPage = webview.url;
|
||||||
|
startingUp = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onWindowCloseRequested: {
|
|
||||||
console.log("---------->requested to closeWindow <--------------");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onNewViewRequested: {
|
onNewViewRequested: {
|
||||||
console.log("-----------> newViewRequested <--------------");
|
|
||||||
var currentUrl = webview.url;
|
var currentUrl = webview.url;
|
||||||
console.log(currentUrl);
|
|
||||||
urlAppend(currentUrl);
|
urlAppend(currentUrl);
|
||||||
request.openIn(webview);
|
request.openIn(webview);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue