Merge branch 'master' into feature/inline_queries
This commit is contained in:
commit
954986edee
3 changed files with 26 additions and 33 deletions
|
@ -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) {
|
||||
|
|
|
@ -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 (photo) {
|
||||
imageFile.fileInformation = photo
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (imagePage.pictureFileInformation.local.is_downloading_completed) {
|
||||
imagePage.imageUrl = imagePage.pictureFileInformation.local.path;
|
||||
} else {
|
||||
tdLibWrapper.downloadFile(imagePage.pictureFileInformation.id);
|
||||
}
|
||||
}
|
||||
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
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
</message>
|
||||
<message>
|
||||
<source>This product uses the Telegram API but is not endorsed or certified by Telegram.</source>
|
||||
<translation>Этот продукт использует Telegram API, но не одобрен или сертифицирован Telegram.</translation>
|
||||
<translation>Этот продукт использует Telegram API, но не одобрен или сертифицирован Telegram FZ-LLC</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>TDLib version %1</source>
|
||||
|
@ -1082,7 +1082,7 @@
|
|||
</message>
|
||||
<message>
|
||||
<source>Synchronize Contacts with Telegram</source>
|
||||
<translation>Сихронизация контактов с Телеграм</translation>
|
||||
<translation>Синхронизировать с Телеграм</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Could not synchronize your contacts with Telegram.</source>
|
||||
|
@ -1592,7 +1592,7 @@
|
|||
</message>
|
||||
<message>
|
||||
<source>Ready</source>
|
||||
<translation>Готов</translation>
|
||||
<translation>Ожидание</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
|
|
Loading…
Reference in a new issue