From 001c2c8ead6dc1ba678df54fa60419f56014d0ec Mon Sep 17 00:00:00 2001 From: Chris Clime Date: Wed, 8 Jul 2020 21:43:44 +0200 Subject: [PATCH 1/3] update addressbar.text via timer, so that the textfield is blocked when search suggestions are loaded --- src/app/webbrowser/AddressBar.qml | 90 +++++++++++++++++++------------ 1 file changed, 55 insertions(+), 35 deletions(-) diff --git a/src/app/webbrowser/AddressBar.qml b/src/app/webbrowser/AddressBar.qml index 65f432322..9a70f7445 100644 --- a/src/app/webbrowser/AddressBar.qml +++ b/src/app/webbrowser/AddressBar.qml @@ -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 @@ -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 @@ -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) { @@ -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; } } From 0163a047deeec67ffbc7f4ab2448c7efa1b5875e Mon Sep 17 00:00:00 2001 From: Chris Clime Date: Wed, 25 Nov 2020 18:50:12 +0100 Subject: [PATCH 2/3] Update AddressBar.qml correct addressBar.text -> addressbar.text --- src/app/webbrowser/AddressBar.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/webbrowser/AddressBar.qml b/src/app/webbrowser/AddressBar.qml index 9a70f7445..003504cca 100644 --- a/src/app/webbrowser/AddressBar.qml +++ b/src/app/webbrowser/AddressBar.qml @@ -547,11 +547,11 @@ FocusScope { textField.text = ""; } else if (canSimplifyText) { textField.text = internal.simplifyUrl(actualUrl); - addressBar.text = textField.text; + addressbar.text = textField.text; internal.simplified = true; } else { textField.text = actualUrl; - addressBar.text = textField.text; + addressbar.text = textField.text; internal.simplified = false; } } From b4a607e41cae0cc07dc0d274911500fb358b18de Mon Sep 17 00:00:00 2001 From: Chris Clime Date: Sun, 31 Jan 2021 18:38:18 +0100 Subject: [PATCH 3/3] clear the search results when the user starts typing --- src/app/webbrowser/AddressBar.qml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/app/webbrowser/AddressBar.qml b/src/app/webbrowser/AddressBar.qml index 003504cca..bc1433ea9 100644 --- a/src/app/webbrowser/AddressBar.qml +++ b/src/app/webbrowser/AddressBar.qml @@ -85,7 +85,12 @@ FocusScope { anchors.fill: parent - onTextChanged: searchTextTimer.restart() + onTextChanged: { + if (editing) { + addressbar.text = ""; + searchTextTimer.restart(); + } + } primaryItem: Item { id: icons