Skip to content
This repository has been archived by the owner on Jan 22, 2022. It is now read-only.

Commit

Permalink
update addressbar.text via timer, so that the textfield is blocked wh…
Browse files Browse the repository at this point in the history
…en search suggestions are loaded
  • Loading branch information
balcy authored and UniversalSuperBox committed Jan 29, 2021
1 parent 7270abf commit 8b0ea20
Showing 1 changed file with 55 additions and 35 deletions.
90 changes: 55 additions & 35 deletions src/app/webbrowser/AddressBar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ FocusScope {

property alias icon: favicon.source
property bool incognito: false
property alias text: textField.text
property string text
property bool bookmarked: false
signal toggleBookmark()
property url requestedUrl
Expand Down Expand Up @@ -73,12 +73,20 @@ FocusScope {
value: findInPageMode ? textField.text : ""
}

Timer {
id: searchTextTimer
onTriggered: (addressbar.text = textField.text)
interval: 900
}

TextField {
id: textField
objectName: "addressBarTextField"

anchors.fill: parent

onTextChanged: searchTextTimer.restart()

primaryItem: Item {
id: icons

Expand Down Expand Up @@ -423,13 +431,14 @@ FocusScope {
}

function validate() {
var query = text.trim()
text = textField.text;
var query = text.trim();
if (UrlUtils.looksLikeAUrl(query)) {
requestedUrl = UrlUtils.fixUrl(query)
requestedUrl = UrlUtils.fixUrl(query);
} else {
requestedUrl = internal.buildSearchUrl(query)
requestedUrl = internal.buildSearchUrl(query);
}
validated()
validated();
}

function simplifyUrl(url) {
Expand Down Expand Up @@ -471,68 +480,79 @@ FocusScope {

onIncognitoChanged: {
if (incognito) {
text = ""
internal.simplified = false
textField.text = "";
internal.simplified = false;
}
}

onEditingChanged: {
if (findInPageMode) return
if (findInPageMode) {
return;
}
if (editing && internal.simplified) {
text = actualUrl
internal.simplified = false
textField.text = actualUrl;
internal.simplified = false;
} else if (!editing) {
if (canSimplifyText && !loading && actualUrl.toString()) {
text = internal.simplifyUrl(actualUrl)
internal.simplified = true
textField.text = internal.simplifyUrl(actualUrl);
internal.simplified = true;
} else {
text = actualUrl
internal.simplified = false
textField.text = actualUrl;
internal.simplified = false;
}
}
}

onCanSimplifyTextChanged: {
if (editing || findInPageMode) return
if (editing || findInPageMode) {
return;
}
if (canSimplifyText && !loading && actualUrl.toString()) {
text = internal.simplifyUrl(actualUrl)
internal.simplified = true
textField.text = internal.simplifyUrl(actualUrl);
internal.simplified = true;
} else if (!canSimplifyText && internal.simplified) {
text = actualUrl
internal.simplified = false
textField.text = actualUrl;
internal.simplified = false;
}
}

onActualUrlChanged: {
if (editing || findInPageMode) return
if (editing || findInPageMode) {
return;
}
if (canSimplifyText) {
text = internal.simplifyUrl(actualUrl)
internal.simplified = true
textField.text = internal.simplifyUrl(actualUrl);
internal.simplified = true;
} else {
text = actualUrl
internal.simplified = false
textField.text = actualUrl;
internal.simplified = false;
}
}

onRequestedUrlChanged: {
if (editing || findInPageMode) return
if (editing || findInPageMode) {
return;
}
if (canSimplifyText) {
text = internal.simplifyUrl(requestedUrl)
internal.simplified = true
textField.text = internal.simplifyUrl(requestedUrl);
internal.simplified = true;
} else {
text = requestedUrl
internal.simplified = false
textField.text = requestedUrl;
internal.simplified = false;
}
}

onFindInPageModeChanged: {
if (findInPageMode) return
if (canSimplifyText) {
text = internal.simplifyUrl(actualUrl)
internal.simplified = true
if (findInPageMode) {
textField.text = "";
} else if (canSimplifyText) {
textField.text = internal.simplifyUrl(actualUrl);
addressBar.text = textField.text;
internal.simplified = true;
} else {
text = actualUrl
internal.simplified = false
textField.text = actualUrl;
addressBar.text = textField.text;
internal.simplified = false;
}
}

Expand Down

0 comments on commit 8b0ea20

Please sign in to comment.