2019-12-19 22:46:16 +11:00
|
|
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
|
|
|
2019-09-15 07:48:53 +10:00
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Layouts 1.12
|
2019-12-27 23:58:24 +11:00
|
|
|
import CppUtils 0.1
|
2019-12-18 19:53:08 +11:00
|
|
|
import "../../../Base"
|
2020-03-31 06:03:35 +11:00
|
|
|
import "../../../Base/HTile"
|
2019-09-15 07:48:53 +10:00
|
|
|
|
|
|
|
HTile {
|
2019-12-17 09:05:09 +11:00
|
|
|
id: file
|
2019-12-17 18:45:00 +11:00
|
|
|
width: Math.min(
|
|
|
|
eventDelegate.width,
|
|
|
|
eventContent.maxMessageWidth,
|
|
|
|
Math.max(theme.chat.message.fileMinWidth, implicitWidth),
|
2019-11-11 20:34:46 +11:00
|
|
|
)
|
2019-12-17 09:28:51 +11:00
|
|
|
height: Math.max(theme.chat.message.avatarSize, implicitHeight)
|
2019-11-11 20:34:46 +11:00
|
|
|
|
2020-03-31 06:03:35 +11:00
|
|
|
contentItem: ContentRow {
|
|
|
|
tile: file
|
2019-09-15 07:48:53 +10:00
|
|
|
|
2020-03-31 06:03:35 +11:00
|
|
|
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,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
2019-09-15 07:48:53 +10:00
|
|
|
}
|
2019-12-17 09:05:09 +11:00
|
|
|
|
|
|
|
onRightClicked: eventDelegate.openContextMenu()
|
2020-03-26 14:06:51 +11:00
|
|
|
onLeftClicked:
|
|
|
|
eventList.selectedCount ?
|
|
|
|
eventDelegate.toggleChecked() : download(Qt.openUrlExternally)
|
2019-12-17 09:05:09 +11:00
|
|
|
|
|
|
|
onHoveredChanged: {
|
|
|
|
if (! hovered) {
|
|
|
|
eventDelegate.hoveredMediaTypeUrl = []
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
eventDelegate.hoveredMediaTypeUrl = [
|
|
|
|
EventDelegate.Media.File,
|
2019-12-17 09:22:25 +11:00
|
|
|
loader.downloadedPath.replace(/^file:\/\//, "") || loader.mediaUrl
|
2019-12-17 09:05:09 +11:00
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
property EventMediaLoader loader
|
|
|
|
|
2020-02-13 04:04:46 +11:00
|
|
|
readonly property bool cryptDict:
|
|
|
|
JSON.parse(loader.singleMediaInfo.media_crypt_dict)
|
|
|
|
|
2019-12-18 08:59:53 +11:00
|
|
|
readonly property bool isEncrypted: ! utils.isEmptyObject(cryptDict)
|
2020-03-26 14:06:51 +11:00
|
|
|
|
|
|
|
|
|
|
|
Binding on backgroundColor {
|
2020-03-27 12:01:36 +11:00
|
|
|
value: theme.chat.message.checkedBackground
|
2020-03-26 14:06:51 +11:00
|
|
|
when: eventDelegate.checked
|
|
|
|
}
|
2020-03-27 12:01:36 +11:00
|
|
|
|
|
|
|
Behavior on backgroundColor { HColorAnimation {} }
|
2019-09-15 07:48:53 +10:00
|
|
|
}
|