Fix which EventImage url gets opened/copied
This commit is contained in:
parent
fc2fb605e3
commit
25ce08891d
|
@ -7,17 +7,7 @@ HImage {
|
||||||
onWidthChanged: Qt.callLater(update)
|
onWidthChanged: Qt.callLater(update)
|
||||||
onHeightChanged: Qt.callLater(update)
|
onHeightChanged: Qt.callLater(update)
|
||||||
onVisibleChanged: Qt.callLater(update)
|
onVisibleChanged: Qt.callLater(update)
|
||||||
onMxcChanged: {
|
onMxcChanged: Qt.callLater(update)
|
||||||
Qt.callLater(update)
|
|
||||||
|
|
||||||
if (isMxc) {
|
|
||||||
py.callCoro("mxc_to_http", [mxc], http => {
|
|
||||||
image.httpUrl = http || ""
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
httpUrl = mxc
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
property string mxc
|
property string mxc
|
||||||
|
@ -27,7 +17,6 @@ HImage {
|
||||||
|
|
||||||
property bool show: false
|
property bool show: false
|
||||||
property string cachedPath: ""
|
property string cachedPath: ""
|
||||||
property string httpUrl: ""
|
|
||||||
readonly property bool isMxc: mxc.startsWith("mxc://")
|
readonly property bool isMxc: mxc.startsWith("mxc://")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,6 @@ HMxcImage {
|
||||||
|
|
||||||
property EventMediaLoader loader
|
property EventMediaLoader loader
|
||||||
readonly property bool isEncrypted: ! Utils.isEmptyObject(cryptDict)
|
readonly property bool isEncrypted: ! Utils.isEmptyObject(cryptDict)
|
||||||
readonly property string openUrl: isEncrypted ? cachedPath : image.httpUrl
|
|
||||||
|
|
||||||
readonly property real maxHeight:
|
readonly property real maxHeight:
|
||||||
theme.chat.message.thumbnailMaxHeightRatio
|
theme.chat.message.thumbnailMaxHeightRatio
|
||||||
|
@ -48,16 +47,37 @@ HMxcImage {
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
function getOpenUrl(callback) {
|
||||||
|
if (image.isEncrypted) {
|
||||||
|
callback(image.cachedPath)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
let toOpen = loader.mediaUrl || loader.thumbnailMxc
|
||||||
|
let isMxc = toOpen.startsWith("mxc://")
|
||||||
|
|
||||||
|
isMxc ?
|
||||||
|
py.callCoro("mxc_to_http", [toOpen], callback) : callback(toOpen)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
TapHandler {
|
TapHandler {
|
||||||
onTapped: if (! image.animated) Qt.openUrlExternally(openUrl)
|
onTapped: if (! image.animated) getOpenUrl(Qt.openUrlExternally)
|
||||||
onDoubleTapped: Qt.openUrlExternally(openUrl)
|
onDoubleTapped: getOpenUrl(Qt.openUrlExternally)
|
||||||
}
|
}
|
||||||
|
|
||||||
HoverHandler {
|
HoverHandler {
|
||||||
id: hover
|
id: hover
|
||||||
onHoveredChanged:
|
onHoveredChanged: {
|
||||||
eventDelegate.hoveredMediaTypeUrl =
|
if (hovered) {
|
||||||
hovered ? [EventDelegate.Media.Image, openUrl] : []
|
getOpenUrl(url => {
|
||||||
|
eventDelegate.hoveredMediaTypeUrl =
|
||||||
|
[EventDelegate.Media.Image, url]
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
eventDelegate.hoveredMediaTypeUrl = []
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EventImageTextBubble {
|
EventImageTextBubble {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user