From e1f24657f1b1e709bf5a75f130704f8e4ce11356 Mon Sep 17 00:00:00 2001 From: miruka Date: Fri, 6 Sep 2019 16:08:16 -0400 Subject: [PATCH] Fix mouse wheel not working on eventList --- TODO.md | 1 - src/qml/Base/HListView.qml | 6 +++--- src/qml/Chat/Timeline/EventContent.qml | 21 +++++++++++++++++++-- src/qml/Chat/Timeline/EventList.qml | 15 +++++++++++++++ 4 files changed, 37 insertions(+), 6 deletions(-) diff --git a/TODO.md b/TODO.md index 290702bb..10e1b7a3 100644 --- a/TODO.md +++ b/TODO.md @@ -36,7 +36,6 @@ - Room header descriptions: styled text - Message selection - - Make scroll wheel usable - Copy to X11 selection - Images don't load correctly in TextEdit diff --git a/src/qml/Base/HListView.qml b/src/qml/Base/HListView.qml index 1a778dd0..a062fd65 100644 --- a/src/qml/Base/HListView.qml +++ b/src/qml/Base/HListView.qml @@ -24,9 +24,9 @@ ListView { color: theme.controls.listView.highlight } - ScrollBar.vertical: ScrollBar { - visible: listView.interactive || ! listView.enableFlicking - } + // ScrollBar.vertical: ScrollBar { + // visible: listView.interactive || ! listView.enableFlicking + // } add: Transition { ParallelAnimation { diff --git a/src/qml/Chat/Timeline/EventContent.qml b/src/qml/Chat/Timeline/EventContent.qml index d09e5d31..120ff81d 100644 --- a/src/qml/Chat/Timeline/EventContent.qml +++ b/src/qml/Chat/Timeline/EventContent.qml @@ -7,13 +7,27 @@ Row { id: eventContent spacing: theme.spacing / 2 - readonly property string hoveredLink: - nameLabel.hoveredLink || contentLabel.hoveredLink readonly property string eventText: Utils.processedEventText(model) readonly property string eventTime: Utils.formatTime(model.date) readonly property int eventTimeSpaces: 2 + readonly property string hoveredLink: + nameLabel.hoveredLink || contentLabel.hoveredLink + + readonly property int cursorShape: + hoveredLink ? Qt.PointingHandCursor : + nameHover.hovered || contentHover.hovered ? Qt.IBeamCursor : + Qt.ArrowCursor + + + // Needed because of eventList's MouseArea which steals the + // HSelectableLabel's MouseArea hover events + onCursorShapeChanged: eventList.cursorShape = cursorShape + + + HoverHandler { id: hover } + Item { width: hideAvatar ? 0 : 48 height: hideAvatar ? 0 : collapseAvatar ? 1 : smallAvatar ? 28 : 48 @@ -74,6 +88,8 @@ Row { function selectAllTextPlus() { contentLabel.selectAllTextPlus() } + + HoverHandler { id: nameHover } } HSelectableLabel { @@ -124,6 +140,7 @@ Row { contentLabel.updateContainerSelectedTexts() } + HoverHandler { id: contentHover } } } } diff --git a/src/qml/Chat/Timeline/EventList.qml b/src/qml/Chat/Timeline/EventList.qml index 9819bb8c..f824c8e0 100644 --- a/src/qml/Chat/Timeline/EventList.qml +++ b/src/qml/Chat/Timeline/EventList.qml @@ -92,6 +92,8 @@ Rectangle { property bool ownEventsOnRight: width < theme.chat.eventList.ownEventsOnRightUnderWidth + property alias cursorShape: mouseArea.cursorShape + function canCombine(item, itemAfter) { if (! item || ! itemAfter) return false @@ -154,6 +156,19 @@ Rectangle { } delegate: EventDelegate {} + + MouseArea { + id: mouseArea + anchors.fill: parent + acceptedButtons: Qt.NoButton + + onWheel: Utils.smartVerticalFlick( + eventList, + 200 * Qt.styleHints.wheelScrollLines * + (wheel.angleDelta.y < 0 ? 1 : -1), + 3 + ) + } } }