parent
055ef7e8c3
commit
6e79bf6495
|
@ -1,4 +1,4 @@
|
||||||
QT += quick widgets
|
QT += quick widgets multimedia
|
||||||
CONFIG += c++14
|
CONFIG += c++14
|
||||||
CONFIG += object_parallel_to_source
|
CONFIG += object_parallel_to_source
|
||||||
CONFIG += qtquickcompiler
|
CONFIG += qtquickcompiler
|
||||||
|
|
|
@ -1,19 +1,54 @@
|
||||||
import QtQuick 2.9
|
import QtQuick 2.9
|
||||||
import QtQuick.Controls 2.2
|
import QtQuick.Controls 2.2
|
||||||
import QtMultimedia 5.8
|
import QtQuick.Controls.Material 2.2
|
||||||
|
import QtMultimedia 5.9
|
||||||
|
import Qt.labs.platform 1.0
|
||||||
|
|
||||||
AvatarContainer {
|
AvatarContainer {
|
||||||
Button {
|
readonly property var downloadAndOpen: downloadable.downloadAndOpen
|
||||||
id: downloadButton
|
readonly property var saveFileAs: downloadable.saveFileAs
|
||||||
|
|
||||||
text: content.body
|
property bool playOnFinished: false
|
||||||
highlighted: !sentByMe
|
|
||||||
flat: true
|
|
||||||
|
|
||||||
onClicked: downloadable.downloadAndOpen()
|
id: messageRow
|
||||||
|
|
||||||
Audio {
|
Audio {
|
||||||
audioRole: Audio.VoiceCommunicationRole
|
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")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
onDownloadedChanged: downloaded && playOnFinished ? audioPlayer.play() : {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,8 @@ AvatarContainer {
|
||||||
readonly property var downloadAndOpen: downloadable.downloadAndOpen
|
readonly property var downloadAndOpen: downloadable.downloadAndOpen
|
||||||
readonly property var saveFileAs: downloadable.saveFileAs
|
readonly property var saveFileAs: downloadable.saveFileAs
|
||||||
|
|
||||||
|
id: messageRow
|
||||||
|
|
||||||
DownloadableContent {
|
DownloadableContent {
|
||||||
id: downloadable
|
id: downloadable
|
||||||
|
|
||||||
|
|
|
@ -42,8 +42,9 @@ Item {
|
||||||
return "MessageBubble.qml"
|
return "MessageBubble.qml"
|
||||||
case "image":
|
case "image":
|
||||||
return "ImageBubble.qml"
|
return "ImageBubble.qml"
|
||||||
case "video":
|
|
||||||
case "audio":
|
case "audio":
|
||||||
|
return "AudioBubble.qml"
|
||||||
|
case "video":
|
||||||
case "file":
|
case "file":
|
||||||
return "FileBubble.qml"
|
return "FileBubble.qml"
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,22 +103,7 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
sorters: [
|
sorters: [
|
||||||
ExpressionSorter {
|
RoleSorter { roleName: "category" },
|
||||||
expression: {
|
|
||||||
var leftCategory = modelLeft.category
|
|
||||||
var rightCategory = modelRight.category
|
|
||||||
if (leftCategory === 1) return true
|
|
||||||
if (rightCategory === 1) return false
|
|
||||||
if (leftCategory === 2) return true
|
|
||||||
if (rightCategory === 2) return false
|
|
||||||
if (leftCategory === 5) return false
|
|
||||||
if (rightCategory === 5) return true
|
|
||||||
if (leftCategory === 4) return false
|
|
||||||
if (rightCategory === 4) return true
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
StringSorter { roleName: "name" }
|
StringSorter { roleName: "name" }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -519,6 +519,8 @@ QVariant MessageEventModel::data(const QModelIndex& idx, int role) const {
|
||||||
return "notice";
|
return "notice";
|
||||||
case MessageEventType::Image:
|
case MessageEventType::Image:
|
||||||
return "image";
|
return "image";
|
||||||
|
case MessageEventType::Audio:
|
||||||
|
return "audio";
|
||||||
default:
|
default:
|
||||||
return e->hasFileContent() ? "file" : "message";
|
return e->hasFileContent() ? "file" : "message";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue