From 117e7e9310b628ab06ad9728674b609fd0624b58 Mon Sep 17 00:00:00 2001 From: John Gibbon Date: Tue, 19 Jan 2021 22:42:53 +0100 Subject: [PATCH] Use biggest image for detail page --- qml/pages/ImagePage.qml | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/qml/pages/ImagePage.qml b/qml/pages/ImagePage.qml index 9b057b5..b691867 100644 --- a/qml/pages/ImagePage.qml +++ b/qml/pages/ImagePage.qml @@ -47,18 +47,16 @@ Page { Component.onCompleted: { if (photoData) { - // Check first which size fits best... - var photo + var biggestIndex = -1 for (var i = 0; i < photoData.sizes.length; i++) { - imagePage.imageWidth = photoData.sizes[i].width; - imagePage.imageHeight = photoData.sizes[i].height; - photo = photoData.sizes[i].photo - if (photoData.sizes[i].width >= imagePage.width) { - break; + if (biggestIndex === -1 || photoData.sizes[i].width > photoData.sizes[biggestIndex].width) { + biggestIndex = i; } } - if (photo) { - imageFile.fileInformation = photo + if (biggestIndex > -1) { + imagePage.imageWidth = photoData.sizes[biggestIndex].width; + imagePage.imageHeight = photoData.sizes[biggestIndex].height; + singleImage.fileInformation = photoData.sizes[biggestIndex].photo } } } @@ -122,9 +120,8 @@ Page { imageFlickable.returnToBounds() } - Image { + TDLibImage { id: singleImage - source: imageFile.isDownloadingCompleted ? imageFile.path : "" width: imagePage.imageWidth * imagePage.sizingFactor height: imagePage.imageHeight * imagePage.sizingFactor anchors.centerIn: parent