2019-09-03 03:04:57 -04:00
|
|
|
import QtQuick 2.12
|
|
|
|
import "../../Base"
|
2019-09-19 15:49:29 -04:00
|
|
|
import "../../utils.js" as Utils
|
2019-09-03 03:04:57 -04:00
|
|
|
|
|
|
|
HImage {
|
|
|
|
id: image
|
2019-09-06 17:46:48 -04:00
|
|
|
sourceSize.width: theme.chat.message.thumbnailWidth
|
|
|
|
sourceSize.height: theme.chat.message.thumbnailWidth
|
2019-09-19 15:49:29 -04:00
|
|
|
width: fitSize.width
|
|
|
|
height: fitSize.height
|
|
|
|
|
|
|
|
// Leaving PreserveAspectFit creates a binding loop, and is uneeded
|
|
|
|
// since we calculate ourself the right size.
|
|
|
|
fillMode: Image.Pad
|
2019-09-03 03:04:57 -04:00
|
|
|
|
2019-09-14 01:03:56 -04:00
|
|
|
|
|
|
|
// source = thumbnail, fullSource = full original image
|
|
|
|
property url fullSource: source
|
|
|
|
|
2019-09-19 15:49:29 -04:00
|
|
|
readonly property size fitSize: Utils.fitSize(
|
|
|
|
implicitWidth, implicitHeight, theme.chat.message.thumbnailWidth,
|
|
|
|
)
|
|
|
|
|
2019-09-14 01:03:56 -04:00
|
|
|
|
2019-09-03 03:04:57 -04:00
|
|
|
TapHandler {
|
2019-09-14 18:33:32 -04:00
|
|
|
onTapped: if (! image.animated) Qt.openUrlExternally(fullSource)
|
|
|
|
onDoubleTapped: Qt.openUrlExternally(fullSource)
|
2019-09-03 03:04:57 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
HoverHandler {
|
|
|
|
id: hover
|
2019-09-06 17:21:41 -04:00
|
|
|
onHoveredChanged:
|
2019-09-14 18:33:32 -04:00
|
|
|
eventDelegate.hoveredMediaTypeUrl =
|
|
|
|
hovered ? [EventDelegate.Media.Image, fullSource] : []
|
2019-09-03 03:04:57 -04:00
|
|
|
}
|
|
|
|
}
|