From a4dbc26e70d8ef8a334b7d942c4d05f3953ea61e Mon Sep 17 00:00:00 2001 From: Slava Monich Date: Wed, 13 Jan 2021 04:19:16 +0200 Subject: [PATCH 1/2] Handle message data change in ImagePreview And use TDLibFile to load image in ImagePage --- qml/components/ImagePreview.qml | 13 ++++++----- qml/pages/ImagePage.qml | 40 +++++++++++++-------------------- 2 files changed, 23 insertions(+), 30 deletions(-) diff --git a/qml/components/ImagePreview.qml b/qml/components/ImagePreview.qml index 98a4d70..68dff15 100644 --- a/qml/components/ImagePreview.qml +++ b/qml/components/ImagePreview.qml @@ -26,7 +26,6 @@ Item { property ListItem messageListItem property MessageOverlayFlickable overlayFlickable property var rawMessage: messageListItem ? messageListItem.myMessage : overlayFlickable.overlayMessage - property var photoData: rawMessage.content.photo readonly property int defaultHeight: Math.round(width * 2 / 3) property bool highlighted @@ -35,15 +34,19 @@ Item { function clicked() { pageStack.push(Qt.resolvedUrl("../pages/ImagePage.qml"), { - "photoData" : imagePreviewItem.photoData, - "pictureFileInformation" : imageFile.fileInformation + "photoData" : imagePreviewItem.rawMessage.content.photo }) } - Component.onCompleted: { - if (photoData) { + Component.onCompleted: updateImage() + + onRawMessageChanged: updateImage() + + function updateImage() { + if (rawMessage.content.photo) { // Check first which size fits best... var photo + var photoData = rawMessage.content.photo for (var i = 0; i < photoData.sizes.length; i++) { photo = photoData.sizes[i].photo if (photoData.sizes[i].width >= imagePreviewItem.width) { diff --git a/qml/pages/ImagePage.qml b/qml/pages/ImagePage.qml index eb301d7..9b057b5 100644 --- a/qml/pages/ImagePage.qml +++ b/qml/pages/ImagePage.qml @@ -18,6 +18,7 @@ */ import QtQuick 2.6 import Sailfish.Silica 1.0 +import WerkWolf.Fernschreiber 1.0 import "../components" import "../js/functions.js" as Functions import "../js/debug.js" as Debug @@ -28,9 +29,7 @@ Page { backNavigation: !imageOnly property var photoData; - property var pictureFileInformation; - property string imageUrl; property int imageWidth; property int imageHeight; @@ -47,40 +46,31 @@ Page { property bool imageOnly Component.onCompleted: { - updatePicture(); - } - - function updatePicture() { - if (typeof photoData === "object") { + if (photoData) { // Check first which size fits best... + var photo for (var i = 0; i < photoData.sizes.length; i++) { imagePage.imageWidth = photoData.sizes[i].width; imagePage.imageHeight = photoData.sizes[i].height; - imagePage.pictureFileInformation = photoData.sizes[i].photo; + photo = photoData.sizes[i].photo if (photoData.sizes[i].width >= imagePage.width) { break; } } - - if (imagePage.pictureFileInformation.local.is_downloading_completed) { - imagePage.imageUrl = imagePage.pictureFileInformation.local.path; - } else { - tdLibWrapper.downloadFile(imagePage.pictureFileInformation.id); + if (photo) { + imageFile.fileInformation = photo } } } + TDLibFile { + id: imageFile + tdlib: tdLibWrapper + autoLoad: true + } + Connections { target: tdLibWrapper - onFileUpdated: { - if (fileId === imagePage.pictureFileInformation.id) { - Debug.log("File updated, completed? ", fileInformation.local.is_downloading_completed); - if (fileInformation.local.is_downloading_completed) { - imagePage.pictureFileInformation = fileInformation; - imagePage.imageUrl = fileInformation.local.path; - } - } - } onCopyToDownloadsSuccessful: { appNotification.show(qsTr("Download of %1 successful.").arg(fileName), filePath); } @@ -96,11 +86,11 @@ Page { interactive: !imageOnly PullDownMenu { - visible: !imageOnly && imageUrl + visible: !imageOnly && imageFile.isDownloadingCompleted && imageFile.path MenuItem { text: qsTr("Download Picture") onClicked: { - tdLibWrapper.copyFileToDownloads(imagePage.imageUrl); + tdLibWrapper.copyFileToDownloads(imageFile.path); } } } @@ -134,7 +124,7 @@ Page { Image { id: singleImage - source: imageUrl + source: imageFile.isDownloadingCompleted ? imageFile.path : "" width: imagePage.imageWidth * imagePage.sizingFactor height: imagePage.imageHeight * imagePage.sizingFactor anchors.centerIn: parent From 3fb66af0fe5beb5b428f8c726505e751cb0b86b2 Mon Sep 17 00:00:00 2001 From: Rustem Abzalov <79509494133@ya.ru> Date: Wed, 13 Jan 2021 20:17:05 +0300 Subject: [PATCH 2/2] Update harbour-fernschreiber-ru.ts --- translations/harbour-fernschreiber-ru.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/translations/harbour-fernschreiber-ru.ts b/translations/harbour-fernschreiber-ru.ts index 334fef1..7efed5f 100644 --- a/translations/harbour-fernschreiber-ru.ts +++ b/translations/harbour-fernschreiber-ru.ts @@ -49,7 +49,7 @@ This product uses the Telegram API but is not endorsed or certified by Telegram. - Этот продукт использует Telegram API, но не одобрен или сертифицирован Telegram. + Этот продукт использует Telegram API, но не одобрен или сертифицирован Telegram FZ-LLC TDLib version %1 @@ -1031,7 +1031,7 @@ Synchronize Contacts with Telegram - Сихронизация контактов с Телеграм + Синхронизировать с Телеграм Could not synchronize your contacts with Telegram. @@ -1529,7 +1529,7 @@ Ready - Готов + Ожидание