2020-09-23 19:57:54 -04:00
|
|
|
// Copyright Mirage authors & contributors <https://github.com/mirukana/mirage>
|
2019-12-19 07:46:16 -04:00
|
|
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
|
|
|
2019-09-14 17:48:53 -04:00
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Layouts 1.12
|
2019-12-27 08:58:24 -04:00
|
|
|
import CppUtils 0.1
|
2020-07-19 20:10:31 -04:00
|
|
|
import "../../.."
|
2019-12-18 04:53:08 -04:00
|
|
|
import "../../../Base"
|
2020-03-30 15:03:35 -04:00
|
|
|
import "../../../Base/HTile"
|
2019-09-14 17:48:53 -04:00
|
|
|
|
|
|
|
HTile {
|
2019-12-16 18:05:09 -04:00
|
|
|
id: file
|
2020-07-12 00:25:57 -04:00
|
|
|
|
|
|
|
property EventMediaLoader loader
|
|
|
|
|
|
|
|
|
2019-12-17 03:45:00 -04:00
|
|
|
width: Math.min(
|
|
|
|
eventDelegate.width,
|
|
|
|
eventContent.maxMessageWidth,
|
|
|
|
Math.max(theme.chat.message.fileMinWidth, implicitWidth),
|
2019-11-11 05:34:46 -04:00
|
|
|
)
|
2019-12-16 18:28:51 -04:00
|
|
|
height: Math.max(theme.chat.message.avatarSize, implicitHeight)
|
2019-11-11 05:34:46 -04:00
|
|
|
|
2020-03-30 15:03:35 -04:00
|
|
|
contentItem: ContentRow {
|
|
|
|
tile: file
|
2019-09-14 17:48:53 -04:00
|
|
|
|
2020-03-30 15:03:35 -04: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-14 17:48:53 -04:00
|
|
|
}
|
2019-12-16 18:05:09 -04:00
|
|
|
|
2020-07-19 20:21:26 -04:00
|
|
|
onMiddleClicked: leftClicked()
|
2019-12-16 18:05:09 -04:00
|
|
|
onRightClicked: eventDelegate.openContextMenu()
|
2020-03-25 23:06:51 -04:00
|
|
|
onLeftClicked:
|
|
|
|
eventList.selectedCount ?
|
2020-07-19 20:10:31 -04:00
|
|
|
eventDelegate.toggleChecked() :
|
|
|
|
|
|
|
|
loader.isMedia ?
|
|
|
|
eventList.openMediaExternally(singleMediaInfo) :
|
|
|
|
|
|
|
|
Qt.openUrlExternally(loader.mediaUrl)
|
2019-12-16 18:05:09 -04:00
|
|
|
|
2020-03-25 23:06:51 -04:00
|
|
|
Binding on backgroundColor {
|
2020-03-26 21:01:36 -04:00
|
|
|
value: theme.chat.message.checkedBackground
|
2020-03-25 23:06:51 -04:00
|
|
|
when: eventDelegate.checked
|
|
|
|
}
|
2020-03-26 21:01:36 -04:00
|
|
|
|
|
|
|
Behavior on backgroundColor { HColorAnimation {} }
|
2019-09-14 17:48:53 -04:00
|
|
|
}
|