Fix EventList stuff depending on scroll position

Add visibleStart/End properties to HListView that take into account the
ListView's originX/Y, and not just contentX/Y which can be largely
offset.

Use those new properties in EventList for message focusing (fix
ctrl+up/down sometimes incorrectly focusing the message at the middle of
the screen even when we're scrolled at the bottom), and detection of
when we can update the read marker (fix cases when we're scrolled at the
bottom but the read marker never updates).
This commit is contained in:
miruka 2020-11-20 10:24:31 -04:00
parent 509b35a633
commit 8d4e67d6a4
2 changed files with 10 additions and 3 deletions

View File

@ -16,6 +16,13 @@ ListView {
property int lastCheckedDelegateIndex: 0
property int selectedCount: Object.keys(checked).length
readonly property point visibleStart:
Qt.point(contentX - originX, contentY - originY)
readonly property point visibleEnd:
Qt.point(visibleStart.x + width, visibleStart.y + height)
function check(...indices) {
for (const i of indices) {
const model = listView.model.get(i)

View File

@ -260,13 +260,13 @@ Rectangle {
}
function focusPreviousMessage() {
currentIndex === -1 && contentY < -height - bottomMargin * 2 ?
currentIndex === -1 && visibleEnd.y < contentHeight - height / 4 ?
focusCenterMessage() :
incrementCurrentIndex()
}
function focusNextMessage() {
currentIndex === -1 && contentY <= -height - bottomMargin * 2 ?
currentIndex === -1 && visibleEnd.y < contentHeight - height / 4 ?
focusCenterMessage() :
eventList.currentIndex === 0 ?
@ -625,7 +625,7 @@ Rectangle {
chat.roomInfo.local_highlights
) &&
Qt.application.state === Qt.ApplicationActive &&
(eventList.contentY + eventList.height) > -50
eventList.visibleEnd.y > eventList.contentHeight - 100
onTriggered: {
for (let i = 0; i < eventList.model.count; i++) {