Refactor MimeComponent

- Fix size and duration not showing in MimeComponents in replies
- Display Itinerary in replies as MimeComponent (in consistency with media
  components)
This commit is contained in:
Andreas Gattringer
2024-07-15 10:53:28 +02:00
parent 95e1bee5e6
commit 0fd578e6aa
2 changed files with 24 additions and 16 deletions

View File

@@ -5,6 +5,7 @@ import QtQuick
import QtQuick.Controls as QQC2
import QtQuick.Layouts
import org.kde.coreaddons
import org.kde.kirigami as Kirigami
/**
@@ -13,13 +14,14 @@ import org.kde.kirigami as Kirigami
RowLayout {
property alias mimeIconSource: icon.source
property alias label: nameLabel.text
property alias subLabel: subLabel.text
property string subLabel: ""
property int size: 0
property int duration: 0
spacing: Kirigami.Units.largeSpacing
Kirigami.Icon {
id: icon
fallback: "unknown"
}
ColumnLayout {
@@ -32,15 +34,21 @@ RowLayout {
id: nameLabel
Layout.fillWidth: true
Layout.alignment: subLabel.visible ? Qt.AlignLeft | Qt.AlignBottom : Qt.AlignLeft | Qt.AlignVCenter
Layout.alignment: caption.visible ? Qt.AlignLeft | Qt.AlignBottom : Qt.AlignLeft | Qt.AlignVCenter
elide: Text.ElideRight
}
QQC2.Label {
id: subLabel
id: caption
Layout.fillWidth: true
text: (subLabel || size || duration || '') && [
subLabel,
size && Format.formatByteSize(size),
duration > 0 && Format.formatDuration(duration),
].filter(Boolean).join(" | ")
elide: Text.ElideRight
visible: text.length > 0
opacity: 0.7

View File

@@ -71,11 +71,11 @@ DelegateChooser {
delegate: MimeComponent {
required property string display
required property var mediaInfo
required property int componentType
mimeIconSource: mediaInfo.mimeIcon
size: mediaInfo.size
duration: mediaInfo.duration
label: display
subLabel: componentType === MessageComponentType.File ? Format.formatByteSize(mediaInfo.size) : Format.formatDuration(mediaInfo.duration)
}
}
@@ -112,11 +112,11 @@ DelegateChooser {
delegate: MimeComponent {
required property string display
required property var mediaInfo
required property int componentType
mimeIconSource: mediaInfo.mimeIcon
size: mediaInfo.size
duration: mediaInfo.duration
label: display
subLabel: componentType === MessageComponentType.File ? Format.formatByteSize(mediaInfo.size) : Format.formatDuration(mediaInfo.duration)
}
}
@@ -125,11 +125,10 @@ DelegateChooser {
delegate: MimeComponent {
required property string display
required property var mediaInfo
required property int componentType
mimeIconSource: mediaInfo.mimeIcon
size: mediaInfo.size
label: display
subLabel: componentType === MessageComponentType.File ? Format.formatByteSize(mediaInfo.size) : Format.formatDuration(mediaInfo.duration)
}
}
@@ -143,16 +142,17 @@ DelegateChooser {
DelegateChoice {
roleValue: MessageComponentType.Location
delegate: LocationComponent {
maxContentWidth: root.maxContentWidth
delegate: MimeComponent {
mimeIconSource: "mark-location"
label: display
}
}
DelegateChoice {
roleValue: MessageComponentType.LiveLocation
delegate: LiveLocationComponent {
room: root.room
maxContentWidth: root.maxContentWidth
delegate: MimeComponent {
mimeIconSource: "mark-location"
label: display
}
}