Use video delegate for videos

There is still two issues:

* Videos send by neochat are broken (missing metadata)
* Once the video has run it is unavailable

Fix #120
This commit is contained in:
Carl Schwan
2020-12-04 10:35:03 +01:00
parent 5ee0ffa144
commit b90a027c99
2 changed files with 161 additions and 155 deletions

View File

@@ -13,27 +13,21 @@ import Qt.labs.platform 1.0 as Platform
import org.kde.kirigami 2.13 as Kirigami
import org.kde.neochat 1.0
import NeoChat.Setting 1.0
import NeoChat.Component 1.0
import NeoChat.Dialog 1.0
import NeoChat.Menu.Timeline 1.0
import NeoChat.Effect 1.0
import NeoChat.Font 1.0
RowLayout {
Video {
id: vid
property bool openOnFinished: false
property bool playOnFinished: false
readonly property bool downloaded: progressInfo && progressInfo.completed
property bool supportStreaming: true
id: root
spacing: 4
z: -5
onDownloadedChanged: {
if (downloaded) {
vid.source = progressInfo.localPath
@@ -49,14 +43,12 @@ RowLayout {
}
}
Video {
readonly property int maxWidth: 1000 // TODO messageListView.width
Layout.preferredWidth: content.info.w > maxWidth ? maxWidth : content.info.w
Layout.preferredHeight: content.info.w > maxWidth ? (content.info.h / content.info.w * maxWidth) : content.info.h
id: vid
loops: MediaPlayer.Infinite
fillMode: VideoOutput.PreserveAspectFit
@@ -81,15 +73,6 @@ RowLayout {
}
}
layer.enabled: true
layer.effect: OpacityMask {
maskSource: Rectangle {
width: vid.width
height: vid.height
radius: 18
}
}
Image {
readonly property bool isThumbnail: content.info.thumbnail_info && content.thumbnailMediaId
readonly property var info: isThumbnail ? content.info.thumbnail_info : content.info
@@ -103,7 +86,7 @@ RowLayout {
sourceSize.width: info.w
sourceSize.height: info.h
fillMode: Image.PreserveAspectCrop
fillMode: Image.PreserveAspectFit
}
Label {
@@ -117,7 +100,7 @@ RowLayout {
padding: 8
background: Rectangle {
radius: height / 2
radius: Kirigami.Units.smallSpacing
color: "black"
opacity: 0.3
}
@@ -171,7 +154,7 @@ RowLayout {
}
}
RippleEffect {
AutoMouseArea {
anchors.fill: parent
id: messageMouseArea
@@ -189,7 +172,7 @@ RowLayout {
}
onSecondaryClicked: {
var contextMenu = imageDelegateContextMenu.createObject(root)
var contextMenu = imageDelegateContextMenu.createObject(vid)
contextMenu.viewSource.connect(function() {
messageSourceSheet.createObject(ApplicationWindow.overlay, {"sourceText": toolTip}).open()
})
@@ -224,7 +207,6 @@ RowLayout {
FileDelegateContextMenu {}
}
}
}
function saveFileAs() {
var folderDialog = openFolderDialog.createObject(ApplicationWindow.overlay)

View File

@@ -343,6 +343,7 @@ Kirigami.ScrollablePage {
ReactionDelegate {
Layout.fillWidth: true
Layout.topMargin: 0
Layout.maximumHeight: 320
Layout.bottomMargin: 8
}
]
@@ -358,6 +359,16 @@ Kirigami.ScrollablePage {
innerObject: MessageDelegate {
Layout.fillWidth: true
onReplyClicked: goToEvent(eventID)
mouseArea: MouseArea {
acceptedButtons: (Kirigami.Settings.isMobile ? Qt.LeftButton : 0) | Qt.RightButton
anchors.fill: parent
onClicked: {
if (mouse.button == Qt.RightButton) {
openMessageContext(author, display, eventId, toolTip);
}
}
onPressAndHold: openMessageContext(author, display, eventId, toolTip);
}
onReplyToMessageClicked: replyToMessage(replyUser, replyContent, eventId);
innerObject: AudioDelegate {
@@ -375,10 +386,23 @@ Kirigami.ScrollablePage {
innerObject: MessageDelegate {
Layout.fillWidth: true
onReplyClicked: goToEvent(eventID)
mouseArea: MouseArea {
acceptedButtons: (Kirigami.Settings.isMobile ? Qt.LeftButton : 0) | Qt.RightButton
anchors.fill: parent
onClicked: {
if (mouse.button == Qt.RightButton) {
openMessageContext(author, display, eventId, toolTip);
}
}
onPressAndHold: openMessageContext(author, display, eventId, toolTip);
}
onReplyToMessageClicked: replyToMessage(replyUser, replyContent, eventId);
innerObject: AudioDelegate {
Layout.fillWidth: true
innerObject: VideoDelegate {
Layout.maximumWidth: parent.width
Layout.minimumWidth: 320
Layout.maximumHeight: 320
Layout.preferredHeight: content.info.h / content.info.w * width
}
}
}