Fix HTile left/right click handling

This commit is contained in:
miruka 2019-09-14 18:52:43 -04:00
parent c6395ff940
commit 76ffdfd28a
4 changed files with 21 additions and 14 deletions

View File

@ -4,6 +4,9 @@ import QtQuick.Layouts 1.12
HButton {
id: tile
signal leftClicked()
signal rightClicked()
default property var additionalItems: []
readonly property alias title: title
@ -69,10 +72,16 @@ HButton {
children: [image, details].concat(additionalItems)
}
TapHandler {
acceptedButtons: Qt.LeftButton
onTapped: leftClicked()
}
TapHandler {
enabled: contextMenu.count > 0
acceptedButtons: Qt.RightButton
onTapped: contextMenu.popup()
onTapped: {
rightClicked()
if (contextMenu.count > 0) contextMenu.popup()
}
}
}

View File

@ -4,7 +4,7 @@ import QtQuick.Layouts 1.12
HTile {
id: tile
onActivated: view.currentIndex = model.index
onClicked: {
onLeftClicked: {
view.highlightRangeMode = ListView.NoHighlightRange
view.highlightMoveDuration = 0
activated()
@ -31,9 +31,4 @@ HTile {
// Component.onCompleted won't work for this
onTriggered: if (shouldBeCurrent) view.currentIndex = model.index
}
TapHandler {
acceptedButtons: Qt.RightButton
onTapped: if (contextMenu.count > 0) contextMenu.popup()
}
}

View File

@ -76,6 +76,12 @@ Column {
null, 4)
}
function openContextMenu() {
contextMenu.media = eventDelegate.hoveredMediaTypeUrl
contextMenu.link = eventContent.hoveredLink
contextMenu.popup()
}
Daybreak {
visible: dayBreak
@ -98,11 +104,7 @@ Column {
TapHandler {
acceptedButtons: Qt.RightButton
onTapped: {
contextMenu.media = eventDelegate.hoveredMediaTypeUrl
contextMenu.link = eventContent.hoveredLink
contextMenu.popup()
}
onTapped: openContextMenu()
}
HMenu {

View File

@ -8,7 +8,8 @@ HTile {
theme.chat.message.thumbnailWidth,
)
onClicked: Qt.openUrlExternally(fileUrl)
onLeftClicked: Qt.openUrlExternally(fileUrl)
onRightClicked: eventDelegate.openContextMenu()
onHoveredChanged:
eventDelegate.hoveredMediaTypeUrl =