From 5e6cd6f4b4368dfc2cd721868a9e7c7c477fce4c Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Mon, 25 Jan 2021 23:39:54 +0100 Subject: [PATCH] Prepare adding/deleting profile pictures --- harbour-fernschreiber.pro | 2 +- ...PictureList.qml => ProfilePictureList.qml} | 15 ++-- .../ChatInformationPageContent.qml | 9 +- .../ChatInformationProfilePicture.qml | 4 +- qml/pages/SettingsPage.qml | 82 ++++++++++++++++++- translations/harbour-fernschreiber-de.ts | 16 ++++ translations/harbour-fernschreiber-en.ts | 16 ++++ translations/harbour-fernschreiber-es.ts | 16 ++++ translations/harbour-fernschreiber-fi.ts | 16 ++++ translations/harbour-fernschreiber-hu.ts | 16 ++++ translations/harbour-fernschreiber-it.ts | 16 ++++ translations/harbour-fernschreiber-pl.ts | 16 ++++ translations/harbour-fernschreiber-ru.ts | 16 ++++ translations/harbour-fernschreiber-sv.ts | 16 ++++ translations/harbour-fernschreiber-zh_CN.ts | 16 ++++ translations/harbour-fernschreiber.ts | 16 ++++ 16 files changed, 272 insertions(+), 16 deletions(-) rename qml/components/{chatInformationPage/ChatInformationProfilePictureList.qml => ProfilePictureList.qml} (80%) diff --git a/harbour-fernschreiber.pro b/harbour-fernschreiber.pro index 4121b6b..2f83f12 100644 --- a/harbour-fernschreiber.pro +++ b/harbour-fernschreiber.pro @@ -60,6 +60,7 @@ DISTFILES += qml/harbour-fernschreiber.qml \ qml/components/PinnedMessageItem.qml \ qml/components/PollPreview.qml \ qml/components/PressEffect.qml \ + qml/components/ProfilePictureList.qml \ qml/components/ReplyMarkupButtons.qml \ qml/components/StickerPicker.qml \ qml/components/PhotoTextsListItem.qml \ @@ -70,7 +71,6 @@ DISTFILES += qml/harbour-fernschreiber.qml \ qml/components/VoiceNoteOverlay.qml \ qml/components/chatInformationPage/ChatInformationPageContent.qml \ qml/components/chatInformationPage/ChatInformationProfilePicture.qml \ - qml/components/chatInformationPage/ChatInformationProfilePictureList.qml \ qml/components/chatInformationPage/ChatInformationTabItemBase.qml \ qml/components/chatInformationPage/ChatInformationTabItemDebug.qml \ qml/components/chatInformationPage/ChatInformationTabItemMembersGroups.qml \ diff --git a/qml/components/chatInformationPage/ChatInformationProfilePictureList.qml b/qml/components/ProfilePictureList.qml similarity index 80% rename from qml/components/chatInformationPage/ChatInformationProfilePictureList.qml rename to qml/components/ProfilePictureList.qml index f9586be..58656bd 100644 --- a/qml/components/chatInformationPage/ChatInformationProfilePictureList.qml +++ b/qml/components/ProfilePictureList.qml @@ -1,5 +1,5 @@ /* - Copyright (C) 2020 Sebastian J. Wolf and other contributors + Copyright (C) 2020-21 Sebastian J. Wolf and other contributors This file is part of Fernschreiber. @@ -18,25 +18,24 @@ */ import QtQuick 2.6 import Sailfish.Silica 1.0 -import "../" Item { - visible: imageContainer.tweenFactor > 0.8 && bigProfilePictureList.count > 0 - property bool isActive: imageContainer.tweenFactor === 1.0 + id: profilePictureListItem + visible: imageContainer.thumbnailVisible && bigProfilePictureList.count > 0 + property bool isActive: imageContainer.thumbnailActive opacity: isActive ? 1.0 : 0.0 Behavior on opacity { FadeAnimation {} } SlideshowView { id: bigProfilePictureList - property bool isActive: imageContainer.tweenFactor === 1.0 width: parent.width height: parent.height clip: true itemWidth: width itemHeight: height interactive: parent.isActive - model: chatInformationPage.chatPartnerProfilePhotos + model: imageContainer.thumbnailModel delegate: Item { width: bigProfilePictureList.itemWidth height: bigProfilePictureList.itemHeight @@ -44,13 +43,13 @@ Item { id: chatPictureDetail photoData: modelData.sizes[modelData.sizes.length - 1].photo replacementStringHint: "" - radius: chatPictureThumbnail.radius + radius: imageContainer.thumbnailRadius anchors.fill: parent } MouseArea { anchors.fill: parent onClicked: { - pageStack.push(Qt.resolvedUrl("../../pages/ImagePage.qml"), { "photoData" : modelData }); + pageStack.push(Qt.resolvedUrl("../pages/ImagePage.qml"), { "photoData" : modelData }); } } } diff --git a/qml/components/chatInformationPage/ChatInformationPageContent.qml b/qml/components/chatInformationPage/ChatInformationPageContent.qml index e1985f9..654ef0a 100644 --- a/qml/components/chatInformationPage/ChatInformationPageContent.qml +++ b/qml/components/chatInformationPage/ChatInformationPageContent.qml @@ -256,6 +256,10 @@ SilicaFlickable { } return 1 - Math.max(0, Math.min(1, contentFlickable.contentY / maxDimension)) } + property bool thumbnailVisible: imageContainer.tweenFactor > 0.8 + property bool thumbnailActive: imageContainer.tweenFactor === 1.0 + property var thumbnailModel: chatInformationPage.chatPartnerProfilePhotos + property int thumbnailRadius: imageContainer.minDimension / 2 function getEased(min,max,factor) { return min + (max-min)*factor @@ -271,17 +275,18 @@ SilicaFlickable { replacementStringHint: headerItem.title width: parent.width height: width - radius: imageContainer.minDimension / 2 + radius: imageContainer.thumbnailRadius opacity: profilePictureLoader.status !== Loader.Ready || profilePictureLoader.item.opacity < 1 ? 1.0 : 0.0 optimizeImageSize: false } + Loader { id: profilePictureLoader active: imageContainer.hasImage asynchronous: true anchors.fill: chatPictureThumbnail source: ( chatInformationPage.isPrivateChat || chatInformationPage.isSecretChat) - ? "ChatInformationProfilePictureList.qml" + ? "../ProfilePictureList.qml" : "ChatInformationProfilePicture.qml" } } diff --git a/qml/components/chatInformationPage/ChatInformationProfilePicture.qml b/qml/components/chatInformationPage/ChatInformationProfilePicture.qml index 16753e7..fe6ae5d 100644 --- a/qml/components/chatInformationPage/ChatInformationProfilePicture.qml +++ b/qml/components/chatInformationPage/ChatInformationProfilePicture.qml @@ -22,8 +22,8 @@ import Sailfish.Silica 1.0 import "../" Item { - visible: imageContainer.tweenFactor > 0.8 && chatPictureDetail.imageStatus === Image.Ready - property bool isActive: imageContainer.tweenFactor === 1.0 + visible: parent.thumbnailVisible && chatPictureDetail.imageStatus === Image.Ready + property bool isActive: parent.thumbnailActive opacity: isActive ? 1.0 : 0.0 Behavior on opacity { FadeAnimation {} } ProfileThumbnail { diff --git a/qml/pages/SettingsPage.qml b/qml/pages/SettingsPage.qml index af215e2..29f84b4 100644 --- a/qml/pages/SettingsPage.qml +++ b/qml/pages/SettingsPage.qml @@ -28,6 +28,13 @@ Page { allowedOrientations: Orientation.All readonly property bool landscapeLayout: (width > height && Screen.sizeCategory > Screen.Small) || Screen.sizeCategory > Screen.Medium + readonly property var userInformation: tdLibWrapper.getUserInformation() + + onStatusChanged: { + if (status === PageStatus.Active) { + tdLibWrapper.getUserProfilePhotos(userInformation.id, 100, 0); + } + } Connections { target: tdLibWrapper @@ -36,6 +43,11 @@ Page { lastNameEditArea.text = userInformation.last_name; userNameEditArea.text = userInformation.username; } + onUserProfilePhotosReceived: { + if (extra === userInformation.id.toString()) { + imageContainer.thumbnailModel = photos; + } + } } SilicaFlickable { @@ -68,7 +80,7 @@ Page { visible: true canEdit: true headerText: qsTr("First Name", "first name of the logged-in profile - header") - text: tdLibWrapper.getUserInformation().first_name + text: userInformation.first_name width: parent.columnWidth headerLeftAligned: true @@ -98,7 +110,7 @@ Page { visible: true canEdit: true headerText: qsTr("Last Name", "last name of the logged-in profile - header") - text: tdLibWrapper.getUserInformation().last_name + text: userInformation.last_name width: parent.columnWidth headerLeftAligned: true @@ -128,7 +140,7 @@ Page { visible: true canEdit: true headerText: qsTr("Username", "user name of the logged-in profile - header") - text: tdLibWrapper.getUserInformation().username + text: userInformation.username width: parent.columnWidth headerLeftAligned: true @@ -139,6 +151,70 @@ Page { } + SectionHeader { + horizontalAlignment: Text.AlignLeft + text: qsTr("Profile Pictures") + } + + Row { + width: parent.width - ( 2 * Theme.horizontalPageMargin ) + spacing: Theme.paddingMedium + + Item { + id: imageContainer + anchors.verticalCenter: parent.verticalCenter + width: parent.width / 2 + height: profilePictureLoader.height + property var thumbnailModel: ({}) + property bool thumbnailVisible: true + property bool thumbnailActive: thumbnailModel.length > 0 + property int thumbnailRadius: imageContainer.width / 2 + + Loader { + id: profilePictureLoader + active: imageContainer.thumbnailActive + asynchronous: true + width: Theme.itemSizeExtraLarge + height: Theme.itemSizeExtraLarge + anchors.horizontalCenter: parent.horizontalCenter + source: "../components/ProfilePictureList.qml" + } + } + + Column { + spacing: Theme.paddingSmall + width: parent.width / 2 + + Button { + id: addProfilePictureButton + text: qsTr("Add Picture") + anchors { + horizontalCenter: parent.horizontalCenter + } + onClicked: { + + } + } + + Button { + id: removeProfilePictureButton + text: qsTr("Remove Picture") + anchors { + horizontalCenter: parent.horizontalCenter + } + onClicked: { + + } + } + + } + } + + SectionHeader { + horizontalAlignment: Text.AlignLeft + text: qsTr("Privacy Options") + } + Grid { width: parent.width columns: landscapeLayout ? 2 : 1 diff --git a/translations/harbour-fernschreiber-de.ts b/translations/harbour-fernschreiber-de.ts index 2c89199..aeda11f 100644 --- a/translations/harbour-fernschreiber-de.ts +++ b/translations/harbour-fernschreiber-de.ts @@ -1616,6 +1616,22 @@ Privacy setting for managing whether your online status is visible. Privatsphären-Einstellung zur Regelung, ob Ihr Onlinestatus sichtbar ist. + + Add Picture + Bild hinzufügen + + + Remove Picture + Bild löschen + + + Profile Pictures + Profilbilder + + + Privacy Options + Optionen zur Privatsphäre + StickerPicker diff --git a/translations/harbour-fernschreiber-en.ts b/translations/harbour-fernschreiber-en.ts index bcf0fe3..480cb70 100644 --- a/translations/harbour-fernschreiber-en.ts +++ b/translations/harbour-fernschreiber-en.ts @@ -1616,6 +1616,22 @@ Privacy setting for managing whether your online status is visible. Privacy setting for managing whether your online status is visible. + + Add Picture + Add Picture + + + Remove Picture + Remove Picture + + + Profile Pictures + Profile Pictures + + + Privacy Options + Privacy Options + StickerPicker diff --git a/translations/harbour-fernschreiber-es.ts b/translations/harbour-fernschreiber-es.ts index 4f8cc22..53e86b0 100644 --- a/translations/harbour-fernschreiber-es.ts +++ b/translations/harbour-fernschreiber-es.ts @@ -1616,6 +1616,22 @@ Privacy setting for managing whether your online status is visible. + + Add Picture + + + + Remove Picture + + + + Profile Pictures + + + + Privacy Options + + StickerPicker diff --git a/translations/harbour-fernschreiber-fi.ts b/translations/harbour-fernschreiber-fi.ts index b036792..a9065fe 100644 --- a/translations/harbour-fernschreiber-fi.ts +++ b/translations/harbour-fernschreiber-fi.ts @@ -1617,6 +1617,22 @@ Privacy setting for managing whether your online status is visible. + + Add Picture + + + + Remove Picture + + + + Profile Pictures + + + + Privacy Options + + StickerPicker diff --git a/translations/harbour-fernschreiber-hu.ts b/translations/harbour-fernschreiber-hu.ts index a788edc..ccc0d70 100644 --- a/translations/harbour-fernschreiber-hu.ts +++ b/translations/harbour-fernschreiber-hu.ts @@ -1591,6 +1591,22 @@ Privacy setting for managing whether your online status is visible. + + Add Picture + + + + Remove Picture + + + + Profile Pictures + + + + Privacy Options + + StickerPicker diff --git a/translations/harbour-fernschreiber-it.ts b/translations/harbour-fernschreiber-it.ts index 3e99343..31c6ad9 100644 --- a/translations/harbour-fernschreiber-it.ts +++ b/translations/harbour-fernschreiber-it.ts @@ -1616,6 +1616,22 @@ Privacy setting for managing whether your online status is visible. + + Add Picture + + + + Remove Picture + + + + Profile Pictures + + + + Privacy Options + + StickerPicker diff --git a/translations/harbour-fernschreiber-pl.ts b/translations/harbour-fernschreiber-pl.ts index 598e234..a73d813 100644 --- a/translations/harbour-fernschreiber-pl.ts +++ b/translations/harbour-fernschreiber-pl.ts @@ -1641,6 +1641,22 @@ Privacy setting for managing whether your online status is visible. + + Add Picture + + + + Remove Picture + + + + Profile Pictures + + + + Privacy Options + + StickerPicker diff --git a/translations/harbour-fernschreiber-ru.ts b/translations/harbour-fernschreiber-ru.ts index 96e588f..72e4189 100644 --- a/translations/harbour-fernschreiber-ru.ts +++ b/translations/harbour-fernschreiber-ru.ts @@ -1641,6 +1641,22 @@ Privacy setting for managing whether your online status is visible. + + Add Picture + + + + Remove Picture + + + + Profile Pictures + + + + Privacy Options + + StickerPicker diff --git a/translations/harbour-fernschreiber-sv.ts b/translations/harbour-fernschreiber-sv.ts index 6b52cd1..b9aa8c0 100644 --- a/translations/harbour-fernschreiber-sv.ts +++ b/translations/harbour-fernschreiber-sv.ts @@ -1616,6 +1616,22 @@ Privacy setting for managing whether your online status is visible. + + Add Picture + + + + Remove Picture + + + + Profile Pictures + + + + Privacy Options + + StickerPicker diff --git a/translations/harbour-fernschreiber-zh_CN.ts b/translations/harbour-fernschreiber-zh_CN.ts index 16e0204..728a33f 100644 --- a/translations/harbour-fernschreiber-zh_CN.ts +++ b/translations/harbour-fernschreiber-zh_CN.ts @@ -1591,6 +1591,22 @@ Privacy setting for managing whether your online status is visible. + + Add Picture + + + + Remove Picture + + + + Profile Pictures + + + + Privacy Options + + StickerPicker diff --git a/translations/harbour-fernschreiber.ts b/translations/harbour-fernschreiber.ts index 14ed7f4..d4f5395 100644 --- a/translations/harbour-fernschreiber.ts +++ b/translations/harbour-fernschreiber.ts @@ -1616,6 +1616,22 @@ Privacy setting for managing whether your online status is visible. + + Add Picture + + + + Remove Picture + + + + Profile Pictures + + + + Privacy Options + + StickerPicker