From 88d684b6c1424a5ad31d3b3283f7b1a03a6e1c57 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Fri, 21 Feb 2025 16:07:31 -0500 Subject: [PATCH] Don't allow long-pressing on non-touchscreen devices It isn't the right kind of interaction on a computer with a mouse or trackpad, it should be relegated to touchscreen only. This should hopefully cover everything from room list delegates to messages. --- src/qml/AvatarTabButton.qml | 8 ++++++-- src/qml/RoomDelegate.qml | 7 +++++-- src/timeline/CodeComponent.qml | 5 +++++ src/timeline/HiddenDelegate.qml | 2 ++ src/timeline/LiveLocationComponent.qml | 3 +++ src/timeline/LocationComponent.qml | 3 +++ src/timeline/MessageDelegate.qml | 1 + src/timeline/QuoteComponent.qml | 1 + src/timeline/TextComponent.qml | 1 + 9 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/qml/AvatarTabButton.qml b/src/qml/AvatarTabButton.qml index 03b48adcb..12bfcc79a 100644 --- a/src/qml/AvatarTabButton.qml +++ b/src/qml/AvatarTabButton.qml @@ -34,9 +34,8 @@ Delegates.RoundedItemDelegate { Keys.onSpacePressed: selected() Keys.onEnterPressed: selected() - onPressAndHold: root.contextMenuRequested() - TapHandler { + acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad | PointerDevice.Stylus acceptedButtons: Qt.RightButton | Qt.LeftButton onTapped: (eventPoint, button) => { if (button === Qt.RightButton) { @@ -47,6 +46,11 @@ Delegates.RoundedItemDelegate { } } + TapHandler { + acceptedDevices: PointerDevice.TouchScreen + onLongPressed: root.contextMenuRequested() + } + contentItem: AvatarNotification { id: avatarNotification source: root.source diff --git a/src/qml/RoomDelegate.qml b/src/qml/RoomDelegate.qml index 1dbefeb83..932551857 100644 --- a/src/qml/RoomDelegate.qml +++ b/src/qml/RoomDelegate.qml @@ -42,8 +42,6 @@ Delegates.RoundedItemDelegate { } } - onPressAndHold: createRoomListContextMenu() - Keys.onSpacePressed: clicked() Keys.onEnterPressed: clicked() Keys.onReturnPressed: clicked() @@ -54,6 +52,11 @@ Delegates.RoundedItemDelegate { onTapped: (eventPoint, button) => root.createRoomListContextMenu() } + TapHandler { + acceptedDevices: PointerDevice.TouchScreen + onLongPressed: root.createRoomListContextMenu() + } + contentItem: RowLayout { spacing: Kirigami.Units.largeSpacing diff --git a/src/timeline/CodeComponent.qml b/src/timeline/CodeComponent.qml index 3a6882480..51af4ad39 100644 --- a/src/timeline/CodeComponent.qml +++ b/src/timeline/CodeComponent.qml @@ -128,7 +128,12 @@ QQC2.Control { TapHandler { enabled: root.time.toString() !== "Invalid Date" acceptedButtons: Qt.LeftButton + acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad | PointerDevice.Stylus onTapped: RoomManager.maximizeCode(root.author, root.time, root.display, root.componentAttributes.class) + } + + TapHandler { + acceptedDevices: PointerDevice.TouchScreen onLongPressed: root.showMessageMenu() } diff --git a/src/timeline/HiddenDelegate.qml b/src/timeline/HiddenDelegate.qml index 11b4dd9be..0032b3155 100644 --- a/src/timeline/HiddenDelegate.qml +++ b/src/timeline/HiddenDelegate.qml @@ -68,11 +68,13 @@ TimelineDelegate { TapHandler { acceptedButtons: Qt.RightButton + acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad | PointerDevice.Stylus onTapped: _private.showMessageMenu() } TapHandler { acceptedButtons: Qt.LeftButton + acceptedDevices: PointerDevice.TouchScreen onLongPressed: _private.showMessageMenu() } diff --git a/src/timeline/LiveLocationComponent.qml b/src/timeline/LiveLocationComponent.qml index 07142ff47..2339383f6 100644 --- a/src/timeline/LiveLocationComponent.qml +++ b/src/timeline/LiveLocationComponent.qml @@ -69,6 +69,9 @@ ColumnLayout { }); map.open(); } + } + TapHandler { + acceptedDevices: PointerDevice.TouchScreen onLongPressed: openMessageContext("") } TapHandler { diff --git a/src/timeline/LocationComponent.qml b/src/timeline/LocationComponent.qml index 20c72ca19..6fee9caa3 100644 --- a/src/timeline/LocationComponent.qml +++ b/src/timeline/LocationComponent.qml @@ -90,6 +90,9 @@ ColumnLayout { }); map.open(); } + } + TapHandler { + acceptedDevices: PointerDevice.TouchScreen onLongPressed: openMessageContext("") } TapHandler { diff --git a/src/timeline/MessageDelegate.qml b/src/timeline/MessageDelegate.qml index c573cd6c2..59cba43f2 100644 --- a/src/timeline/MessageDelegate.qml +++ b/src/timeline/MessageDelegate.qml @@ -323,6 +323,7 @@ TimelineDelegate { } TapHandler { + acceptedDevices: PointerDevice.TouchScreen acceptedButtons: Qt.LeftButton onLongPressed: _private.showMessageMenu() } diff --git a/src/timeline/QuoteComponent.qml b/src/timeline/QuoteComponent.qml index 1640e3f79..27399a406 100644 --- a/src/timeline/QuoteComponent.qml +++ b/src/timeline/QuoteComponent.qml @@ -55,6 +55,7 @@ QQC2.Control { TapHandler { enabled: !quoteText.hoveredLink + acceptedDevices: PointerDevice.TouchScreen acceptedButtons: Qt.LeftButton onLongPressed: root.showMessageMenu() } diff --git a/src/timeline/TextComponent.qml b/src/timeline/TextComponent.qml index 3cb9c7a49..03f188190 100644 --- a/src/timeline/TextComponent.qml +++ b/src/timeline/TextComponent.qml @@ -132,6 +132,7 @@ a{ TapHandler { enabled: !root.hoveredLink acceptedButtons: Qt.LeftButton + acceptedDevices: PointerDevice.TouchScreen onLongPressed: root.showMessageMenu() } }