More progress bars & fix some web page previews

This commit is contained in:
Sebastian Wolf 2020-11-14 22:53:51 +01:00
parent fa470f73ba
commit 6666cf494a
4 changed files with 59 additions and 30 deletions

View file

@ -101,6 +101,10 @@ Item {
} }
} }
} }
if (fileId === audioFileId) {
downloadingProgressBar.maximumValue = fileInformation.size;
downloadingProgressBar.value = fileInformation.local.downloaded_size;
}
} }
} }
} }
@ -128,37 +132,52 @@ Item {
visible: playButton.visible visible: playButton.visible
} }
Row { Column {
width: parent.width width: parent.width
height: parent.height height: downloadingProgressBar.height + audioControlRow.height
Item { anchors.centerIn: parent
height: parent.height Row {
id: audioControlRow
width: parent.width width: parent.width
Image { height: Theme.iconSizeLarge
id: playButton Item {
anchors.centerIn: parent
width: Theme.iconSizeLarge
height: Theme.iconSizeLarge height: Theme.iconSizeLarge
source: "image://theme/icon-l-play?white" width: parent.width
asynchronous: true Image {
visible: placeholderImage.status === Image.Ready ? true : false id: playButton
MouseArea { anchors.centerIn: parent
anchors.fill: parent width: Theme.iconSizeLarge
onClicked: { height: Theme.iconSizeLarge
handlePlay(); source: "image://theme/icon-l-play?white"
asynchronous: true
visible: placeholderImage.status === Image.Ready ? true : false
MouseArea {
anchors.fill: parent
onClicked: {
handlePlay();
}
} }
} }
} BusyIndicator {
BusyIndicator { id: audioDownloadBusyIndicator
id: audioDownloadBusyIndicator running: false
running: false visible: running
visible: running anchors.centerIn: parent
anchors.centerIn: parent size: BusyIndicatorSize.Large
size: BusyIndicatorSize.Large }
} }
} }
ProgressBar {
id: downloadingProgressBar
minimumValue: 0
maximumValue: 100
value: 0
visible: audioDownloadBusyIndicator.visible
width: parent.width
}
} }
Rectangle { Rectangle {
id: audioErrorShade id: audioErrorShade
width: parent.width width: parent.width

View file

@ -52,7 +52,7 @@ Item {
onFileUpdated: { onFileUpdated: {
if (documentData) { if (documentData) {
if (!fileInformation.remote.is_uploading_active && fileId === documentData.document.id && fileInformation.local.is_downloading_completed) { if (!fileInformation.remote.is_uploading_active && fileId === documentData.document.id && fileInformation.local.is_downloading_completed) {
downloadBusyIndicator.running = false; downloadingProgressBar.visible = false;
documentData.document = fileInformation; documentData.document = fileInformation;
downloadDocumentButton.visible = false; downloadDocumentButton.visible = false;
openDocumentButton.visible = true; openDocumentButton.visible = true;
@ -61,6 +61,10 @@ Item {
tdLibWrapper.openFileOnDevice(documentData.document.local.path); tdLibWrapper.openFileOnDevice(documentData.document.local.path);
} }
} }
if (fileId === documentData.document.id) {
downloadingProgressBar.maximumValue = fileInformation.size;
downloadingProgressBar.value = fileInformation.local.downloaded_size;
}
} }
} }
} }
@ -73,16 +77,18 @@ Item {
visible: false visible: false
onClicked: { onClicked: {
downloadDocumentButton.visible = false; downloadDocumentButton.visible = false;
downloadBusyIndicator.running = true; downloadingProgressBar.visible = true;
tdLibWrapper.downloadFile(documentData.document.id); tdLibWrapper.downloadFile(documentData.document.id);
} }
} }
BusyIndicator { ProgressBar {
id: downloadBusyIndicator id: downloadingProgressBar
running: false minimumValue: 0
size: BusyIndicatorSize.Medium maximumValue: 100
visible: running value: 0
visible: false
width: parent.width
anchors.centerIn: parent anchors.centerIn: parent
} }

View file

@ -362,6 +362,10 @@ ListItem {
WebPagePreview { WebPagePreview {
id: webPagePreview id: webPagePreview
Component.onCompleted: {
webPagePreviewLoader.height = 0;
}
onImplicitHeightChanged: { onImplicitHeightChanged: {
webPagePreviewLoader.height = webPagePreview.implicitHeight; webPagePreviewLoader.height = webPagePreview.implicitHeight;
} }

View file

@ -608,7 +608,7 @@ Page {
case "LocationPreview": case "LocationPreview":
return parentWidth * 0.66666666; // 2 / 3; return parentWidth * 0.66666666; // 2 / 3;
case "VideoPreview": case "VideoPreview":
return ( content['@type'] === "messageVideoNote" ) ? content.video_note.length : ( Functions.getVideoHeight(parentWidth, ( content['@type'] === "messageVideo" ) ? content.video : content.animation) ); return ( content['@type'] === "messageVideoNote" ) ? parentWidth : ( Functions.getVideoHeight(parentWidth, ( content['@type'] === "messageVideo" ) ? content.video : content.animation) );
case "AudioPreview": case "AudioPreview":
return parentWidth / 2; return parentWidth / 2;
case "DocumentPreview": case "DocumentPreview":