Add download option to audio preview

This commit is contained in:
Sebastian Wolf 2020-12-28 21:20:10 +01:00
parent f7c6f8a399
commit ef1f824cd8
No known key found for this signature in database
GPG key ID: CEA9522B5F38A90A
14 changed files with 158 additions and 17 deletions

View file

@ -163,7 +163,7 @@ Item {
height: Theme.iconSizeLarge
Item {
height: Theme.iconSizeLarge
width: parent.width
width: downloadItem.visible ? parent.width / 2 : parent.width
IconButton {
id: playButton
anchors.centerIn: parent
@ -187,6 +187,35 @@ Item {
size: BusyIndicatorSize.Large
}
}
Item {
id: downloadItem
width: parent.width / 2
height: Theme.iconSizeLarge
visible: audioData[audioType].local.is_downloading_completed
Rectangle {
color: Theme.primaryColor
opacity: Theme.opacityFaint
width: Theme.iconSizeLarge * 0.9
height: Theme.iconSizeLarge * 0.9
anchors.centerIn: parent
radius: width / 2
}
IconButton {
id: downloadButton
anchors.centerIn: parent
width: Theme.iconSizeLarge
height: Theme.iconSizeLarge
icon {
source: "image://theme/icon-m-cloud-download?white"
asynchronous: true
}
highlighted: audioMessageComponent.highlighted || down
onClicked: {
tdLibWrapper.copyFileToDownloads(audioData[audioType].local.path);
}
}
}
}
ProgressBar {
id: downloadingProgressBar
@ -250,6 +279,7 @@ Item {
target: messageAudio
onPlaying: {
playButton.visible = false;
downloadItem.visible = false;
}
}
@ -261,7 +291,6 @@ Item {
timeLeftItem.visible = true;
} else {
messageAudio.play();
timeLeftTimer.start();
}
}
}
@ -272,7 +301,6 @@ Item {
Component.onCompleted: {
if (messageAudio.error === MediaPlayer.NoError) {
messageAudio.play();
timeLeftTimer.start();
} else {
errorText.text = qsTr("Error loading audio! " + messageAudio.errorString)
errorTextOverlay.visible = true;
@ -323,6 +351,7 @@ Item {
onStopped: {
playButton.visible = true;
downloadItem.visible = true;
audioComponentLoader.active = false;
}
}
@ -336,15 +365,6 @@ Item {
size: BusyIndicatorSize.Medium
}
Timer {
id: timeLeftTimer
repeat: false
interval: 2000
onTriggered: {
timeLeftItem.visible = false;
}
}
Item {
id: timeLeftItem
width: parent.width
@ -372,7 +392,7 @@ Item {
visible: audioComponentLoader.active && messageAudio.playbackState === MediaPlayer.PausedState
Item {
height: parent.height
width: parent.width
width: parent.width / 2
IconButton {
id: pausedPlayButton
anchors.centerIn: parent
@ -385,7 +405,34 @@ Item {
}
onClicked: {
messageAudio.play();
timeLeftTimer.start();
}
}
}
Item {
id: pausedDownloadItem
width: parent.width / 2
height: parent.height
Rectangle {
color: Theme.primaryColor
opacity: Theme.opacityFaint
width: Theme.iconSizeLarge * 0.9
height: Theme.iconSizeLarge * 0.9
anchors.centerIn: parent
radius: width / 2
}
IconButton {
id: pausedDownloadButton
anchors.centerIn: parent
width: Theme.iconSizeLarge
height: Theme.iconSizeLarge
icon {
source: "image://theme/icon-m-cloud-download?white"
asynchronous: true
}
highlighted: audioMessageComponent.highlighted || down
onClicked: {
tdLibWrapper.copyFileToDownloads(audioData[audioType].local.path);
}
}
}
@ -406,7 +453,6 @@ Item {
onReleased: {
messageAudio.seek(Math.floor(value));
messageAudio.play();
timeLeftTimer.start();
}
valueText: getTimeString(Math.round((messageAudio.duration - messageAudioSlider.value) / 1000))
}

View file

@ -77,7 +77,7 @@ Item {
anchors.centerIn: parent
text: qsTr("Download Document")
visible: false
highlighted: videoMessageComponent.highlighted || down
highlighted: documentPreviewItem.highlighted || down
onClicked: {
downloadDocumentButton.visible = false;
downloadingProgressBar.visible = true;
@ -101,7 +101,7 @@ Item {
anchors.centerIn: parent
text: qsTr("Open Document")
visible: false
highlighted: videoMessageComponent.highlighted || down
highlighted: documentPreviewItem.highlighted || down
onClicked: {
documentPreviewItem.openRequested = true;
tdLibWrapper.openFileOnDevice(documentData.document.local.path);

View file

@ -183,6 +183,13 @@ Page {
onErrorReceived: {
Functions.handleErrorMessage(code, message);
}
onCopyToDownloadsSuccessful: {
appNotification.show(qsTr("Download of %1 successful.").arg(fileName), filePath);
}
onCopyToDownloadsError: {
appNotification.show(qsTr("Download failed."));
}
}
Component.onCompleted: {

View file

@ -1026,6 +1026,14 @@
<source>New Chat</source>
<translation>Neuer Chat</translation>
</message>
<message>
<source>Download of %1 successful.</source>
<translation type="unfinished">Download von %1 erfolgreich.</translation>
</message>
<message>
<source>Download failed.</source>
<translation type="unfinished">Download fehlgeschlagen.</translation>
</message>
</context>
<context>
<name>PinnedMessageItem</name>

View file

@ -1026,6 +1026,14 @@
<source>New Chat</source>
<translation>New Chat</translation>
</message>
<message>
<source>Download of %1 successful.</source>
<translation type="unfinished">Download of %1 successful.</translation>
</message>
<message>
<source>Download failed.</source>
<translation type="unfinished">Download failed.</translation>
</message>
</context>
<context>
<name>PinnedMessageItem</name>

View file

@ -1015,6 +1015,14 @@
<source>New Chat</source>
<translation>Nueva charla</translation>
</message>
<message>
<source>Download of %1 successful.</source>
<translation type="unfinished">Bajada de %1 exitosa.</translation>
</message>
<message>
<source>Download failed.</source>
<translation type="unfinished">Error al bajar</translation>
</message>
</context>
<context>
<name>PinnedMessageItem</name>

View file

@ -1027,6 +1027,14 @@
<source>New Chat</source>
<translation>Uusi keskustelu</translation>
</message>
<message>
<source>Download of %1 successful.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Download failed.</source>
<translation type="unfinished">Lataus epäonnistui.</translation>
</message>
</context>
<context>
<name>PinnedMessageItem</name>

View file

@ -1015,6 +1015,14 @@
<source>New Chat</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Download of %1 successful.</source>
<translation type="unfinished">A %1 letöltése sikerült.</translation>
</message>
<message>
<source>Download failed.</source>
<translation type="unfinished">A letöltés nem sikerült.</translation>
</message>
</context>
<context>
<name>PinnedMessageItem</name>

View file

@ -1026,6 +1026,14 @@
<source>New Chat</source>
<translation>Nuova chat</translation>
</message>
<message>
<source>Download of %1 successful.</source>
<translation type="unfinished">Download di %1 completato.</translation>
</message>
<message>
<source>Download failed.</source>
<translation type="unfinished">Download non riuscito.</translation>
</message>
</context>
<context>
<name>PinnedMessageItem</name>

View file

@ -1037,6 +1037,14 @@
<source>New Chat</source>
<translation>Nowy czat</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>PinnedMessageItem</name>

View file

@ -1037,6 +1037,14 @@
<source>New Chat</source>
<translation>Новый Чат</translation>
</message>
<message>
<source>Download of %1 successful.</source>
<translation type="unfinished">Успешно скачано %1.</translation>
</message>
<message>
<source>Download failed.</source>
<translation type="unfinished">Ошибка скачивания.</translation>
</message>
</context>
<context>
<name>PinnedMessageItem</name>

View file

@ -1026,6 +1026,14 @@
<source>New Chat</source>
<translation>Ny chatt</translation>
</message>
<message>
<source>Download of %1 successful.</source>
<translation type="unfinished">Nerladdning av %1 slutförd.</translation>
</message>
<message>
<source>Download failed.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PinnedMessageItem</name>

View file

@ -1015,6 +1015,14 @@
<source>New Chat</source>
<translation></translation>
</message>
<message>
<source>Download of %1 successful.</source>
<translation type="unfinished"> %1 </translation>
</message>
<message>
<source>Download failed.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PinnedMessageItem</name>

View file

@ -1026,6 +1026,14 @@
<source>New Chat</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Download of %1 successful.</source>
<translation type="unfinished">Download of %1 successful.</translation>
</message>
<message>
<source>Download failed.</source>
<translation type="unfinished">Download failed.</translation>
</message>
</context>
<context>
<name>PinnedMessageItem</name>