moment/src/gui/Pages/Chat/Timeline/EventFile.qml
miruka ad937573cf Rewrite HTile and adapt components using it
Rewrite HTile in a more standard way, hopefully fixing the
mysterious segfault on some systems
2020-04-03 07:53:36 -04:00

74 lines
1.8 KiB
QML

// SPDX-License-Identifier: LGPL-3.0-or-later
import QtQuick 2.12
import QtQuick.Layouts 1.12
import CppUtils 0.1
import "../../../Base"
import "../../../Base/HTile"
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)
contentItem: ContentRow {
tile: file
HIcon {
svgName: "download"
}
HColumnLayout {
TitleLabel {
elide: Text.ElideMiddle
text: loader.singleMediaInfo.media_title ||
qsTr("Untitled file")
}
SubtitleLabel {
tile: file
text: CppUtils.formattedBytes(
loader.singleMediaInfo.media_size,
)
}
}
}
onRightClicked: eventDelegate.openContextMenu()
onLeftClicked:
eventList.selectedCount ?
eventDelegate.toggleChecked() : download(Qt.openUrlExternally)
onHoveredChanged: {
if (! hovered) {
eventDelegate.hoveredMediaTypeUrl = []
return
}
eventDelegate.hoveredMediaTypeUrl = [
EventDelegate.Media.File,
loader.downloadedPath.replace(/^file:\/\//, "") || loader.mediaUrl
]
}
property EventMediaLoader loader
readonly property bool cryptDict:
JSON.parse(loader.singleMediaInfo.media_crypt_dict)
readonly property bool isEncrypted: ! utils.isEmptyObject(cryptDict)
Binding on backgroundColor {
value: theme.chat.message.checkedBackground
when: eventDelegate.checked
}
Behavior on backgroundColor { HColorAnimation {} }
}