[ChatTextInput] support more image formats and use icons for non-image attached files
This commit is contained in:
@@ -33,7 +33,10 @@ ToolBar {
|
|||||||
property int autoCompleteEndPosition
|
property int autoCompleteEndPosition
|
||||||
|
|
||||||
property bool hasAttachment: false
|
property bool hasAttachment: false
|
||||||
property url attachmentPath
|
property url attachmentPath: ""
|
||||||
|
property var attachmentMimetype: FileType.mimeTypeForUrl(attachmentPath)
|
||||||
|
property bool hasImageAttachment: hasAttachment && attachmentMimetype.valid
|
||||||
|
&& FileType.supportedImageFormats.includes(attachmentMimetype.preferredSuffix)
|
||||||
|
|
||||||
position: ToolBar.Footer
|
position: ToolBar.Footer
|
||||||
|
|
||||||
@@ -193,7 +196,7 @@ ToolBar {
|
|||||||
Image {
|
Image {
|
||||||
Layout.preferredHeight: Kirigami.Units.gridUnit * 10
|
Layout.preferredHeight: Kirigami.Units.gridUnit * 10
|
||||||
source: attachmentPath
|
source: attachmentPath
|
||||||
visible: hasAttachment && (attachmentPath.toString().endsWith('.png') || attachmentPath.toString().endsWith('.jpg'))
|
visible: hasImageAttachment
|
||||||
fillMode: Image.PreserveAspectFit
|
fillMode: Image.PreserveAspectFit
|
||||||
Layout.preferredWidth: paintedWidth
|
Layout.preferredWidth: paintedWidth
|
||||||
RowLayout {
|
RowLayout {
|
||||||
@@ -249,7 +252,7 @@ ToolBar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
visible: hasAttachment && !(attachmentPath.toString().endsWith('.png') || attachmentPath.toString().endsWith('.jpg'))
|
visible: hasAttachment && !hasImageAttachment
|
||||||
ToolButton {
|
ToolButton {
|
||||||
icon.name: "dialog-cancel"
|
icon.name: "dialog-cancel"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
@@ -258,7 +261,15 @@ ToolBar {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Kirigami.Icon {
|
||||||
|
id: mimetypeIcon
|
||||||
|
implicitHeight: Kirigami.Units.fontMetrics.roundedIconSize(horizontalFileLabel.implicitHeight)
|
||||||
|
implicitWidth: implicitHeight
|
||||||
|
source: attachmentMimetype.iconName
|
||||||
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
|
id: horizontalFileLabel
|
||||||
Layout.alignment: Qt.AlignVCenter
|
Layout.alignment: Qt.AlignVCenter
|
||||||
text: attachmentPath !== "" ? attachmentPath.toString().substring(attachmentPath.toString().lastIndexOf('/') + 1, attachmentPath.length) : ""
|
text: attachmentPath !== "" ? attachmentPath.toString().substring(attachmentPath.toString().lastIndexOf('/') + 1, attachmentPath.length) : ""
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user