space-saving metadata placement

This commit is contained in:
Malte E 2022-02-14 21:07:03 +01:00
parent 1df1b5037e
commit 6f3ed5b282
7 changed files with 31 additions and 10 deletions

View File

@ -80,7 +80,7 @@ Item {
anchors.left: bubbleOnRight? undefined : parent.left anchors.left: bubbleOnRight? undefined : parent.left
anchors.right: bubbleOnRight? parent.right : undefined anchors.right: bubbleOnRight? parent.right : undefined
property int maxWidth: parent.width-anchors.leftMargin-anchors.rightMargin property int maxWidth: parent.width-anchors.leftMargin-anchors.rightMargin
width: Settings.bubbles? Math.min(maxWidth,implicitWidth+4) : maxWidth width: Settings.bubbles? Math.min(maxWidth,implicitWidth+metadata.width+12) : maxWidth
leftPadding: 4 leftPadding: 4
rightPadding: (Settings.bubbles && !isStateEvent)? 4: 2 rightPadding: (Settings.bubbles && !isStateEvent)? 4: 2
topPadding: (Settings.bubbles && !isStateEvent)? 4: 2 topPadding: (Settings.bubbles && !isStateEvent)? 4: 2
@ -107,7 +107,6 @@ Item {
Layout.fillWidth: true Layout.fillWidth: true
Layout.bottomMargin: visible? 2 : 0 Layout.bottomMargin: visible? 2 : 0
Layout.preferredHeight: height Layout.preferredHeight: height
Layout.maximumWidth: implicitWidth
id: reply id: reply
function fromModel(role) { function fromModel(role) {
@ -144,7 +143,6 @@ Item {
Layout.column: 0 Layout.column: 0
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: height Layout.preferredHeight: height
Layout.maximumWidth: implicitWidth
id: contentItem id: contentItem
blurhash: r.blurhash blurhash: r.blurhash
@ -169,6 +167,7 @@ Item {
encryptionError: r.encryptionError encryptionError: r.encryptionError
relatedEventCacheBuster: r.relatedEventCacheBuster relatedEventCacheBuster: r.relatedEventCacheBuster
isReply: false isReply: false
metadataWidth: metadata.width
} }
RowLayout { RowLayout {
@ -177,6 +176,7 @@ Item {
Layout.row: Settings.bubbles? 2 : 0 Layout.row: Settings.bubbles? 2 : 0
Layout.rowSpan: Settings.bubbles? 1 : 2 Layout.rowSpan: Settings.bubbles? 1 : 2
Layout.bottomMargin: -2 Layout.bottomMargin: -2
Layout.topMargin: contentItem.fitsMetadata? -height-Layout.bottomMargin : 0
Layout.alignment: Qt.AlignTop | Qt.AlignRight Layout.alignment: Qt.AlignTop | Qt.AlignRight
Layout.preferredWidth: implicitWidth Layout.preferredWidth: implicitWidth
visible: !isStateEvent visible: !isStateEvent

View File

@ -12,15 +12,17 @@ Item {
required property string filename required property string filename
required property string filesize required property string filesize
height: row.height + 24 height: row.height + (Settings.bubbles? 16: 24)
width: parent.width width: parent.width
implicitWidth: row.implicitWidth implicitWidth: row.implicitWidth+metadataWidth
property int metadataWidth
property bool fitsMetadata: true
RowLayout { RowLayout {
id: row id: row
anchors.centerIn: parent anchors.centerIn: parent
width: parent.width - 24 width: parent.width - (Settings.bubbles? 16 : 24)
spacing: 15 spacing: 15
Rectangle { Rectangle {
@ -88,6 +90,7 @@ Item {
z: -1 z: -1
radius: 10 radius: 10
anchors.fill: parent anchors.fill: parent
visible: !Settings.bubbles // the bubble in a bubble looks odd
} }
} }

View File

@ -20,9 +20,12 @@ Item {
property double divisor: isReply ? 5 : 3 property double divisor: isReply ? 5 : 3
implicitWidth: Math.round(originalWidth*Math.min((timelineView.height/divisor)/(originalWidth*proportionalHeight), 1)) implicitWidth: Math.round(originalWidth*Math.min((timelineView.height/divisor)/(originalWidth*proportionalHeight), 1))
width: parent.width width: Math.min(parent.width,implicitWidth)
height: width*proportionalHeight height: width*proportionalHeight
property int metadataWidth
property bool fitsMetadata: (parent.width - width) > metadataWidth+4
Image { Image {
id: blurhash_ id: blurhash_

View File

@ -35,6 +35,8 @@ Item {
required property string callType required property string callType
required property int encryptionError required property int encryptionError
required property int relatedEventCacheBuster required property int relatedEventCacheBuster
property bool fitsMetadata: (chooser.child && chooser.child.fitsMetadata) ? chooser.child.fitsMetadata : false
property int metadataWidth
height: chooser.child ? chooser.child.height : Nheko.paddingLarge height: chooser.child ? chooser.child.height : Nheko.paddingLarge
@ -65,6 +67,7 @@ Item {
body: d.body body: d.body
isOnlyEmoji: d.isOnlyEmoji isOnlyEmoji: d.isOnlyEmoji
isReply: d.isReply isReply: d.isReply
metadataWidth: d.metadataWidth
} }
} }
@ -109,6 +112,7 @@ Item {
filename: d.filename filename: d.filename
isReply: d.isReply isReply: d.isReply
eventId: d.eventId eventId: d.eventId
metadataWidth: d.metadataWidth
} }
} }
@ -126,6 +130,7 @@ Item {
filename: d.filename filename: d.filename
isReply: d.isReply isReply: d.isReply
eventId: d.eventId eventId: d.eventId
metadataWidth: d.metadataWidth
} }
} }
@ -137,6 +142,7 @@ Item {
eventId: d.eventId eventId: d.eventId
filename: d.filename filename: d.filename
filesize: d.filesize filesize: d.filesize
metadataWidth: d.metadataWidth
} }
} }
@ -153,6 +159,7 @@ Item {
url: d.url url: d.url
body: d.body body: d.body
filesize: d.filesize filesize: d.filesize
metadataWidth: d.metadataWidth
} }
} }
@ -169,6 +176,7 @@ Item {
url: d.url url: d.url
body: d.body body: d.body
filesize: d.filesize filesize: d.filesize
metadataWidth: d.metadataWidth
} }
} }
@ -177,7 +185,7 @@ Item {
roleValue: MtxEvent.Redacted roleValue: MtxEvent.Redacted
Redacted { Redacted {
//delegateWidth: d.width metadataWidth: d.metadataWidth
} }
} }

