Commit 8f272539 authored by Rinigus Saar's avatar Rinigus Saar
Browse files

a delay before performing a search for short strings

parent 32bd5477
......@@ -43,8 +43,21 @@ Kirigami.ScrollablePage {
inputMethodHints: rootPage.privateMode ? Qt.ImhNoPredictiveText : Qt.ImhNone
Kirigami.Theme.inherit: true
onDisplayTextChanged: list.model.filter = displayText;
onDisplayTextChanged: {
if (displayText === "" || displayText.length > 2) {
list.model.filter = displayText;
timer.running = false;
}
else timer.running = true;
}
Keys.onEscapePressed: pageStack.pop()
Timer {
id: timer
repeat: false
interval: Math.max(1000, 3000 - search.displayText.length * 1000)
onTriggered: list.model.filter = search.displayText
}
}
}
......
......@@ -43,8 +43,21 @@ Kirigami.ScrollablePage {
inputMethodHints: rootPage.privateMode ? Qt.ImhNoPredictiveText : Qt.ImhNone
Kirigami.Theme.inherit: true
onDisplayTextChanged: list.model.filter = displayText;
onDisplayTextChanged: {
if (displayText === "" || displayText.length > 2) {
list.model.filter = displayText;
timer.running = false;
}
else timer.running = true;
}
Keys.onEscapePressed: pageStack.pop()
Timer {
id: timer
repeat: false
interval: Math.max(1000, 3000 - search.displayText.length * 1000)
onTriggered: list.model.filter = search.displayText
}
}
}
......
......@@ -43,7 +43,6 @@ Controls.Drawer {
property int buttonSize: Kirigami.Units.gridUnit * 2
property int fullHeight: 0.9 * rootPage.height
property bool openedState: false
property bool justOpened: false
contentHeight: fullHeight - topPadding - bottomPadding
contentWidth: parent.width - rightPadding - leftPadding
......@@ -82,11 +81,21 @@ Controls.Drawer {
onAccepted: applyUrl()
onDisplayTextChanged: {
if (!openedState) return; // avoid filtering
urlFilter.filter = displayText;
justOpened = false;
if (displayText === "" || displayText.length > 2) {
urlFilter.filter = displayText;
timer.running = false;
}
else timer.running = true;
}
Keys.onEscapePressed: if (overlay.sheetOpen) overlay.close()
Timer {
id: timer
repeat: false
interval: Math.max(1000, 3000 - urlInput.displayText.length * 1000)
onTriggered: urlFilter.filter = urlInput.displayText
}
function applyUrl() {
if (text.match(RegexWebUrl.re_weburl)) {
currentWebView.url = UrlUtils.urlFromUserInput(text);
......@@ -125,7 +134,7 @@ Controls.Drawer {
delegate: UrlDelegate {
showRemove: false
onClicked: overlay.close()
highlightText: urlInput.displayText
highlightText: urlFilter.filter
width: parent.width
}
......@@ -144,7 +153,6 @@ Controls.Drawer {
urlInput.text = currentWebView.requestedUrl;
urlInput.forceActiveFocus();
urlInput.selectAll();
justOpened = true;
urlFilter.filter = "";
openedState = true;
listView.positionViewAtBeginning();
......
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