Commit 57053f35 authored by Rinigus Saar's avatar Rinigus Saar Committed by Jonah Brüchert

follow requested URL when interacting with user

parent 94181d23
......@@ -44,7 +44,10 @@ Repeater {
id: tabsModel
isMobileDefault: Kirigami.Settings.isMobile
privateMode: privateTabsMode
Component.onCompleted: tabsModel.loadInitialTabs()
Component.onCompleted: {
tabsModel.loadInitialTabs();
loadTabsModel();
}
signal loadTabsModel()
}
......@@ -55,7 +58,6 @@ Repeater {
top: tabs.top
}
privateMode: tabs.privateTabsMode
url: "about:empty"
userAgent.isMobile: model.isMobile
width: tabs.width
......@@ -70,9 +72,7 @@ Repeater {
}
}
onUrlChanged: {
tabsModel.setUrl(index, url);
}
onRequestedUrlChanged: tabsModel.setUrl(index, requestedUrl)
Component.onCompleted: url = model.pageurl
......
......@@ -108,7 +108,7 @@ Item {
Layout.fillWidth: true
Layout.preferredHeight: layout.height
property string scheme: UrlUtils.urlScheme(currentWebView.url)
property string scheme: UrlUtils.urlScheme(currentWebView.requestedUrl)
Controls.ToolButton {
id: schemeIcon
......@@ -138,12 +138,12 @@ Item {
text: {
if (labelItem.scheme === "http" || labelItem.scheme === "https") {
var h = UrlUtils.urlHostPort(currentWebView.url);
var p = UrlUtils.urlPath(currentWebView.url);
var h = UrlUtils.urlHostPort(currentWebView.requestedUrl);
var p = UrlUtils.urlPath(currentWebView.requestedUrl);
if (p === "/") p = ""
return '%1<font size="2">%2</font>'.arg(h).arg(p);
}
return currentWebView.url;
return currentWebView.requestedUrl;
}
textFormat: Text.StyledText
elide: Text.ElideRight
......
......@@ -74,7 +74,6 @@ Controls.Drawer {
Layout.fillWidth: true
clip: true
focus: false
text: currentWebView.url
selectByMouse: true
Kirigami.Theme.inherit: true
......@@ -136,7 +135,7 @@ Controls.Drawer {
// check if the drawer was just slightly slided
if (openedState) return;
openedState = true;
urlInput.text = currentWebView.url;
urlInput.text = currentWebView.requestedUrl;
urlInput.forceActiveFocus();
urlInput.selectAll();
listView.positionViewAtBeginning();
......
......@@ -42,6 +42,11 @@ WebEngineView {
property bool reloadOnVisible: true
// URL that was requested and should be used
// as a base for user interaction. It reflects
// last request (successful or failed)
property url requestedUrl: url
UserAgentGenerator {
id: userAgent
onUserAgentChanged: webEngineView.reload()
......@@ -166,9 +171,15 @@ WebEngineView {
}
if (loadRequest.status === WebEngineView.LoadFailedStatus) {
print("Load failed: " + loadRequest.errorCode + " " + loadRequest.errorString);
print("Load failed url: " + loadRequest.url + " " + url);
ec = loadRequest.errorCode;
es = loadRequest.errorString;
thumb.source = "";
// update requested URL only after its clear that it fails.
// Otherwise, its updated as a part of url property update.
if (requestedUrl !== loadRequest.url)
requestedUrl = loadRequest.url;
}
errorCode = ec;
errorString = es;
......@@ -196,7 +207,12 @@ WebEngineView {
}
}
onUrlChanged: thumb.source = ""
onUrlChanged: {
if (requestedUrl !== url) {
requestedUrl = url;
}
thumb.source = "";
}
onFullScreenRequested: {
request.accept()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment