mirror of
https://github.com/monero-project/monero-gui.git
synced 2024-12-23 03:59:38 +00:00
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:
parent
002fe8eefa
commit
6778e7261b
1 changed files with 88 additions and 61 deletions
|
@ -146,11 +146,37 @@ ColumnLayout {
|
||||||
padding: 0
|
padding: 0
|
||||||
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
|
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 {
|
Rectangle {
|
||||||
id: droplist
|
id: droplist
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
width: dropdown.width
|
width: dropdown.width
|
||||||
y: head.y + head.height
|
|
||||||
clip: true
|
clip: true
|
||||||
height: dropdown.expanded ? columnid.height : 0
|
height: dropdown.expanded ? columnid.height : 0
|
||||||
color: dropdown.pressedColor
|
color: dropdown.pressedColor
|
||||||
|
@ -226,3 +252,4 @@ ColumnLayout {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue