2018-07-16 14:05:34 +00:00
|
|
|
import QtQuick 2.9
|
|
|
|
import QtQuick.Controls 2.2
|
2018-08-17 07:58:08 +00:00
|
|
|
import QtQuick.Controls.Material 2.2
|
|
|
|
import QtMultimedia 5.9
|
|
|
|
import Qt.labs.platform 1.0
|
2018-07-16 14:05:34 +00:00
|
|
|
|
|
|
|
AvatarContainer {
|
2018-08-17 07:58:08 +00:00
|
|
|
readonly property var downloadAndOpen: downloadable.downloadAndOpen
|
|
|
|
readonly property var saveFileAs: downloadable.saveFileAs
|
2018-07-16 14:05:34 +00:00
|
|
|
|
2018-08-17 07:58:08 +00:00
|
|
|
property bool playOnFinished: false
|
2018-07-16 14:05:34 +00:00
|
|
|
|
2018-08-17 07:58:08 +00:00
|
|
|
id: messageRow
|
2018-07-16 14:05:34 +00:00
|
|
|
|
2018-08-17 07:58:08 +00:00
|
|
|
Audio {
|
|
|
|
id: audioPlayer
|
|
|
|
source: progressInfo.localPath
|
|
|
|
}
|
|
|
|
|
|
|
|
DownloadableContent {
|
|
|
|
id: downloadable
|
|
|
|
|
|
|
|
width: downloadDelegate.width
|
|
|
|
height: downloadDelegate.height
|
|
|
|
|
|
|
|
TextDelegate {
|
|
|
|
id: downloadDelegate
|
|
|
|
|
|
|
|
maximumWidth: messageListView.width
|
|
|
|
highlighted: !sentByMe
|
|
|
|
timeLabelVisible: false
|
|
|
|
authorLabelVisible: messageRow.avatarVisible
|
|
|
|
|
|
|
|
displayText: content.info.duration / 1000 + '"'
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
propagateComposedEvents: true
|
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
if (downloadable.downloaded)
|
|
|
|
audioPlayer.play()
|
|
|
|
else
|
|
|
|
{
|
|
|
|
playOnFinished = true
|
|
|
|
currentRoom.downloadFile(eventId, StandardPaths.writableLocation(StandardPaths.CacheLocation) + "/" + eventId.replace(":", "_") + ".tmp")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-07-16 14:05:34 +00:00
|
|
|
}
|
2018-08-17 07:58:08 +00:00
|
|
|
onDownloadedChanged: downloaded && playOnFinished ? audioPlayer.play() : {}
|
2018-07-16 14:05:34 +00:00
|
|
|
}
|
|
|
|
}
|