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:
@@ -5,6 +5,7 @@ import QtQuick
|
|||||||
import QtQuick.Controls as QQC2
|
import QtQuick.Controls as QQC2
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
|
|
||||||
|
import org.kde.coreaddons
|
||||||
import org.kde.kirigami as Kirigami
|
import org.kde.kirigami as Kirigami
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -13,13 +14,14 @@ import org.kde.kirigami as Kirigami
|
|||||||
RowLayout {
|
RowLayout {
|
||||||
property alias mimeIconSource: icon.source
|
property alias mimeIconSource: icon.source
|
||||||
property alias label: nameLabel.text
|
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
|
spacing: Kirigami.Units.largeSpacing
|
||||||
|
|
||||||
Kirigami.Icon {
|
Kirigami.Icon {
|
||||||
id: icon
|
id: icon
|
||||||
|
|
||||||
fallback: "unknown"
|
fallback: "unknown"
|
||||||
}
|
}
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
@@ -32,15 +34,21 @@ RowLayout {
|
|||||||
id: nameLabel
|
id: nameLabel
|
||||||
|
|
||||||
Layout.fillWidth: true
|
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
|
elide: Text.ElideRight
|
||||||
}
|
}
|
||||||
QQC2.Label {
|
QQC2.Label {
|
||||||
id: subLabel
|
id: caption
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|
||||||
|
text: (subLabel || size || duration || '') && [
|
||||||
|
subLabel,
|
||||||
|
size && Format.formatByteSize(size),
|
||||||
|
duration > 0 && Format.formatDuration(duration),
|
||||||
|
].filter(Boolean).join(" | ")
|
||||||
|
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
visible: text.length > 0
|
visible: text.length > 0
|
||||||
opacity: 0.7
|
opacity: 0.7
|
||||||
|
|||||||
@@ -71,11 +71,11 @@ DelegateChooser {
|
|||||||
delegate: MimeComponent {
|
delegate: MimeComponent {
|
||||||
required property string display
|
required property string display
|
||||||
required property var mediaInfo
|
required property var mediaInfo
|
||||||
required property int componentType
|
|
||||||
|
|
||||||
mimeIconSource: mediaInfo.mimeIcon
|
mimeIconSource: mediaInfo.mimeIcon
|
||||||
|
size: mediaInfo.size
|
||||||
|
duration: mediaInfo.duration
|
||||||
label: display
|
label: display
|
||||||
subLabel: componentType === MessageComponentType.File ? Format.formatByteSize(mediaInfo.size) : Format.formatDuration(mediaInfo.duration)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,11 +112,11 @@ DelegateChooser {
|
|||||||
delegate: MimeComponent {
|
delegate: MimeComponent {
|
||||||
required property string display
|
required property string display
|
||||||
required property var mediaInfo
|
required property var mediaInfo
|
||||||
required property int componentType
|
|
||||||
|
|
||||||
mimeIconSource: mediaInfo.mimeIcon
|
mimeIconSource: mediaInfo.mimeIcon
|
||||||
|
size: mediaInfo.size
|
||||||
|
duration: mediaInfo.duration
|
||||||
label: display
|
label: display
|
||||||
subLabel: componentType === MessageComponentType.File ? Format.formatByteSize(mediaInfo.size) : Format.formatDuration(mediaInfo.duration)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,11 +125,10 @@ DelegateChooser {
|
|||||||
delegate: MimeComponent {
|
delegate: MimeComponent {
|
||||||
required property string display
|
required property string display
|
||||||
required property var mediaInfo
|
required property var mediaInfo
|
||||||
required property int componentType
|
|
||||||
|
|
||||||
mimeIconSource: mediaInfo.mimeIcon
|
mimeIconSource: mediaInfo.mimeIcon
|
||||||
|
size: mediaInfo.size
|
||||||
label: display
|
label: display
|
||||||
subLabel: componentType === MessageComponentType.File ? Format.formatByteSize(mediaInfo.size) : Format.formatDuration(mediaInfo.duration)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,16 +142,17 @@ DelegateChooser {
|
|||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: MessageComponentType.Location
|
roleValue: MessageComponentType.Location
|
||||||
delegate: LocationComponent {
|
delegate: MimeComponent {
|
||||||
maxContentWidth: root.maxContentWidth
|
mimeIconSource: "mark-location"
|
||||||
|
label: display
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: MessageComponentType.LiveLocation
|
roleValue: MessageComponentType.LiveLocation
|
||||||
delegate: LiveLocationComponent {
|
delegate: MimeComponent {
|
||||||
room: root.room
|
mimeIconSource: "mark-location"
|
||||||
maxContentWidth: root.maxContentWidth
|
label: display
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user