Simplify & fix bugs event images context menu
Fix copy menu entries for messages with URL thumbnail previews
This commit is contained in:
parent
648c37f413
commit
b3ca5599cf
@ -8,11 +8,7 @@ import "../../../Base"
|
|||||||
import "../../../Base/MediaPlayer"
|
import "../../../Base/MediaPlayer"
|
||||||
|
|
||||||
AudioPlayer {
|
AudioPlayer {
|
||||||
id: audio
|
readonly property bool hovered: hover.hovered
|
||||||
|
|
||||||
HoverHandler {
|
HoverHandler { id: hover }
|
||||||
onHoveredChanged:
|
|
||||||
eventDelegate.hoveredMediaTypeUrl =
|
|
||||||
hovered ? [Utils.Media.Audio, audio.source, loader.title] : []
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -41,8 +41,11 @@ HRowLayout {
|
|||||||
|
|
||||||
readonly property bool pureMedia: ! contentText && linksRepeater.count
|
readonly property bool pureMedia: ! contentText && linksRepeater.count
|
||||||
|
|
||||||
readonly property string hoveredLink: contentLabel.hoveredLink
|
|
||||||
readonly property bool hoveredSelectable: contentHover.hovered
|
readonly property bool hoveredSelectable: contentHover.hovered
|
||||||
|
readonly property string hoveredLink:
|
||||||
|
linksRepeater.lastHovered && linksRepeater.lastHovered.hovered ?
|
||||||
|
linksRepeater.lastHovered.mediaUrl :
|
||||||
|
contentLabel.hoveredLink
|
||||||
|
|
||||||
readonly property alias contentLabel: contentLabel
|
readonly property alias contentLabel: contentLabel
|
||||||
|
|
||||||
@ -295,6 +298,11 @@ HRowLayout {
|
|||||||
|
|
||||||
HRepeater {
|
HRepeater {
|
||||||
id: linksRepeater
|
id: linksRepeater
|
||||||
|
|
||||||
|
property EventMediaLoader lastHovered: null
|
||||||
|
property var pr: lastHovered
|
||||||
|
onPrChanged: print("pr changed:", pr)
|
||||||
|
|
||||||
model: {
|
model: {
|
||||||
const links = JSON.parse(eventDelegate.currentModel.links)
|
const links = JSON.parse(eventDelegate.currentModel.links)
|
||||||
|
|
||||||
@ -313,6 +321,8 @@ HRowLayout {
|
|||||||
|
|
||||||
transform: Translate { x: xOffset }
|
transform: Translate { x: xOffset }
|
||||||
|
|
||||||
|
onHoveredChanged: if (hovered) linksRepeater.lastHovered = this
|
||||||
|
|
||||||
Layout.bottomMargin: pureMedia ? 0 : contentLabel.bottomPadding
|
Layout.bottomMargin: pureMedia ? 0 : contentLabel.bottomPadding
|
||||||
Layout.leftMargin: pureMedia ? 0 : eventContent.spacing
|
Layout.leftMargin: pureMedia ? 0 : eventContent.spacing
|
||||||
Layout.rightMargin: pureMedia ? 0 : eventContent.spacing
|
Layout.rightMargin: pureMedia ? 0 : eventContent.spacing
|
||||||
|
@ -13,7 +13,6 @@ HMenu {
|
|||||||
property HListView eventList
|
property HListView eventList
|
||||||
property int eventIndex: 0
|
property int eventIndex: 0
|
||||||
property Item eventDelegate: null // TODO: Qt 5.13: just use itemAtIndex()
|
property Item eventDelegate: null // TODO: Qt 5.13: just use itemAtIndex()
|
||||||
property var hoveredMedia: [] // [Utils.Media.<Type>, url, title]
|
|
||||||
property string hoveredLink: ""
|
property string hoveredLink: ""
|
||||||
|
|
||||||
readonly property QtObject event: eventList.model.get(eventIndex)
|
readonly property QtObject event: eventList.model.get(eventIndex)
|
||||||
@ -21,19 +20,20 @@ HMenu {
|
|||||||
readonly property bool isEncryptedMedia:
|
readonly property bool isEncryptedMedia:
|
||||||
Object.keys(JSON.parse(event.media_crypt_dict)).length > 0
|
Object.keys(JSON.parse(event.media_crypt_dict)).length > 0
|
||||||
|
|
||||||
function spawn(eventIndex, eventDelegate, hoveredMedia=[], hoveredUrl="") {
|
readonly property var mediaType: // Utils.Media.<Type> or null
|
||||||
|
event.media_http_url ? eventList.getMediaType(event) :
|
||||||
|
hoveredLink ? utils.getLinkType(hoveredLink) :
|
||||||
|
null
|
||||||
|
|
||||||
|
function spawn(eventIndex, eventDelegate, hoveredLink="") {
|
||||||
menu.eventIndex = eventIndex
|
menu.eventIndex = eventIndex
|
||||||
menu.eventDelegate = eventDelegate
|
menu.eventDelegate = eventDelegate
|
||||||
menu.hoveredMedia = hoveredMedia
|
menu.hoveredLink = hoveredLink
|
||||||
menu.hoveredLink = hoveredUrl
|
|
||||||
menu.popup()
|
menu.popup()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
onClosed: {
|
onClosed: hoveredLink = ""
|
||||||
hoveredMedia = []
|
|
||||||
hoveredLink = ""
|
|
||||||
}
|
|
||||||
|
|
||||||
HMenuItem {
|
HMenuItem {
|
||||||
icon.name: "toggle-select-message"
|
icon.name: "toggle-select-message"
|
||||||
@ -74,38 +74,23 @@ HMenu {
|
|||||||
HMenuItem {
|
HMenuItem {
|
||||||
id: copyMedia
|
id: copyMedia
|
||||||
icon.name: "copy-link"
|
icon.name: "copy-link"
|
||||||
|
visible: menu.mediaType && ! menu.isEncryptedMedia
|
||||||
text:
|
text:
|
||||||
menu.hoveredMedia.length === 0 ||
|
! visible ? "" :
|
||||||
menu.isEncryptedMedia ?
|
menu.mediaType === Utils.Media.File ? qsTr("Copy file address") :
|
||||||
"" :
|
menu.mediaType === Utils.Media.Image ? qsTr("Copy image address") :
|
||||||
|
menu.mediaType === Utils.Media.Video ? qsTr("Copy video address") :
|
||||||
|
menu.mediaType === Utils.Media.Audio ? qsTr("Copy audio address") :
|
||||||
|
qsTr("Copy link address")
|
||||||
|
|
||||||
menu.hoveredMedia[0] === Utils.Media.File ?
|
onTriggered: Clipboard.text = event.media_http_url || menu.hoveredLink
|
||||||
qsTr("Copy file address") :
|
|
||||||
|
|
||||||
menu.hoveredMedia[0] === Utils.Media.Image ?
|
|
||||||
qsTr("Copy image address") :
|
|
||||||
|
|
||||||
menu.hoveredMedia[0] === Utils.Media.Video ?
|
|
||||||
qsTr("Copy video address") :
|
|
||||||
|
|
||||||
qsTr("Copy audio address")
|
|
||||||
|
|
||||||
visible: Boolean(text)
|
|
||||||
onTriggered: Clipboard.text = event.media_http_url // FIXME
|
|
||||||
}
|
|
||||||
|
|
||||||
HMenuItem {
|
|
||||||
icon.name: "copy-link"
|
|
||||||
text: qsTr("Copy link address")
|
|
||||||
visible: Boolean(menu.hoveredLink)
|
|
||||||
onTriggered: Clipboard.text = menu.hoveredLink
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HMenuItem {
|
HMenuItem {
|
||||||
icon.name: "copy-text"
|
icon.name: "copy-text"
|
||||||
text:
|
text:
|
||||||
eventList.selectedCount ? qsTr("Copy selection") :
|
eventList.selectedCount ? qsTr("Copy selection") :
|
||||||
menu.hoveredMedia.length > 0 ? qsTr("Copy filename") :
|
event.media_url ? qsTr("Copy filename") :
|
||||||
qsTr("Copy text")
|
qsTr("Copy text")
|
||||||
|
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
|
@ -10,8 +10,6 @@ import "../../../PythonBridge"
|
|||||||
HColumnLayout {
|
HColumnLayout {
|
||||||
id: eventDelegate
|
id: eventDelegate
|
||||||
|
|
||||||
property var hoveredMediaTypeUrl: [] // [] or [mediaType, url, title]
|
|
||||||
|
|
||||||
property var fetchProfilesFuture: null
|
property var fetchProfilesFuture: null
|
||||||
|
|
||||||
// Remember timeline goes from newest message at index 0 to oldest
|
// Remember timeline goes from newest message at index 0 to oldest
|
||||||
@ -32,11 +30,8 @@ HColumnLayout {
|
|||||||
eventList.canDayBreak(previousModel, model)
|
eventList.canDayBreak(previousModel, model)
|
||||||
|
|
||||||
readonly property int cursorShape:
|
readonly property int cursorShape:
|
||||||
eventContent.hoveredLink || hoveredMediaTypeUrl.length === 3 ?
|
eventContent.hoveredLink ? Qt.PointingHandCursor :
|
||||||
Qt.PointingHandCursor :
|
|
||||||
|
|
||||||
eventContent.hoveredSelectable ? Qt.IBeamCursor :
|
eventContent.hoveredSelectable ? Qt.IBeamCursor :
|
||||||
|
|
||||||
Qt.ArrowCursor
|
Qt.ArrowCursor
|
||||||
|
|
||||||
readonly property int separationSpacing:
|
readonly property int separationSpacing:
|
||||||
@ -57,10 +52,7 @@ HColumnLayout {
|
|||||||
|
|
||||||
function openContextMenu() {
|
function openContextMenu() {
|
||||||
eventList.contextMenu.spawn(
|
eventList.contextMenu.spawn(
|
||||||
model.index,
|
model.index, eventDelegate, eventContent.hoveredLink,
|
||||||
eventDelegate,
|
|
||||||
hoveredMediaTypeUrl,
|
|
||||||
eventContent.hoveredLink,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,16 +54,6 @@ HTile {
|
|||||||
|
|
||||||
Qt.openUrlExternally(loader.mediaUrl)
|
Qt.openUrlExternally(loader.mediaUrl)
|
||||||
|
|
||||||
onHoveredChanged: {
|
|
||||||
if (! hovered) {
|
|
||||||
eventDelegate.hoveredMediaTypeUrl = []
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
eventDelegate.hoveredMediaTypeUrl =
|
|
||||||
[Utils.Media.File, loader.mediaUrl, loader.title]
|
|
||||||
}
|
|
||||||
|
|
||||||
Binding on backgroundColor {
|
Binding on backgroundColor {
|
||||||
value: theme.chat.message.checkedBackground
|
value: theme.chat.message.checkedBackground
|
||||||
when: eventDelegate.checked
|
when: eventDelegate.checked
|
||||||
|
@ -42,6 +42,8 @@ HMxcImage {
|
|||||||
Math.max(maxHeight, theme.chat.message.thumbnailMinSize.height),
|
Math.max(maxHeight, theme.chat.message.thumbnailMinSize.height),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
readonly property bool hovered: hover.hovered
|
||||||
|
|
||||||
function openInternally() {
|
function openInternally() {
|
||||||
eventList.openImageViewer(
|
eventList.openImageViewer(
|
||||||
singleMediaInfo,
|
singleMediaInfo,
|
||||||
@ -118,15 +120,6 @@ HMxcImage {
|
|||||||
|
|
||||||
HoverHandler {
|
HoverHandler {
|
||||||
id: hover
|
id: hover
|
||||||
onHoveredChanged: {
|
|
||||||
if (! hovered) {
|
|
||||||
eventDelegate.hoveredMediaTypeUrl = []
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
eventDelegate.hoveredMediaTypeUrl =
|
|
||||||
[Utils.Media.Image, loader.mediaUrl, loader.title]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EventImageTextBubble {
|
EventImageTextBubble {
|
||||||
|
@ -28,9 +28,10 @@ HLoader {
|
|||||||
utils.getLinkType(mediaUrl)
|
utils.getLinkType(mediaUrl)
|
||||||
|
|
||||||
readonly property string cachedLocalPath: ""
|
readonly property string cachedLocalPath: ""
|
||||||
|
|
||||||
readonly property string thumbnailMxc: singleMediaInfo.thumbnail_url
|
readonly property string thumbnailMxc: singleMediaInfo.thumbnail_url
|
||||||
|
|
||||||
|
readonly property bool hovered: item ? item.hovered : false
|
||||||
|
|
||||||
|
|
||||||
visible: Boolean(item)
|
visible: Boolean(item)
|
||||||
x: eventContent.spacing
|
x: eventContent.spacing
|
||||||
|
@ -8,9 +8,7 @@ import "../../../Base"
|
|||||||
import "../../../Base/MediaPlayer"
|
import "../../../Base/MediaPlayer"
|
||||||
|
|
||||||
VideoPlayer {
|
VideoPlayer {
|
||||||
id: video
|
readonly property bool hovered: hover.hovered
|
||||||
|
|
||||||
onHoveredChanged:
|
HoverHandler { id: hover }
|
||||||
eventDelegate.hoveredMediaTypeUrl =
|
|
||||||
hovered ? [Utils.Media.Video, video.source, loader.title] : []
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user