Add fullscreen video page

This commit is contained in:
Sebastian J. Wolf 2020-08-28 11:43:51 +02:00
parent c741a157b7
commit 50a67bb037
9 changed files with 145 additions and 9 deletions

View file

@ -30,6 +30,7 @@ DISTFILES += qml/harbour-fernschreiber.qml \
qml/pages/InitializationPage.qml \
qml/pages/OverviewPage.qml \
qml/pages/AboutPage.qml \
qml/pages/VideoPage.qml \
rpm/harbour-fernschreiber.changes.in \
rpm/harbour-fernschreiber.changes.run.in \
rpm/harbour-fernschreiber.spec \

View file

@ -29,6 +29,7 @@ Item {
property int previewFileId;
property int videoFileId;
property bool fullscreen : false;
property bool onScreen;
width: parent.width
height: parent.height
@ -105,12 +106,14 @@ Item {
videoDownloadBusyIndicator.running = false;
videoData.video = fileInformation;
videoUrl = fileInformation.local.path;
if (onScreen) {
videoComponentLoader.active = true;
}
}
}
}
}
}
Image {
id: placeholderImage
@ -187,8 +190,7 @@ Item {
MouseArea {
anchors.fill: parent
onClicked: {
// TODO show video page once it's there...
//pageStack.push(Qt.resolvedUrl("../pages/VideoPage.qml"), {"tweetModel": tweet.retweeted_status ? tweet.retweeted_status : tweet});
pageStack.push(Qt.resolvedUrl("../pages/VideoPage.qml"), {"videoData": videoData});
}
}
}
@ -417,8 +419,7 @@ Item {
MouseArea {
anchors.fill: parent
onClicked: {
// TODO go to video page once it's done
// pageStack.push(Qt.resolvedUrl("../pages/VideoPage.qml"), {"tweetModel": videoMessageComponent.tweet});
pageStack.push(Qt.resolvedUrl("../pages/VideoPage.qml"), {"videoData": videoData});
}
}
}

View file

@ -446,6 +446,7 @@ Page {
width: parent.width
height: Functions.getVideoHeight(width, display.content.video)
visible: display.content['@type'] === "messageVideo"
onScreen: chatPage.status === PageStatus.Active
}
// Row {

View file

@ -99,7 +99,7 @@ Page {
MenuItem {
text: qsTr("Download Picture")
onClicked: {
tdLibWrapper.copyPictureToDownloads(imagePage.imageUrl);
tdLibWrapper.copyFileToDownloads(imagePage.imageUrl);
}
}
}

103
qml/pages/VideoPage.qml Normal file
View file

@ -0,0 +1,103 @@
/*
Copyright (C) 2020 Sebastian J. Wolf
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/>.
*/
import QtQuick 2.0
import Sailfish.Silica 1.0
import QtMultimedia 5.0
import "../components"
import "../js/functions.js" as Functions
Page {
id: videoPage
allowedOrientations: Orientation.All
property variant videoData;
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") {
if (videoData.video.local.is_downloading_completed) {
videoPage.videoUrl = videoData.video.local.path;
}
}
}
SilicaFlickable {
anchors.fill: parent
PullDownMenu {
id: videoPagePullDownMenu
visible: (videoPage.videoUrl !== "")
MenuItem {
text: qsTr("Download Video")
onClicked: {
tdLibWrapper.copyFileToDownloads(videoPage.videoUrl);
}
}
}
Connections {
target: tdLibWrapper
onFileUpdated: {
if (fileId === videoPage.video.id) {
if (fileInformation.local.is_downloading_completed) {
videoPage.video = fileInformation;
videoPage.videoUrl = fileInformation.local.path;
videoPagePullDownMenu.visible = true;
}
}
}
onCopyToDownloadsSuccessful: {
videoNotification.show(qsTr("Download of %1 successful.").arg(fileName), filePath);
}
onCopyToDownloadsError: {
videoNotification.show(qsTr("Download failed."));
}
}
AppNotification {
id: videoNotification
}
Item {
width: videoPage.videoWidth * videoPage.sizingFactor
height: videoPage.videoHeight * videoPage.sizingFactor
anchors.centerIn: parent
VideoPreview {
videoData: videoPage.videoData
fullscreen: true
onScreen: videoPage.status === PageStatus.Active
}
}
}
}

View file

@ -246,9 +246,9 @@ QVariantMap TDLibWrapper::getSuperGroup(const QString &groupId)
return this->superGroups.value(groupId).toMap();
}
void TDLibWrapper::copyPictureToDownloads(const QString &filePath)
void TDLibWrapper::copyFileToDownloads(const QString &filePath)
{
qDebug() << "[TDLibWrapper] Copy picture to downloads " << filePath;
qDebug() << "[TDLibWrapper] Copy file to downloads " << filePath;
QFileInfo fileInfo(filePath);
if (fileInfo.exists()) {
QString downloadFilePath = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation) + "/" + fileInfo.fileName();

View file

@ -67,7 +67,7 @@ public:
Q_INVOKABLE QVariantMap getUnreadChatInformation();
Q_INVOKABLE QVariantMap getBasicGroup(const QString &groupId);
Q_INVOKABLE QVariantMap getSuperGroup(const QString &groupId);
Q_INVOKABLE void copyPictureToDownloads(const QString &filePath);
Q_INVOKABLE void copyFileToDownloads(const QString &filePath);
Q_INVOKABLE void handleAdditionalInformation(const QString &additionalInformation);
Q_INVOKABLE void controlScreenSaver(const bool &enabled);

View file

@ -282,6 +282,21 @@
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>VideoPage</name>
<message>
<source>Download Video</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Download of %1 successful.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Download failed.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>functions</name>
<message>

View file

@ -282,6 +282,21 @@
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>VideoPage</name>
<message>
<source>Download Video</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Download of %1 successful.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Download failed.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>functions</name>
<message>