View File

@ -25,10 +25,13 @@ Item {
property double divisor: isReply ? 4 : 2 property double divisor: isReply ? 4 : 2
property int tempWidth: originalWidth < 1? 400: originalWidth property int tempWidth: originalWidth < 1? 400: originalWidth
implicitWidth: type == MtxEvent.VideoMessage ? Math.round(tempWidth*Math.min((timelineView.height/divisor)/(tempWidth*proportionalHeight), 1)) : 500 implicitWidth: type == MtxEvent.VideoMessage ? Math.round(tempWidth*Math.min((timelineView.height/divisor)/(tempWidth*proportionalHeight), 1)) : 500
width: parent.width width: Math.min(parent.width, implicitWidth)
height: (type == MtxEvent.VideoMessage ? width*proportionalHeight : 80) + fileInfoLabel.height height: (type == MtxEvent.VideoMessage ? width*proportionalHeight : 80) + fileInfoLabel.height
implicitHeight: height implicitHeight: height
property int metadataWidth
property bool fitsMetadata: (parent.width - fileInfoLabel.width) > metadataWidth+4
MxcMedia { MxcMedia {
id: mxcmedia id: mxcmedia

View File

@ -12,9 +12,11 @@ Rectangle{
height: redactedLayout.implicitHeight + Nheko.paddingSmall height: redactedLayout.implicitHeight + Nheko.paddingSmall
implicitWidth: redactedLayout.implicitWidth + 2 * Nheko.paddingMedium implicitWidth: redactedLayout.implicitWidth + 2 * Nheko.paddingMedium
width: parent.width width: Math.min(parent.width,implicitWidth+1)
radius: fontMetrics.lineSpacing / 2 + 2 * Nheko.paddingSmall radius: fontMetrics.lineSpacing / 2 + 2 * Nheko.paddingSmall
color: Nheko.colors.alternateBase color: Nheko.colors.alternateBase
property int metadataWidth
property bool fitsMetadata: parent.width - redactedLayout.width > metadataWidth + 4
RowLayout { RowLayout {
id: redactedLayout id: redactedLayout

View File

@ -13,6 +13,8 @@ MatrixText {
required property bool isReply required property bool isReply
required property string formatted required property string formatted
property string copyText: selectedText ? getText(selectionStart, selectionEnd) : body property string copyText: selectedText ? getText(selectionStart, selectionEnd) : body
property int metadataWidth
property bool fitsMetadata: positionAt(width,height-4) == positionAt(width-metadataWidth-10, height-4)
// table border-collapse doesn't seem to work // table border-collapse doesn't seem to work
text: " text: "