Browse Source

qml: implement scrollbar drag in history listview

master
Sander van Grieken 3 years ago
parent
commit
c37e202e44
  1. 3
      electrum/gui/qml/components/Constants.qml
  2. 45
      electrum/gui/qml/components/History.qml
  3. 3
      electrum/gui/qml/components/controls/HistoryItemDelegate.qml

3
electrum/gui/qml/components/Constants.qml

@ -32,4 +32,7 @@ Item {
property color colorLightningLocal: "blue" property color colorLightningLocal: "blue"
property color colorLightningRemote: "yellow" property color colorLightningRemote: "yellow"
function colorAlpha(baseColor, alpha) {
return Qt.rgba(baseColor.r, baseColor.g, baseColor.b, alpha)
}
} }

45
electrum/gui/qml/components/History.qml

@ -10,7 +10,8 @@ import "controls"
Pane { Pane {
id: rootItem id: rootItem
visible: Daemon.currentWallet !== undefined visible: Daemon.currentWallet
padding: 0
clip: true clip: true
ListView { ListView {
@ -62,6 +63,48 @@ Pane {
} }
MouseArea {
id: vdragscroll
anchors {
top: listview.top
right: listview.right
bottom: listview.bottom
}
width: constants.paddingXXLarge
drag.target: dragb
onPressedChanged: if (pressed) {
dragb.y = mouseY - dragb.height/2
}
}
Rectangle {
id: dragb
anchors.right: vdragscroll.left
width: postext.width + constants.paddingXXLarge
height: postext.height + constants.paddingXXLarge
radius: constants.paddingXSmall
color: constants._alpha(Material.accentColor, 0.33)
border.color: Material.accentColor
opacity : vdragscroll.drag.active ? 1 : 0
Behavior on opacity { NumberAnimation { duration: 300 } }
onYChanged: {
if (vdragscroll.drag.active) {
listview.contentY =
Math.min(listview.contentHeight - listview.height + listview.originY,
Math.max(listview.originY,
(y/vdragscroll.height) * listview.contentHeight))
}
}
Label {
id: postext
anchors.centerIn: parent
text: listview.itemAt(0,listview.contentY + (dragb.y + dragb.height/2)).delegateModel.date
font.pixelSize: constants.fontSizeLarge
}
}
Connections { Connections {
target: Network target: Network
function onHeightChanged(height) { function onHeightChanged(height) {

3
electrum/gui/qml/components/controls/HistoryItemDelegate.qml

@ -10,6 +10,9 @@ Item {
width: ListView.view.width width: ListView.view.width
height: delegateLayout.height height: delegateLayout.height
// expose delegate model for scroll indicator
property var delegateModel: model
ColumnLayout { ColumnLayout {
id: delegateLayout id: delegateLayout
width: parent.width width: parent.width

Loading…
Cancel
Save