Add bubbles on top of EventImage to show name-date

This commit is contained in:
miruka 2019-10-30 09:21:58 -04:00
parent 2e4a7904d5
commit ba527abedc
5 changed files with 54 additions and 22 deletions

10
TODO.md
View File

@ -6,19 +6,17 @@
- Bottom/top bar - Bottom/top bar
- Uploading (+local echo) - Uploading (+local echo)
- Deduplicate uploads - Deduplicate uploads
- File thumbnails + ask matrix API?
- Encrypted media - Encrypted media
- Loading animation - Loading progress bar
- GIF thumbnails: load the real animated image - Support m.file thumbnails
- EventLink
- GIFs can use the video player - GIFs can use the video player
- Display GIF static thumbnails while the real GIF is loading
- Video bug: when media is done playing, clicking on progress slider always - Video bug: when media is done playing, clicking on progress slider always
bring back to the beginning no matter where bring back to the beginning no matter where
- Video: missing buttons and small size problems - Video: missing buttons and small size problems
- Audio: online playback is buggy, must download+play file - Audio: online playback is buggy, must download+play file
- EventLink
- Combined pure media events time looks bad
- RoomMessageNotice - RoomMessageNotice

View File

@ -9,6 +9,12 @@ HRowLayout {
layoutDirection: onRight ? Qt.RightToLeft: Qt.LeftToRight layoutDirection: onRight ? Qt.RightToLeft: Qt.LeftToRight
readonly property string eventSender:
hideNameLine ? "" : (
"<div class='sender'>" +
Utils.coloredNameHtml(model.sender_name, model.sender_id) +
"</div>"
)
readonly property string eventText: Utils.processedEventText(model) readonly property string eventText: Utils.processedEventText(model)
readonly property string eventTime: Utils.formatTime(model.date, false) readonly property string eventTime: Utils.formatTime(model.date, false)
readonly property bool pureMedia: ! eventText && linksRepeater.count readonly property bool pureMedia: ! eventText && linksRepeater.count
@ -62,6 +68,7 @@ HRowLayout {
id: contentLabel id: contentLabel
container: selectableLabelContainer container: selectableLabelContainer
index: model.index index: model.index
visible: ! pureMedia
topPadding: theme.spacing / 1.75 topPadding: theme.spacing / 1.75
bottomPadding: topPadding bottomPadding: topPadding
@ -76,10 +83,7 @@ HRowLayout {
theme.chat.message.styleInclude + theme.chat.message.styleInclude +
// Sender name // Sender name
(hideNameLine ? "" : ( eventContent.eventSender +
"<div class='sender'>" +
Utils.coloredNameHtml(model.sender_name, model.sender_id) +
"</div>")) +
// Message body // Message body
eventContent.eventText + eventContent.eventText +
@ -142,6 +146,8 @@ HRowLayout {
EventMediaLoader { EventMediaLoader {
singleMediaInfo: eventDelegate.currentItem singleMediaInfo: eventDelegate.currentItem
mediaUrl: modelData mediaUrl: modelData
showSender: pureMedia ? eventSender : ""
showDate: pureMedia ? eventTime : ""
transform: Translate { x: xOffset } transform: Translate { x: xOffset }

View File

@ -6,13 +6,13 @@ HImage {
id: image id: image
horizontalAlignment: Image.AlignLeft horizontalAlignment: Image.AlignLeft
sourceSize.width: theme.chat.message.thumbnailWidth // FIXME sourceSize.width: theme.chat.message.thumbnailWidth // FIXME
source: animated ? openUrl : thumbnailUrl source: animated ? openUrl : loader.previewUrl
animated: loader.singleMediaInfo.media_mime === "image/gif" ||
Utils.urlExtension(loader.mediaUrl) === "gif"
property url thumbnailUrl property EventMediaLoader loader
property url fullImageUrl readonly property url openUrl: loader.mediaUrl || loader.previewUrl
readonly property url openUrl: fullImageUrl || thumbnailUrl
TapHandler { TapHandler {
@ -26,4 +26,17 @@ HImage {
eventDelegate.hoveredMediaTypeUrl = eventDelegate.hoveredMediaTypeUrl =
hovered ? [EventDelegate.Media.Image, openUrl] : [] hovered ? [EventDelegate.Media.Image, openUrl] : []
} }
EventImageTextBubble {
anchors.left: parent.left
anchors.top: parent.top
text: loader.showSender
textFormat: Text.StyledText
}
EventImageTextBubble {
anchors.right: parent.right
anchors.bottom: parent.bottom
text: loader.showDate
}
} }

View File

@ -0,0 +1,19 @@
import QtQuick 2.12
import "../../Base"
HLabel {
visible: Boolean(text)
anchors.margins: theme.spacing / 4
topPadding: theme.spacing / 2
bottomPadding: topPadding
leftPadding: theme.spacing / 1.5
rightPadding: leftPadding
font.pixelSize: theme.fontSize.small
background: Rectangle {
color: Qt.hsla(0, 0, 0, 0.7)
radius: theme.radius
}
}

View File

@ -9,6 +9,8 @@ HLoader {
property QtObject singleMediaInfo property QtObject singleMediaInfo
property url mediaUrl property url mediaUrl
property string showSender: ""
property string showDate: ""
readonly property var imageExtensions: [ readonly property var imageExtensions: [
"bmp", "gif", "jpg", "jpeg", "png", "pbm", "pgm", "ppm", "xbm", "xpm", "bmp", "gif", "jpg", "jpeg", "png", "pbm", "pgm", "ppm", "xbm", "xpm",
@ -55,12 +57,6 @@ HLoader {
onPreviewUrlChanged: { onPreviewUrlChanged: {
if (type === EventDelegate.Media.Image) { if (type === EventDelegate.Media.Image) {
var file = "EventImage.qml" var file = "EventImage.qml"
var props = {
thumbnailUrl: previewUrl,
fullImageUrl: mediaUrl,
animated: singleMediaInfo.media_mime === "image/gif" ||
Utils.urlExtension(mediaUrl) === "gif",
}
// } else if (type === EventDelegate.Media.File) { // } else if (type === EventDelegate.Media.File) {
// var file = "EventFile.qml" // var file = "EventFile.qml"
@ -81,6 +77,6 @@ HLoader {
} else { return } } else { return }
loader.setSource(file, props) loader.setSource(file, {loader})
} }
} }