fix(StatusListPicker): Disable uncheck option and reset searcher (#639)

Disabled uncheck option if component is configured as single selection mode.

Added binding to reset searcher input text when picker is closed.

BREAKING CHANGE: Renamed `searchText` property for `placeholderSearchText` to control placeholder text in searcher and added / used existing `searchText` property to control  searcher input text.
This commit is contained in:
Noelia 2022-05-03 10:45:36 +02:00 committed by GitHub
parent 7710470559
commit ae1e72fb23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 10 deletions

View File

@ -24,27 +24,27 @@ GridLayout {
id: languagePicker
z: 100
inputList: Models.languagePickerModel
searchText: qsTr("Search Languages")
placeholderSearchText: qsTr("Search Languages")
}
StatusListPicker {
id: languagePicker2
z: 100
inputList: Models.languageNoImagePickerModel
searchText: qsTr("Search Languages")
placeholderSearchText: qsTr("Search Languages")
}
StatusListPicker {
id: currencyPicker
inputList: Models.currencyPickerModel
searchText: qsTr("Search Currencies")
placeholderSearchText: qsTr("Search Currencies")
multiSelection: true
}
StatusListPicker {
id: currencyPicker2
inputList: Models.currencyPickerModel2
searchText: qsTr("Search Currencies")
placeholderSearchText: qsTr("Search Currencies")
multiSelection: true
printSymbol: true
enableSelectableItem: false

View File

@ -73,9 +73,15 @@ Item {
/*!
\qmlproperty string StatusListPicker::searchText
This property holds the search text the searcher input displays by default.
*/
property string searchText: ""
/*!
\qmlproperty string StatusListPicker::placeholderSearchText
This property holds the placeholder text the searcher input displays by default.
*/
property string searchText: qsTr("Search")
property string placeholderSearchText: qsTr("Search")
/*!
\qmlproperty string StatusListPicker::multiSelection
@ -113,7 +119,12 @@ Item {
}
\endqml
*/
function close() { picker.visible = false }
function close() {
picker.visible = false
// Reset searcher:
root.searchText = ""
}
/*!
\qmlsignal StatusListPicker::itemPickerChanged(string key, bool selected)
@ -276,16 +287,20 @@ Item {
anchors.verticalCenter: parent.verticalCenter
topPadding: 8
bottomPadding: 0
placeholderText: root.searchText
placeholderText: root.placeholderSearchText
text: root.searchText
icon.name: "search"
onTextChanged: { d.applyFilter(text) }
onTextChanged: {
d.applyFilter(text)
root.searchText = text
}
}
}// End of search input item
delegate: StatusItemPicker {
width: content.itemWidth
height: content.itemHeight
color: mouseArea.containsMouse? Theme.palette.baseColor4 : "transparent"
color: mouseArea.containsMouse ? Theme.palette.baseColor4 : "transparent"
image: StatusImageSettings {
source: model.imageSource ? model.imageSource : ""
width: 15
@ -319,7 +334,15 @@ Item {
anchors.fill: parent
cursorShape: root.enableSelectableItem ? Qt.PointingHandCursor : Qt.ArrowCursor
hoverEnabled: true
onClicked: { selected = !selected }
onClicked: {
if(selectorType === StatusItemPicker.SelectorType.RadioButton) {
// Just only allow to select, not unselect in case of single selection (radiobutton)
if(!selected) selected = !selected
}
else
// In case of multiple selections you can both select and unselect.
selected = !selected
}
}
}
section.property: "category"