2020-08-28 12:43:51 +03:00
|
|
|
/*
|
2020-10-19 20:34:47 +03:00
|
|
|
Copyright (C) 2020 Sebastian J. Wolf and other contributors
|
2020-08-28 12:43:51 +03:00
|
|
|
|
|
|
|
This file is part of Fernschreiber.
|
|
|
|
|
|
|
|
Fernschreiber is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Fernschreiber is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Fernschreiber. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2020-10-31 22:49:03 +03:00
|
|
|
import QtQuick 2.6
|
2020-08-28 12:43:51 +03:00
|
|
|
import Sailfish.Silica 1.0
|
2020-10-31 22:50:32 +03:00
|
|
|
import QtMultimedia 5.6
|
2020-08-28 12:43:51 +03:00
|
|
|
import "../components"
|
2021-02-04 01:12:24 +03:00
|
|
|
import "../components/messageContent"
|
2020-08-28 12:43:51 +03:00
|
|
|
import "../js/functions.js" as Functions
|
2021-02-04 01:12:24 +03:00
|
|
|
import "../js/debug.js" as Debug
|
2020-08-28 12:43:51 +03:00
|
|
|
|
|
|
|
Page {
|
|
|
|
id: videoPage
|
|
|
|
allowedOrientations: Orientation.All
|
|
|
|
|
2020-11-06 01:23:37 +03:00
|
|
|
property var videoData;
|
2021-02-04 01:12:24 +03:00
|
|
|
property alias videoType: myVideoComponent.videoType
|
|
|
|
property alias isVideoNote: myVideoComponent.isVideoNote
|
|
|
|
property var sourceMessage;
|
2020-08-28 12:43:51 +03:00
|
|
|
|
|
|
|
property int videoWidth : videoData.width
|
|
|
|
property int videoHeight : videoData.height
|
|
|
|
property string videoUrl;
|
|
|
|
|
|
|
|
property real imageSizeFactor : videoWidth / videoHeight;
|
|
|
|
property real screenSizeFactor: videoPage.width / videoPage.height;
|
|
|
|
property real sizingFactor : imageSizeFactor >= screenSizeFactor ? videoPage.width / videoWidth : videoPage.height / videoHeight;
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
updateVideoData();
|
|
|
|
}
|
|
|
|
|
|
|
|
function updateVideoData() {
|
|
|
|
if (typeof videoData === "object") {
|
2021-02-04 01:12:24 +03:00
|
|
|
if (videoData[videoType].local.is_downloading_completed) {
|
|
|
|
videoPage.videoUrl = videoData[videoType].local.path;
|
2020-08-28 12:43:51 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SilicaFlickable {
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
PullDownMenu {
|
|
|
|
id: videoPagePullDownMenu
|
|
|
|
visible: (videoPage.videoUrl !== "")
|
|
|
|
MenuItem {
|
2021-02-04 01:12:24 +03:00
|
|
|
text: qsTr("Copy video to gallery")
|
2020-08-28 12:43:51 +03:00
|
|
|
onClicked: {
|
|
|
|
tdLibWrapper.copyFileToDownloads(videoPage.videoUrl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: tdLibWrapper
|
|
|
|
onFileUpdated: {
|
2021-02-04 01:12:24 +03:00
|
|
|
if (fileId === videoPage.videoData[videoType].id) {
|
2020-08-28 12:43:51 +03:00
|
|
|
if (fileInformation.local.is_downloading_completed) {
|
|
|
|
videoPage.videoUrl = fileInformation.local.path;
|
|
|
|
videoPagePullDownMenu.visible = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
onCopyToDownloadsSuccessful: {
|
2020-11-23 22:15:28 +03:00
|
|
|
appNotification.show(qsTr("Download of %1 successful.").arg(fileName), filePath);
|
2020-08-28 12:43:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
onCopyToDownloadsError: {
|
2020-11-23 22:15:28 +03:00
|
|
|
appNotification.show(qsTr("Download failed."));
|
2020-08-28 12:43:51 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Item {
|
|
|
|
width: videoPage.videoWidth * videoPage.sizingFactor
|
|
|
|
height: videoPage.videoHeight * videoPage.sizingFactor
|
|
|
|
anchors.centerIn: parent
|
|
|
|
|
2021-02-04 01:12:24 +03:00
|
|
|
MessageVideo {
|
|
|
|
id: myVideoComponent
|
2020-08-28 12:43:51 +03:00
|
|
|
videoData: videoPage.videoData
|
|
|
|
fullscreen: true
|
|
|
|
onScreen: videoPage.status === PageStatus.Active
|
2021-02-04 01:12:24 +03:00
|
|
|
rawMessage: sourceMessage
|
|
|
|
anchors.fill: parent
|
2020-08-28 12:43:51 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|