StandardDropdown: Add Flickable and ScrollBar to droplist

This commit adds a Flickable and ScrollBar to the
StandardDropdown component. The use case is for the list
of fiat currencies which is flowing off-screen. Tested on
ASUSTek laptop touchpad.

Fixes: 302490e ("Add additional fiat currencies")
This commit is contained in:
reemuru 2022-03-20 15:24:46 -05:00
parent 002fe8eefa
commit 6778e7261b
No known key found for this signature in database
GPG key ID: 5EDBFEFFA9E9A7AB

View file

@ -146,11 +146,37 @@ ColumnLayout {
padding: 0
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
Flickable {
id: flickable
flickableDirection: Flickable.VerticalFlick
clip: true
boundsBehavior: Flickable.StopAtBounds
contentHeight: contentItem.childrenRect.height
contentWidth: contentItem.childrenRect.width
width: dropdown.width
height: 240
y: head.height + head.y
flickDeceleration: 35000
onAtYEndChanged: {
if (flickable.atYEnd) {
// hack for getting that last item Flickable seems to hate showing
}
}
// put a mouse area on the flickable since we don't have access to the previous one
MouseArea {
id: dropArea2
anchors.fill: parent
onClicked: dropdown.expanded ? popup.close() : popup.open()
hoverEnabled: true
cursorShape: Qt.ArrowCursor
onPressed: flickable.interactive = false
onReleased: flickable.interactive = true
}
ScrollBar.vertical: ScrollBar {}
Rectangle {
id: droplist
anchors.left: parent.left
width: dropdown.width
y: head.y + head.height
clip: true
height: dropdown.expanded ? columnid.height : 0
color: dropdown.pressedColor
@ -225,4 +251,5 @@ ColumnLayout {
}
}
}
}
}