moment/src/qml/Chat/Timeline/EventFile.qml
miruka 026c049d62 Improve message delegate code, fix multiple issues
- Fix the ListView not auto-scrolling like it should when message
  delegates changed height, such as when images were loaded

- Fix messed up delegate positions overlapping each others when
  movements happen

- Fix previous/nextItem binding broken due to imperative modification

- Fix "messageBodyWidth" binding loop
2019-12-17 03:45:00 -04:00

44 lines
1.2 KiB
QML

import QtQuick 2.12
import QtQuick.Layouts 1.12
import "../../Base"
import "../../utils.js" as Utils
HTile {
id: file
width: Math.min(
eventDelegate.width,
eventContent.maxMessageWidth,
Math.max(theme.chat.message.fileMinWidth, implicitWidth),
)
height: Math.max(theme.chat.message.avatarSize, implicitHeight)
title.text: loader.singleMediaInfo.media_title || qsTr("Untitled file")
title.elide: Text.ElideMiddle
subtitle.text: CppUtils.formattedBytes(loader.singleMediaInfo.media_size)
image: HIcon {
svgName: "download"
}
onLeftClicked: download(Qt.openUrlExternally)
onRightClicked: eventDelegate.openContextMenu()
onHoveredChanged: {
if (! hovered) {
eventDelegate.hoveredMediaTypeUrl = []
return
}
eventDelegate.hoveredMediaTypeUrl = [
EventDelegate.Media.File,
loader.downloadedPath.replace(/^file:\/\//, "") || loader.mediaUrl
]
}
property EventMediaLoader loader
readonly property bool cryptDict: loader.singleMediaInfo.media_crypt_dict
readonly property bool isEncrypted: ! Utils.isEmptyObject(cryptDict)
}