From 7e7852b51e593683a50bfa89df7b1b176190bcc8 Mon Sep 17 00:00:00 2001 From: miruka Date: Tue, 20 Aug 2019 14:29:03 -0400 Subject: [PATCH] Hide hover highlight when moving with keybinds --- src/qml/Base/HInteractiveRectangle.qml | 12 +++++++++--- src/qml/SidePane/AccountRoomList.qml | 17 +++++++++++++++++ src/qml/SidePane/DelegateAccount.qml | 5 +++++ src/qml/SidePane/DelegateRoom.qml | 7 +++++-- 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/src/qml/Base/HInteractiveRectangle.qml b/src/qml/Base/HInteractiveRectangle.qml index cce66f6b..93d5e01f 100644 --- a/src/qml/Base/HInteractiveRectangle.qml +++ b/src/qml/Base/HInteractiveRectangle.qml @@ -1,10 +1,12 @@ import QtQuick 2.12 HRectangle { + id: rectangle + property bool checkable: false // TODO property bool checked: false - property alias pressed: tap.pressed - property alias hovered: hover.hovered + property bool hovered: false + readonly property alias pressed: tap.pressed readonly property QtObject _ir: theme.controls.interactiveRectangle color: _ir.background @@ -26,6 +28,10 @@ HRectangle { "transparent" } - HoverHandler { id: hover } + HoverHandler { + id: hover + onHoveredChanged: rectangle.hovered = hovered + } + TapHandler { id: tap } } diff --git a/src/qml/SidePane/AccountRoomList.qml b/src/qml/SidePane/AccountRoomList.qml index ed50a5c3..84e8c87b 100644 --- a/src/qml/SidePane/AccountRoomList.qml +++ b/src/qml/SidePane/AccountRoomList.qml @@ -7,6 +7,10 @@ HListView { id: accountRoomList + signal hideHoverHighlight() + onHideHoverHighlight: hoverBlocker.enabled = true + + readonly property var originSource: window.sidePaneModelSource readonly property var collapseAccounts: window.uiState.collapseAccounts readonly property string filter: paneToolBar.roomFilter @@ -58,12 +62,14 @@ HListView { } function previous(activate=true) { + hideHoverHighlight() decrementCurrentIndex() if (activate) activateLimiter.requestFire() } function next(activate=true) { + hideHoverHighlight() incrementCurrentIndex() if (activate) activateLimiter.requestFire() } @@ -105,6 +111,17 @@ HListView { } + MouseArea { + id: hoverBlocker + anchors.fill: parent + enabled: false + hoverEnabled: enabled + propagateComposedEvents: true + + onMouseXChanged: enabled = false + onMouseYChanged: enabled = false + } + HRateLimiter { id: filterLimiter cooldown: 16 diff --git a/src/qml/SidePane/DelegateAccount.qml b/src/qml/SidePane/DelegateAccount.qml index 4b81fed7..3c509cc8 100644 --- a/src/qml/SidePane/DelegateAccount.qml +++ b/src/qml/SidePane/DelegateAccount.qml @@ -51,6 +51,11 @@ HInteractiveRectangle { onTriggered: if (isCurrent) beHighlighted() } + Connections { + target: accountRoomList + onHideHoverHighlight: accountDelegate.hovered = false + } + TapHandler { onTapped: { accountRoomList.highlightRangeMode = ListView.NoHighlightRange diff --git a/src/qml/SidePane/DelegateRoom.qml b/src/qml/SidePane/DelegateRoom.qml index a45ef2fd..3a9bb40a 100644 --- a/src/qml/SidePane/DelegateRoom.qml +++ b/src/qml/SidePane/DelegateRoom.qml @@ -45,6 +45,11 @@ HInteractiveRectangle { onTriggered: if (isCurrent) beHighlighted() } + Connections { + target: accountRoomList + onHideHoverHighlight: roomDelegate.hovered = false + } + TapHandler { onTapped: { accountRoomList.highlightRangeMode = ListView.NoHighlightRange @@ -57,8 +62,6 @@ HInteractiveRectangle { HRowLayout { id: rowLayout - property var pr: sidePane.currentSpacing - onPrChanged: print("pr changed:", pr, spacing, x) spacing: sidePane.currentSpacing x: sidePane.currentSpacing