linphone-desktop/linphone-app/ui/modules/Linphone/Notifications/NotificationReceivedFileMessage.qml
Julien Wadel d6f5a7f0ce Fix file transfert and notification behaviour
- Add External Image Provider to avoid having error message when we try to show a file that is not an image (used to show an attachment where it can be a regular file).
- When creating an image, try to read the headers of a file when the extension is not consistent with contents.
- Build if not exists, a thumbnail image if the file has been displayed when filling a message
- When trying to open the file, test if it was downloaded by reading the flag
- Add a status for File Transfert In Progress
- Use non-deprecated function to get file path from ChatMessage
- Use FileSize in addtion of content Size to get the full size of a message
- Show a progressbar when downloading a file
- Show the image in notification when downloaded or the file name if it is not an image
2020-05-05 00:35:55 +02:00

77 lines
2.2 KiB
QML

import QtQuick 2.7
import QtQuick.Layouts 1.3
import Common 1.0
import Linphone.Styles 1.0
import Utils 1.0
// =============================================================================
Notification {
id: notification
icon: 'file_sign'
overrodeHeight: NotificationReceivedFileMessageStyle.overrodeHeight
// ---------------------------------------------------------------------------
readonly property string fileUri: notificationData && notificationData.fileUri || ''
// ---------------------------------------------------------------------------
Loader {
active: Boolean(notification.fileUri)
anchors {
fill: parent
leftMargin: NotificationReceivedFileMessageStyle.leftMargin
rightMargin: NotificationReceivedFileMessageStyle.rightMargin
}
sourceComponent: RowLayout {
anchors.fill: parent
spacing: NotificationReceivedFileMessageStyle.spacing
Text {
Layout.fillWidth: true
color: NotificationReceivedFileMessageStyle.fileName.color
elide: Text.ElideRight
font.pointSize: NotificationReceivedFileMessageStyle.fileName.pointSize
text: Utils.basename(notification.fileUri)
visible:!image.visible
}
Image{
id:image
Layout.fillHeight: true
Layout.fillWidth: true
fillMode: Image.PreserveAspectFit
source: "image://external/"+notification.fileUri
visible: image.status == Image.Ready
}
Text {
Layout.preferredWidth: NotificationReceivedFileMessageStyle.fileSize.width
color: NotificationReceivedFileMessageStyle.fileSize.color
elide: Text.ElideRight
font.pointSize: NotificationReceivedFileMessageStyle.fileSize.pointSize
horizontalAlignment: Text.AlignRight
text: Utils.formatSize(notification.notificationData.fileSize)
}
}
MouseArea {
anchors.fill: parent
cursorShape: containsMouse ? Qt.PointingHandCursor : Qt.ArrowCursor
hoverEnabled: true
onClicked: notification._close(function () {
var uri = Utils.getUriFromSystemPath(notification.fileUri)
if (!Qt.openUrlExternally(uri)) {
Qt.openUrlExternally(Utils.dirname(uri))
}
})
}
}
}