Introduce some lazy loading
This commit is contained in:
parent
cfb93912ec
commit
c5dade71b0
7 changed files with 157 additions and 70 deletions
|
@ -50,7 +50,9 @@ DISTFILES += qml/harbour-fernschreiber.qml \
|
|||
|
||||
SAILFISHAPP_ICONS = 86x86 108x108 128x128 172x172 256x256
|
||||
|
||||
TRANSLATIONS += translations/harbour-fernschreiber-de.ts
|
||||
TRANSLATIONS += translations/harbour-fernschreiber-de.ts \
|
||||
translations/harbour-fernschreiber-es.ts \
|
||||
translations/harbour-fernschreiber-zh_CN.ts
|
||||
|
||||
LIBS += -L$$PWD/tdlib/lib/ -ltdjson
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ Item {
|
|||
function updatePicture() {
|
||||
if (typeof photoData === "object") {
|
||||
if (photoData.local.is_downloading_completed) {
|
||||
singleImage.source = photoData.local.path;
|
||||
profileImageLoader.active = true;
|
||||
} else {
|
||||
tdLibWrapper.downloadFile(photoData.id);
|
||||
}
|
||||
|
@ -82,49 +82,70 @@ Item {
|
|||
console.log("File updated, completed? " + fileInformation.local.is_downloading_completed);
|
||||
if (fileInformation.local.is_downloading_completed) {
|
||||
photoData = fileInformation;
|
||||
singleImage.source = photoData.local.path;
|
||||
profileImageLoader.active = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Image {
|
||||
id: singleImage
|
||||
width: parent.width - Theme.paddingSmall
|
||||
height: parent.height - Theme.paddingSmall
|
||||
anchors.centerIn: parent
|
||||
Component {
|
||||
id: profileImageComponent
|
||||
Item {
|
||||
width: parent.width
|
||||
height: width
|
||||
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
autoTransform: true
|
||||
Image {
|
||||
id: singleImage
|
||||
width: parent.width - Theme.paddingSmall
|
||||
height: parent.height - Theme.paddingSmall
|
||||
anchors.centerIn: parent
|
||||
source: profileThumbnail.photoData.local.path
|
||||
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
autoTransform: true
|
||||
asynchronous: true
|
||||
visible: false
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: profileThumbnailMask
|
||||
width: parent.width - Theme.paddingSmall
|
||||
height: parent.height - Theme.paddingSmall
|
||||
color: Theme.primaryColor
|
||||
radius: parent.width / 2
|
||||
anchors.centerIn: singleImage
|
||||
visible: false
|
||||
}
|
||||
|
||||
OpacityMask {
|
||||
id: maskedThumbnail
|
||||
source: singleImage
|
||||
maskSource: profileThumbnailMask
|
||||
anchors.fill: singleImage
|
||||
visible: singleImage.status === Image.Ready ? true : false
|
||||
opacity: singleImage.status === Image.Ready ? 1 : 0
|
||||
Behavior on opacity { NumberAnimation {} }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: profileImageLoader
|
||||
active: false
|
||||
asynchronous: true
|
||||
visible: false
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: profileThumbnailMask
|
||||
width: parent.width - Theme.paddingSmall
|
||||
height: parent.height - Theme.paddingSmall
|
||||
color: Theme.primaryColor
|
||||
radius: parent.width / 2
|
||||
anchors.centerIn: singleImage
|
||||
visible: false
|
||||
}
|
||||
|
||||
OpacityMask {
|
||||
id: maskedThumbnail
|
||||
source: singleImage
|
||||
maskSource: profileThumbnailMask
|
||||
anchors.fill: singleImage
|
||||
visible: singleImage.status === Image.Ready ? true : false
|
||||
opacity: singleImage.status === Image.Ready ? 1 : 0
|
||||
Behavior on opacity { NumberAnimation {} }
|
||||
width: parent.width
|
||||
sourceComponent: profileImageComponent
|
||||
onLoaded: {
|
||||
console.log(profileThumbnail.photoData.local.path);
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
id: replacementThumbnailItem
|
||||
width: parent.width - Theme.paddingSmall
|
||||
height: parent.height - Theme.paddingSmall
|
||||
visible: singleImage.status !== Image.Ready
|
||||
//visible: singleImage.status !== Image.Ready
|
||||
visible: !profileImageLoader.active
|
||||
|
||||
Rectangle {
|
||||
id: replacementThumbnailBackground
|
||||
|
|
|
@ -56,7 +56,7 @@ Page {
|
|||
}
|
||||
|
||||
Label {
|
||||
text: "Fernschreiber 0.1"
|
||||
text: "Fernschreiber 0.2"
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
font.pixelSize: Theme.fontSizeExtraLarge
|
||||
anchors {
|
||||
|
|
|
@ -354,10 +354,8 @@ Page {
|
|||
id: chatView
|
||||
|
||||
anchors.fill: parent
|
||||
|
||||
opacity: chatPage.loading ? 0 : 1
|
||||
Behavior on opacity { NumberAnimation {} }
|
||||
|
||||
clip: true
|
||||
|
||||
property int lastReadSentIndex: 0
|
||||
|
@ -540,50 +538,116 @@ Page {
|
|||
visible: (text !== "")
|
||||
}
|
||||
|
||||
WebPagePreview {
|
||||
id: webPagePreview
|
||||
webPageData: ( typeof display.content.web_page !== "undefined" ) ? display.content.web_page : ""
|
||||
Component {
|
||||
id: webPagePreviewComponent
|
||||
WebPagePreview {
|
||||
id: webPagePreview
|
||||
webPageData: ( typeof display.content.web_page !== "undefined" ) ? display.content.web_page : ""
|
||||
width: parent.width
|
||||
visible: typeof display.content.web_page !== "undefined"
|
||||
}
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: webPagePreviewLoader
|
||||
active: ( typeof display.content.web_page !== "undefined" )
|
||||
asynchronous: true
|
||||
width: parent.width
|
||||
visible: typeof display.content.web_page !== "undefined"
|
||||
sourceComponent: webPagePreviewComponent
|
||||
}
|
||||
|
||||
ImagePreview {
|
||||
id: messageImagePreview
|
||||
photoData: ( display.content['@type'] === "messagePhoto" ) ? display.content.photo : ""
|
||||
Component {
|
||||
id: imagePreviewComponent
|
||||
ImagePreview {
|
||||
id: messageImagePreview
|
||||
photoData: ( display.content['@type'] === "messagePhoto" ) ? display.content.photo : ""
|
||||
width: parent.width
|
||||
height: parent.width * 2 / 3
|
||||
visible: display.content['@type'] === "messagePhoto"
|
||||
}
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: imagePreviewLoader
|
||||
active: ( display.content['@type'] === "messagePhoto" )
|
||||
asynchronous: true
|
||||
width: parent.width
|
||||
height: parent.width * 2 / 3
|
||||
visible: display.content['@type'] === "messagePhoto"
|
||||
sourceComponent: imagePreviewComponent
|
||||
}
|
||||
|
||||
StickerPreview {
|
||||
id: messageStickerPreview
|
||||
stickerData: ( display.content['@type'] === "messageSticker" ) ? display.content.sticker : ""
|
||||
visible: display.content['@type'] === "messageSticker"
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
Component {
|
||||
id: stickerPreviewComponent
|
||||
StickerPreview {
|
||||
id: messageStickerPreview
|
||||
stickerData: ( display.content['@type'] === "messageSticker" ) ? display.content.sticker : ""
|
||||
visible: display.content['@type'] === "messageSticker"
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
}
|
||||
|
||||
VideoPreview {
|
||||
id: messageVideoPreview
|
||||
videoData: ( display.content['@type'] === "messageVideo" ) ? display.content.video : ( ( display.content['@type'] === "messageAnimation" ) ? display.content.animation : "")
|
||||
Loader {
|
||||
id: stickerPreviewLoader
|
||||
active: ( display.content['@type'] === "messageSticker" )
|
||||
asynchronous: true
|
||||
width: parent.width
|
||||
height: ( display.content['@type'] === "messageVideo" ) ? Functions.getVideoHeight(width, display.content.video) : Functions.getVideoHeight(width, display.content.animation)
|
||||
visible: ( display.content['@type'] === "messageVideo" || display.content['@type'] === "messageAnimation" )
|
||||
onScreen: chatPage.status === PageStatus.Active
|
||||
sourceComponent: stickerPreviewComponent
|
||||
}
|
||||
|
||||
AudioPreview {
|
||||
id: messageAudioPreview
|
||||
audioData: ( display.content['@type'] === "messageVoiceNote" ) ? display.content.voice_note : ( ( display.content['@type'] === "messageAudio" ) ? display.content.audio : "")
|
||||
Component {
|
||||
id: videoPreviewComponent
|
||||
VideoPreview {
|
||||
id: messageVideoPreview
|
||||
videoData: ( display.content['@type'] === "messageVideo" ) ? display.content.video : ( ( display.content['@type'] === "messageAnimation" ) ? display.content.animation : "")
|
||||
width: parent.width
|
||||
height: ( display.content['@type'] === "messageVideo" ) ? Functions.getVideoHeight(width, display.content.video) : Functions.getVideoHeight(width, display.content.animation)
|
||||
visible: ( display.content['@type'] === "messageVideo" || display.content['@type'] === "messageAnimation" )
|
||||
onScreen: chatPage.status === PageStatus.Active
|
||||
}
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: videoPreviewLoader
|
||||
active: (( display.content['@type'] === "messageVideo" ) || ( display.content['@type'] === "messageAnimation" ))
|
||||
asynchronous: true
|
||||
width: parent.width
|
||||
height: parent.width / 2
|
||||
visible: ( display.content['@type'] === "messageVoiceNote" || display.content['@type'] === "messageAudio" )
|
||||
onScreen: chatPage.status === PageStatus.Active
|
||||
sourceComponent: videoPreviewComponent
|
||||
}
|
||||
|
||||
DocumentPreview {
|
||||
id: messageDocumentPreview
|
||||
documentData: ( display.content['@type'] === "messageDocument" ) ? display.content.document : ""
|
||||
visible: display.content['@type'] === "messageDocument"
|
||||
Component {
|
||||
id: audioPreviewComponent
|
||||
AudioPreview {
|
||||
id: messageAudioPreview
|
||||
audioData: ( display.content['@type'] === "messageVoiceNote" ) ? display.content.voice_note : ( ( display.content['@type'] === "messageAudio" ) ? display.content.audio : "")
|
||||
width: parent.width
|
||||
height: parent.width / 2
|
||||
visible: ( display.content['@type'] === "messageVoiceNote" || display.content['@type'] === "messageAudio" )
|
||||
onScreen: chatPage.status === PageStatus.Active
|
||||
}
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: audioPreviewLoader
|
||||
active: (( display.content['@type'] === "messageVoiceNote" ) || ( display.content['@type'] === "messageAudio" ))
|
||||
asynchronous: true
|
||||
width: parent.width
|
||||
sourceComponent: audioPreviewComponent
|
||||
}
|
||||
|
||||
Component {
|
||||
id: documentPreviewComponent
|
||||
DocumentPreview {
|
||||
id: messageDocumentPreview
|
||||
documentData: ( display.content['@type'] === "messageDocument" ) ? display.content.document : ""
|
||||
visible: display.content['@type'] === "messageDocument"
|
||||
}
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: documentPreviewLoader
|
||||
active: ( display.content['@type'] === "messageDocument" )
|
||||
asynchronous: true
|
||||
width: parent.width
|
||||
sourceComponent: documentPreviewComponent
|
||||
}
|
||||
|
||||
Timer {
|
||||
|
|
|
@ -11,8 +11,8 @@ Name: harbour-fernschreiber
|
|||
# << macros
|
||||
|
||||
Summary: Fernschreiber is a Telegram client for Sailfish OS
|
||||
Version: 0.1
|
||||
Release: 6
|
||||
Version: 0.2
|
||||
Release: 1
|
||||
Group: Qt/Qt
|
||||
License: LICENSE
|
||||
URL: http://werkwolf.eu/
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
Name: harbour-fernschreiber
|
||||
Summary: Fernschreiber is a Telegram client for Sailfish OS
|
||||
Version: 0.1
|
||||
Release: 6
|
||||
Version: 0.2
|
||||
Release: 1
|
||||
# The contents of the Group field should be one of the groups listed here:
|
||||
# https://github.com/mer-tools/spectacle/blob/master/data/GROUPS
|
||||
Group: Qt/Qt
|
||||
|
|
|
@ -631,7 +631,7 @@ void TDLibWrapper::setInitialParameters()
|
|||
QSettings hardwareSettings("/etc/hw-release", QSettings::NativeFormat);
|
||||
initialParameters.insert("device_model", hardwareSettings.value("NAME", "Unknown Mobile Device").toString());
|
||||
initialParameters.insert("system_version", QSysInfo::prettyProductName());
|
||||
initialParameters.insert("application_version", "0.1");
|
||||
initialParameters.insert("application_version", "0.2");
|
||||
requestObject.insert("parameters", initialParameters);
|
||||
this->sendRequest(requestObject);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue