mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-08-09 06:58:29 -04:00
@@ -33,6 +33,11 @@ Item {
|
|||||||
searchResultsModel.clear();
|
searchResultsModel.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CJK city names are commonly two code points (北京, 東京, 서울).
|
||||||
|
function canSearch(t) {
|
||||||
|
return t.length > 2 || (t.length >= 2 && /[-ヿ㐀-䶿一-鿿豈-가-]/.test(t));
|
||||||
|
}
|
||||||
|
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: searchInputField.height + (searchDropdown.visible ? searchDropdown.height : 0)
|
height: searchInputField.height + (searchDropdown.visible ? searchDropdown.height : 0)
|
||||||
|
|
||||||
@@ -47,7 +52,7 @@ Item {
|
|||||||
running: false
|
running: false
|
||||||
repeat: false
|
repeat: false
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
if (locationInput.text.length > 2) {
|
if (root.canSearch(locationInput.text)) {
|
||||||
searchResultsModel.clear();
|
searchResultsModel.clear();
|
||||||
root.isLoading = true;
|
root.isLoading = true;
|
||||||
const searchLocation = locationInput.text;
|
const searchLocation = locationInput.text;
|
||||||
@@ -130,7 +135,7 @@ Item {
|
|||||||
if (root._internalChange)
|
if (root._internalChange)
|
||||||
return;
|
return;
|
||||||
if (getActiveFocus()) {
|
if (getActiveFocus()) {
|
||||||
if (text.length > 2) {
|
if (root.canSearch(text)) {
|
||||||
root.isLoading = true;
|
root.isLoading = true;
|
||||||
locationSearchTimer.restart();
|
locationSearchTimer.restart();
|
||||||
} else {
|
} else {
|
||||||
@@ -154,7 +159,7 @@ Item {
|
|||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.rightMargin: Theme.spacingM
|
anchors.rightMargin: Theme.spacingM
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
opacity: (locationInput.getActiveFocus() && locationInput.text.length > 2) ? 1 : 0
|
opacity: (locationInput.getActiveFocus() && root.canSearch(locationInput.text)) ? 1 : 0
|
||||||
|
|
||||||
Behavior on opacity {
|
Behavior on opacity {
|
||||||
NumberAnimation {
|
NumberAnimation {
|
||||||
@@ -177,7 +182,7 @@ Item {
|
|||||||
color: Theme.withAlpha(Theme.surfaceContainer, Theme.popupTransparency)
|
color: Theme.withAlpha(Theme.surfaceContainer, Theme.popupTransparency)
|
||||||
border.color: Theme.primarySelected
|
border.color: Theme.primarySelected
|
||||||
border.width: 1
|
border.width: 1
|
||||||
visible: locationInput.getActiveFocus() && locationInput.text.length > 2 && (searchResultsModel.count > 0 || root.isLoading)
|
visible: locationInput.getActiveFocus() && root.canSearch(locationInput.text) && (searchResultsModel.count > 0 || root.isLoading)
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
@@ -259,7 +264,7 @@ Item {
|
|||||||
text: root.isLoading ? "Searching..." : "No locations found"
|
text: root.isLoading ? "Searching..." : "No locations found"
|
||||||
font.pixelSize: Theme.fontSizeMedium
|
font.pixelSize: Theme.fontSizeMedium
|
||||||
color: Theme.surfaceVariantText
|
color: Theme.surfaceVariantText
|
||||||
visible: searchResultsList.count === 0 && locationInput.text.length > 2
|
visible: searchResultsList.count === 0 && root.canSearch(locationInput.text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user