From 4e6d012a7d5aa2a77445d26a519c548fe7b98214 Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Tue, 19 Jan 2021 00:02:37 +0100 Subject: [PATCH 1/8] Start with personal profile settings --- harbour-fernschreiber.pro | 4 +- qml/components/ChatListViewItem.qml | 2 +- ...onEditArea.qml => InformationEditArea.qml} | 12 ++- ...onTextItem.qml => InformationTextItem.qml} | 7 +- qml/components/MessageListViewItem.qml | 10 +-- .../ChatInformationPageContent.qml | 8 +- .../ChatInformationTabItemDebug.qml | 6 +- qml/pages/SettingsPage.qml | 75 +++++++++++++++++++ src/tdlibwrapper.cpp | 12 +++ src/tdlibwrapper.h | 2 + translations/harbour-fernschreiber-de.ts | 22 ++++++ translations/harbour-fernschreiber-en.ts | 22 ++++++ translations/harbour-fernschreiber-es.ts | 22 ++++++ translations/harbour-fernschreiber-fi.ts | 22 ++++++ translations/harbour-fernschreiber-hu.ts | 22 ++++++ translations/harbour-fernschreiber-it.ts | 22 ++++++ translations/harbour-fernschreiber-pl.ts | 22 ++++++ translations/harbour-fernschreiber-ru.ts | 22 ++++++ translations/harbour-fernschreiber-sv.ts | 22 ++++++ translations/harbour-fernschreiber-zh_CN.ts | 22 ++++++ translations/harbour-fernschreiber.ts | 22 ++++++ 21 files changed, 360 insertions(+), 20 deletions(-) rename qml/components/{chatInformationPage/ChatInformationEditArea.qml => InformationEditArea.qml} (88%) rename qml/components/{chatInformationPage/ChatInformationTextItem.qml => InformationTextItem.qml} (94%) diff --git a/harbour-fernschreiber.pro b/harbour-fernschreiber.pro index 82b4a20..1f255f1 100644 --- a/harbour-fernschreiber.pro +++ b/harbour-fernschreiber.pro @@ -47,6 +47,8 @@ DISTFILES += qml/harbour-fernschreiber.qml \ qml/components/DocumentPreview.qml \ qml/components/GamePreview.qml \ qml/components/ImagePreview.qml \ + qml/components/InformationEditArea.qml \ + qml/components/InformationTextItem.qml \ qml/components/InReplyToRow.qml \ qml/components/InlineQuery.qml \ qml/components/LocationPreview.qml \ @@ -64,7 +66,6 @@ DISTFILES += qml/harbour-fernschreiber.qml \ qml/components/TDLibImage.qml \ qml/components/TDLibThumbnail.qml \ qml/components/VoiceNoteOverlay.qml \ - qml/components/chatInformationPage/ChatInformationEditArea.qml \ qml/components/chatInformationPage/ChatInformationPageContent.qml \ qml/components/chatInformationPage/ChatInformationProfilePicture.qml \ qml/components/chatInformationPage/ChatInformationProfilePictureList.qml \ @@ -73,7 +74,6 @@ DISTFILES += qml/harbour-fernschreiber.qml \ qml/components/chatInformationPage/ChatInformationTabItemMembersGroups.qml \ qml/components/chatInformationPage/ChatInformationTabItemSettings.qml \ qml/components/chatInformationPage/ChatInformationTabView.qml \ - qml/components/chatInformationPage/ChatInformationTextItem.qml \ qml/components/chatInformationPage/EditGroupChatPermissionsColumn.qml \ qml/components/chatInformationPage/EditSuperGroupSlowModeColumn.qml \ qml/components/inlineQueryResults/InlineQueryResult.qml \ diff --git a/qml/components/ChatListViewItem.qml b/qml/components/ChatListViewItem.qml index 684f02a..f893445 100644 --- a/qml/components/ChatListViewItem.qml +++ b/qml/components/ChatListViewItem.qml @@ -18,7 +18,7 @@ PhotoTextsListItem { // chat title primaryText.text: title ? Emoji.emojify(title, Theme.fontSizeMedium) : qsTr("Unknown") // last user - prologSecondaryText.text: showDraft ? ""+qsTr("Draft")+"" : (is_channel ? "" : ( last_message_sender_id ? ( last_message_sender_id !== ownUserId ? Emoji.emojify(Functions.getUserName(tdLibWrapper.getUserInformation(last_message_sender_id)), primaryText.font.pixelSize) : qsTr("You") ) : "" )) + prologSecondaryText.text: showDraft ? ""+qsTr("Draft")+"" : (is_channel ? "" : ( last_message_sender_id ? ( last_message_sender_id !== ownUserId ? Emoji.emojify(Functions.getUserName(tdLibWrapper.getUserInformation(last_message_sender_id)), Theme.fontSizeExtraSmall) : qsTr("You") ) : "" )) // last message secondaryText.text: previewText ? Emoji.emojify(Functions.enhanceHtmlEntities(previewText), Theme.fontSizeExtraSmall) : "" + qsTr("No message in this chat.") + "" // message date diff --git a/qml/components/chatInformationPage/ChatInformationEditArea.qml b/qml/components/InformationEditArea.qml similarity index 88% rename from qml/components/chatInformationPage/ChatInformationEditArea.qml rename to qml/components/InformationEditArea.qml index 863849a..347882d 100644 --- a/qml/components/chatInformationPage/ChatInformationEditArea.qml +++ b/qml/components/InformationEditArea.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. @@ -16,6 +16,7 @@ You should have received a copy of the GNU General Public License along with Fernschreiber. If not, see . */ + import QtQuick 2.6 import Sailfish.Silica 1.0 @@ -27,6 +28,7 @@ Column { property string emptyPlaceholderText property string text property bool multiLine + property bool headerLeftAligned property bool isEditing property Item editItem: multiLine ? editAreaTextArea : editAreaTextField @@ -41,6 +43,7 @@ Column { id: editAreaHeader height: parent.visible && text !== "" ? Theme.itemSizeExtraSmall : 0 x: 0 + horizontalAlignment: headerLeftAligned ? Text.AlignLeft : Text.AlignRight } Row { id: editAreaTextRow @@ -50,25 +53,30 @@ Column { id: editAreaTextArea visible: editAreaColumn.isEditing && editAreaColumn.multiLine width: parent.width - editAreaButton.width + textLeftMargin: 0 anchors.verticalCenter: parent.verticalCenter + font.pixelSize: Theme.fontSizeSmall } TextField { id: editAreaTextField visible: editAreaColumn.isEditing && !editAreaColumn.multiLine width: parent.width - editAreaButton.width anchors.verticalCenter: parent.verticalCenter + textLeftMargin: 0 EnterKey.onClicked: { editAreaColumn.isEditing = false; editAreaColumn.saveButtonClicked(editAreaColumn.editItem.text); } EnterKey.iconSource: editAreaButton.icon.source + font.pixelSize: Theme.fontSizeSmall } - ChatInformationTextItem { + InformationTextItem { id: editAreaTextItem visible: !editAreaColumn.isEditing anchors.verticalCenter: parent.verticalCenter text: editAreaColumn.text || editAreaColumn.emptyPlaceholderText width: parent.width - editAreaButton.width + height: !editAreaColumn.multiLine ? implicitHeight : editAreaTextField.height } IconButton { id: editAreaButton diff --git a/qml/components/chatInformationPage/ChatInformationTextItem.qml b/qml/components/InformationTextItem.qml similarity index 94% rename from qml/components/chatInformationPage/ChatInformationTextItem.qml rename to qml/components/InformationTextItem.qml index db9ca5f..6bf0ad0 100644 --- a/qml/components/chatInformationPage/ChatInformationTextItem.qml +++ b/qml/components/InformationTextItem.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. @@ -16,11 +16,12 @@ You should have received a copy of the GNU General Public License along with Fernschreiber. If not, see . */ + import QtQuick 2.6 import Sailfish.Silica 1.0 -import "../../js/twemoji.js" as Emoji -import "../../js/functions.js" as Functions +import "../js/twemoji.js" as Emoji +import "../js/functions.js" as Functions Column { id: textItem diff --git a/qml/components/MessageListViewItem.qml b/qml/components/MessageListViewItem.qml index 1e81d59..57c6b11 100644 --- a/qml/components/MessageListViewItem.qml +++ b/qml/components/MessageListViewItem.qml @@ -186,11 +186,11 @@ ListItem { } onMyMessageChanged: { - Debug.log("[ChatModel] This message was updated, index", messageIndex, ", updating content...") - messageDateText.text = getMessageStatusText(myMessage, messageIndex, chatView.lastReadSentIndex, messageDateText.useElapsed) - messageText.text = Emoji.emojify(Functions.getMessageText(myMessage, false, page.myUserId, false), messageText.font.pixelSize) + Debug.log("[ChatModel] This message was updated, index", messageIndex, ", updating content..."); + messageDateText.text = getMessageStatusText(myMessage, messageIndex, chatView.lastReadSentIndex, messageDateText.useElapsed); + messageText.text = Emoji.emojify(Functions.getMessageText(myMessage, false, page.myUserId, false), Theme.fontSizeSmall); if (webPagePreviewLoader.item) { - webPagePreviewLoader.item.webPageData = myMessage.content.web_page + webPagePreviewLoader.item.webPageData = myMessage.content.web_page; } } @@ -399,7 +399,7 @@ ListItem { Text { id: messageText width: parent.width - text: Emoji.emojify(Functions.getMessageText(myMessage, false, page.myUserId, false), font.pixelSize) + text: Emoji.emojify(Functions.getMessageText(myMessage, false, page.myUserId, false), Theme.fontSizeMedium) font.pixelSize: Theme.fontSizeSmall color: messageListItem.textColor wrapMode: Text.Wrap diff --git a/qml/components/chatInformationPage/ChatInformationPageContent.qml b/qml/components/chatInformationPage/ChatInformationPageContent.qml index 021377f..e1985f9 100644 --- a/qml/components/chatInformationPage/ChatInformationPageContent.qml +++ b/qml/components/chatInformationPage/ChatInformationPageContent.qml @@ -350,7 +350,7 @@ SilicaFlickable { height: imageContainer.hasImage ? imageContainer.maxDimension : 0 } - ChatInformationEditArea { + InformationEditArea { visible: canEdit canEdit: !(chatInformationPage.isPrivateChat || chatInformationPage.isSecretChat) && chatInformationPage.groupInformation.status && (chatInformationPage.groupInformation.status.can_change_info || chatInformationPage.groupInformation.status["@type"] === "chatMemberStatusCreator") headerText: qsTr("Chat Title", "group title header") @@ -376,7 +376,7 @@ SilicaFlickable { } } } - ChatInformationEditArea { + InformationEditArea { canEdit: ((chatInformationPage.isPrivateChat || chatInformationPage.isSecretChat) && chatInformationPage.privateChatUserInformation.id === chatInformationPage.myUserId) || ((chatInformationPage.isBasicGroup || chatInformationPage.isSuperGroup) && chatInformationPage.groupInformation && (chatInformationPage.groupInformation.status.can_change_info || chatInformationPage.groupInformation.status["@type"] === "chatMemberStatusCreator")) emptyPlaceholderText: qsTr("There is no information text available, yet.") headerText: qsTr("Info", "group or user infotext header") @@ -391,7 +391,7 @@ SilicaFlickable { } } - ChatInformationTextItem { + InformationTextItem { headerText: qsTr("Phone Number", "user phone number header") text: ((chatInformationPage.isPrivateChat || chatInformationPage.isSecretChat) && chatInformationPage.privateChatUserInformation.phone_number ? "+"+chatInformationPage.privateChatUserInformation.phone_number : "") || "" isLinkedLabel: true @@ -408,7 +408,7 @@ SilicaFlickable { Row { width: parent.width visible: !!inviteLinkItem.text - ChatInformationTextItem { + InformationTextItem { id: inviteLinkItem text: !(chatInformationPage.isPrivateChat || chatInformationPage.isSecretChat) ? chatInformationPage.groupFullInformation.invite_link : "" width: parent.width - inviteLinkButton.width diff --git a/qml/components/chatInformationPage/ChatInformationTabItemDebug.qml b/qml/components/chatInformationPage/ChatInformationTabItemDebug.qml index 6696c1c..4d15bc3 100644 --- a/qml/components/chatInformationPage/ChatInformationTabItemDebug.qml +++ b/qml/components/chatInformationPage/ChatInformationTabItemDebug.qml @@ -38,18 +38,18 @@ ChatInformationTabItemBase { width: tabBase.width - Theme.horizontalPageMargin * 2 x: Theme.horizontalPageMargin - ChatInformationTextItem { + InformationTextItem { headerText: "chatInformation" text:chatInformationPage.chatInformation ? JSON.stringify(chatInformationPage.chatInformation, null, 2) : "" isLinkedLabel: true } - ChatInformationTextItem { + InformationTextItem { headerText: "groupInformation" text: chatInformationPage.groupInformation ? JSON.stringify(chatInformationPage.groupInformation, null, 2) : "" isLinkedLabel: true } - ChatInformationTextItem { + InformationTextItem { headerText: "groupFullInformation" text: chatInformationPage.groupFullInformation ? JSON.stringify(chatInformationPage.groupFullInformation, null, 2) : "" isLinkedLabel: true diff --git a/qml/pages/SettingsPage.qml b/qml/pages/SettingsPage.qml index b2bf0f6..4b755bd 100644 --- a/qml/pages/SettingsPage.qml +++ b/qml/pages/SettingsPage.qml @@ -19,6 +19,7 @@ import QtQuick 2.6 import Sailfish.Silica 1.0 import WerkWolf.Fernschreiber 1.0 +import "../components" import "../js/functions.js" as Functions Page { @@ -27,6 +28,14 @@ Page { readonly property bool landscapeLayout: (width > height && Screen.sizeCategory > Screen.Small) || Screen.sizeCategory > Screen.Medium + Connections { + target: tdLibWrapper + onOwnUserUpdated: { + firstNameEditArea.text = userInformation.first_name; + lastNameEditArea.text = userInformation.last_name; + } + } + SilicaFlickable { id: settingsContainer contentHeight: column.height @@ -40,6 +49,72 @@ Page { title: qsTr("Settings") } + SectionHeader { + text: qsTr("User Profile") + } + + InformationEditArea { + id: firstNameEditArea + visible: true + canEdit: true + headerText: qsTr("First Name", "first name of the logged-in profile - header") + text: tdLibWrapper.getUserInformation().first_name + width: parent.width - ( 2 * Theme.horizontalPageMargin ) + headerLeftAligned: true + anchors.horizontalCenter: parent.horizontalCenter + + onSaveButtonClicked: { + if(!editItem.errorHighlight) { + tdLibWrapper.setName(textValue, lastNameEditArea.text); + } else { + isEditing = true; + } + } + + onTextEdited: { + if(textValue.length > 0 && textValue.length < 65) { + editItem.errorHighlight = false; + editItem.label = ""; + editItem.placeholderText = ""; + } else { + editItem.label = qsTr("Enter 1-64 characters"); + editItem.placeholderText = editItem.label; + editItem.errorHighlight = true; + } + } + } + + InformationEditArea { + id: lastNameEditArea + visible: true + canEdit: true + headerText: qsTr("Last Name", "last name of the logged-in profile - header") + text: tdLibWrapper.getUserInformation().last_name + width: parent.width - ( 2 * Theme.horizontalPageMargin ) + headerLeftAligned: true + anchors.horizontalCenter: parent.horizontalCenter + + onSaveButtonClicked: { + if(!editItem.errorHighlight) { + tdLibWrapper.setName(firstNameEditArea.text, textValue); + } else { + isEditing = true; + } + } + + onTextEdited: { + if(textValue.length >= 0 && textValue.length < 65) { + editItem.errorHighlight = false; + editItem.label = ""; + editItem.placeholderText = ""; + } else { + editItem.label = qsTr("Enter 0-64 characters"); + editItem.placeholderText = editItem.label; + editItem.errorHighlight = true; + } + } + } + SectionHeader { text: qsTr("Behavior") } diff --git a/src/tdlibwrapper.cpp b/src/tdlibwrapper.cpp index 5446f7e..7cb2b73 100644 --- a/src/tdlibwrapper.cpp +++ b/src/tdlibwrapper.cpp @@ -1177,6 +1177,17 @@ void TDLibWrapper::deleteFile(int fileId) this->sendRequest(requestObject); } +void TDLibWrapper::setName(const QString &firstName, const QString &lastName) +{ + LOG("Set name of current user" << firstName << lastName); + QVariantMap requestObject; + requestObject.insert(_TYPE, "setName"); + requestObject.insert("first_name", firstName); + requestObject.insert("last_name", lastName); + + this->sendRequest(requestObject); +} + void TDLibWrapper::searchEmoji(const QString &queryString) { LOG("Searching emoji" << queryString); @@ -1431,6 +1442,7 @@ void TDLibWrapper::handleUserUpdated(const QVariantMap &userInformation) if (updatedUserId == this->options.value("my_id").toString()) { LOG("Own user information updated :)"); this->userInformation = userInformation; + emit ownUserUpdated(userInformation); } LOG("User information updated:" << userInformation.value(USERNAME).toString() << userInformation.value(FIRST_NAME).toString() << userInformation.value(LAST_NAME).toString()); this->allUsers.insert(updatedUserId, userInformation); diff --git a/src/tdlibwrapper.h b/src/tdlibwrapper.h index 8b1ce90..8a5e81b 100644 --- a/src/tdlibwrapper.h +++ b/src/tdlibwrapper.h @@ -196,6 +196,7 @@ public: Q_INVOKABLE void cancelDownloadFile(int fileId); Q_INVOKABLE void cancelUploadFile(int fileId); Q_INVOKABLE void deleteFile(int fileId); + Q_INVOKABLE void setName(const QString &firstName, const QString &lastName); // Others (candidates for extraction ;)) Q_INVOKABLE void searchEmoji(const QString &queryString); @@ -224,6 +225,7 @@ signals: void chatReadInboxUpdated(const QString &chatId, const QString &lastReadInboxMessageId, int unreadCount); void chatReadOutboxUpdated(const QString &chatId, const QString &lastReadOutboxMessageId); void userUpdated(const QString &userId, const QVariantMap &userInformation); + void ownUserUpdated(const QVariantMap &userInformation); void basicGroupUpdated(qlonglong groupId); void superGroupUpdated(qlonglong groupId); void chatOnlineMemberCountUpdated(const QString &chatId, int onlineMemberCount); diff --git a/translations/harbour-fernschreiber-de.ts b/translations/harbour-fernschreiber-de.ts index 28add57..201cc4c 100644 --- a/translations/harbour-fernschreiber-de.ts +++ b/translations/harbour-fernschreiber-de.ts @@ -1508,6 +1508,28 @@ Some inline bots request location data when using them Einige Inline-Bots fragen bei Nutzung Standortdaten an + + User Profile + + + + First Name + first name of the logged-in profile - header + + + + Enter 1-64 characters + Geben Sie 1-128 Zeichen ein {1-64 ?} + + + Last Name + last name of the logged-in profile - header + + + + Enter 0-64 characters + Geben Sie 1-128 Zeichen ein {0-64 ?} + StickerPicker diff --git a/translations/harbour-fernschreiber-en.ts b/translations/harbour-fernschreiber-en.ts index 3d0fcce..29bd00f 100644 --- a/translations/harbour-fernschreiber-en.ts +++ b/translations/harbour-fernschreiber-en.ts @@ -1508,6 +1508,28 @@ Some inline bots request location data when using them Some inline bots request location data when using them + + User Profile + + + + First Name + first name of the logged-in profile - header + + + + Enter 1-64 characters + Enter 1-128 characters {1-64 ?} + + + Last Name + last name of the logged-in profile - header + + + + Enter 0-64 characters + Enter 1-128 characters {0-64 ?} + StickerPicker diff --git a/translations/harbour-fernschreiber-es.ts b/translations/harbour-fernschreiber-es.ts index 6bd0ef7..ff8d1cb 100644 --- a/translations/harbour-fernschreiber-es.ts +++ b/translations/harbour-fernschreiber-es.ts @@ -1508,6 +1508,28 @@ Some inline bots request location data when using them + + User Profile + + + + First Name + first name of the logged-in profile - header + + + + Enter 1-64 characters + Marcar caracteres 1-128 {1-64 ?} + + + Last Name + last name of the logged-in profile - header + + + + Enter 0-64 characters + Marcar caracteres 1-128 {0-64 ?} + StickerPicker diff --git a/translations/harbour-fernschreiber-fi.ts b/translations/harbour-fernschreiber-fi.ts index f1595d0..2f6c57a 100644 --- a/translations/harbour-fernschreiber-fi.ts +++ b/translations/harbour-fernschreiber-fi.ts @@ -1509,6 +1509,28 @@ Some inline bots request location data when using them + + User Profile + + + + First Name + first name of the logged-in profile - header + + + + Enter 1-64 characters + Syötä 1-128 merkkiä {1-64 ?} + + + Last Name + last name of the logged-in profile - header + + + + Enter 0-64 characters + Syötä 1-128 merkkiä {0-64 ?} + StickerPicker diff --git a/translations/harbour-fernschreiber-hu.ts b/translations/harbour-fernschreiber-hu.ts index e289d2a..8add7fa 100644 --- a/translations/harbour-fernschreiber-hu.ts +++ b/translations/harbour-fernschreiber-hu.ts @@ -1483,6 +1483,28 @@ Some inline bots request location data when using them + + User Profile + + + + First Name + first name of the logged-in profile - header + + + + Enter 1-64 characters + + + + Last Name + last name of the logged-in profile - header + + + + Enter 0-64 characters + + StickerPicker diff --git a/translations/harbour-fernschreiber-it.ts b/translations/harbour-fernschreiber-it.ts index 3feba91..0d084c6 100644 --- a/translations/harbour-fernschreiber-it.ts +++ b/translations/harbour-fernschreiber-it.ts @@ -1508,6 +1508,28 @@ Some inline bots request location data when using them + + User Profile + + + + First Name + first name of the logged-in profile - header + + + + Enter 1-64 characters + Inserisci da 1 a 128 caratteri {1-64 ?} + + + Last Name + last name of the logged-in profile - header + + + + Enter 0-64 characters + Inserisci da 1 a 128 caratteri {0-64 ?} + StickerPicker diff --git a/translations/harbour-fernschreiber-pl.ts b/translations/harbour-fernschreiber-pl.ts index 23e0666..bcdfec7 100644 --- a/translations/harbour-fernschreiber-pl.ts +++ b/translations/harbour-fernschreiber-pl.ts @@ -1533,6 +1533,28 @@ Some inline bots request location data when using them + + User Profile + + + + First Name + first name of the logged-in profile - header + + + + Enter 1-64 characters + Wprowadź znaki 1-128 {1-64 ?} + + + Last Name + last name of the logged-in profile - header + + + + Enter 0-64 characters + Wprowadź znaki 1-128 {0-64 ?} + StickerPicker diff --git a/translations/harbour-fernschreiber-ru.ts b/translations/harbour-fernschreiber-ru.ts index 23bfce7..fe8f812 100644 --- a/translations/harbour-fernschreiber-ru.ts +++ b/translations/harbour-fernschreiber-ru.ts @@ -1533,6 +1533,28 @@ Some inline bots request location data when using them + + User Profile + + + + First Name + first name of the logged-in profile - header + + + + Enter 1-64 characters + Введите 1-128 символов {1-64 ?} + + + Last Name + last name of the logged-in profile - header + + + + Enter 0-64 characters + Введите 1-128 символов {0-64 ?} + StickerPicker diff --git a/translations/harbour-fernschreiber-sv.ts b/translations/harbour-fernschreiber-sv.ts index 48a27cd..86456bc 100644 --- a/translations/harbour-fernschreiber-sv.ts +++ b/translations/harbour-fernschreiber-sv.ts @@ -1508,6 +1508,28 @@ Some inline bots request location data when using them + + User Profile + + + + First Name + first name of the logged-in profile - header + + + + Enter 1-64 characters + Ange 1-128 tecken {1-64 ?} + + + Last Name + last name of the logged-in profile - header + + + + Enter 0-64 characters + Ange 1-128 tecken {0-64 ?} + StickerPicker diff --git a/translations/harbour-fernschreiber-zh_CN.ts b/translations/harbour-fernschreiber-zh_CN.ts index 40bcda9..1e3a881 100644 --- a/translations/harbour-fernschreiber-zh_CN.ts +++ b/translations/harbour-fernschreiber-zh_CN.ts @@ -1483,6 +1483,28 @@ Some inline bots request location data when using them 使用某些内联机器人时会请求位置数据 + + User Profile + + + + First Name + first name of the logged-in profile - header + + + + Enter 1-64 characters + 输入 1-128 个字符 {1-64 ?} + + + Last Name + last name of the logged-in profile - header + + + + Enter 0-64 characters + 输入 1-128 个字符 {0-64 ?} + StickerPicker diff --git a/translations/harbour-fernschreiber.ts b/translations/harbour-fernschreiber.ts index bfdd7b4..9039576 100644 --- a/translations/harbour-fernschreiber.ts +++ b/translations/harbour-fernschreiber.ts @@ -1508,6 +1508,28 @@ Some inline bots request location data when using them + + User Profile + + + + First Name + first name of the logged-in profile - header + + + + Enter 1-64 characters + Enter 1-128 characters {1-64 ?} + + + Last Name + last name of the logged-in profile - header + + + + Enter 0-64 characters + Enter 1-128 characters {0-64 ?} + StickerPicker From f0d14bc44069cb0da5b07fd13df5f7f47d432013 Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Tue, 19 Jan 2021 23:58:58 +0100 Subject: [PATCH 2/8] Change username, prepare privacy setting rules --- qml/pages/SettingsPage.qml | 117 ++++++++++++-------- src/tdlibwrapper.cpp | 62 +++++++++++ src/tdlibwrapper.h | 20 ++++ translations/harbour-fernschreiber-de.ts | 5 + translations/harbour-fernschreiber-en.ts | 5 + translations/harbour-fernschreiber-es.ts | 5 + translations/harbour-fernschreiber-fi.ts | 5 + translations/harbour-fernschreiber-hu.ts | 5 + translations/harbour-fernschreiber-it.ts | 5 + translations/harbour-fernschreiber-pl.ts | 5 + translations/harbour-fernschreiber-ru.ts | 5 + translations/harbour-fernschreiber-sv.ts | 5 + translations/harbour-fernschreiber-zh_CN.ts | 5 + translations/harbour-fernschreiber.ts | 5 + 14 files changed, 207 insertions(+), 47 deletions(-) diff --git a/qml/pages/SettingsPage.qml b/qml/pages/SettingsPage.qml index 4b755bd..94fc6dd 100644 --- a/qml/pages/SettingsPage.qml +++ b/qml/pages/SettingsPage.qml @@ -33,6 +33,7 @@ Page { onOwnUserUpdated: { firstNameEditArea.text = userInformation.first_name; lastNameEditArea.text = userInformation.last_name; + userNameEditArea.text = userInformation.username; } } @@ -53,66 +54,88 @@ Page { text: qsTr("User Profile") } - InformationEditArea { - id: firstNameEditArea - visible: true - canEdit: true - headerText: qsTr("First Name", "first name of the logged-in profile - header") - text: tdLibWrapper.getUserInformation().first_name + Grid { width: parent.width - ( 2 * Theme.horizontalPageMargin ) - headerLeftAligned: true + columns: landscapeLayout ? 2 : 1 + columnSpacing: Theme.horizontalPageMargin anchors.horizontalCenter: parent.horizontalCenter - onSaveButtonClicked: { - if(!editItem.errorHighlight) { - tdLibWrapper.setName(textValue, lastNameEditArea.text); - } else { - isEditing = true; + readonly property real columnWidth: width/columns + + InformationEditArea { + id: firstNameEditArea + visible: true + canEdit: true + headerText: qsTr("First Name", "first name of the logged-in profile - header") + text: tdLibWrapper.getUserInformation().first_name + width: parent.columnWidth + headerLeftAligned: true + + onSaveButtonClicked: { + if(!editItem.errorHighlight) { + tdLibWrapper.setName(textValue, lastNameEditArea.text); + } else { + isEditing = true; + } + } + + onTextEdited: { + if(textValue.length > 0 && textValue.length < 65) { + editItem.errorHighlight = false; + editItem.label = ""; + editItem.placeholderText = ""; + } else { + editItem.label = qsTr("Enter 1-64 characters"); + editItem.placeholderText = editItem.label; + editItem.errorHighlight = true; + } } } - onTextEdited: { - if(textValue.length > 0 && textValue.length < 65) { - editItem.errorHighlight = false; - editItem.label = ""; - editItem.placeholderText = ""; - } else { - editItem.label = qsTr("Enter 1-64 characters"); - editItem.placeholderText = editItem.label; - editItem.errorHighlight = true; + InformationEditArea { + id: lastNameEditArea + visible: true + canEdit: true + headerText: qsTr("Last Name", "last name of the logged-in profile - header") + text: tdLibWrapper.getUserInformation().last_name + width: parent.columnWidth + headerLeftAligned: true + + onSaveButtonClicked: { + if(!editItem.errorHighlight) { + tdLibWrapper.setName(firstNameEditArea.text, textValue); + } else { + isEditing = true; + } } - } - } - InformationEditArea { - id: lastNameEditArea - visible: true - canEdit: true - headerText: qsTr("Last Name", "last name of the logged-in profile - header") - text: tdLibWrapper.getUserInformation().last_name - width: parent.width - ( 2 * Theme.horizontalPageMargin ) - headerLeftAligned: true - anchors.horizontalCenter: parent.horizontalCenter - - onSaveButtonClicked: { - if(!editItem.errorHighlight) { - tdLibWrapper.setName(firstNameEditArea.text, textValue); - } else { - isEditing = true; + onTextEdited: { + if(textValue.length >= 0 && textValue.length < 65) { + editItem.errorHighlight = false; + editItem.label = ""; + editItem.placeholderText = ""; + } else { + editItem.label = qsTr("Enter 0-64 characters"); + editItem.placeholderText = editItem.label; + editItem.errorHighlight = true; + } } } - onTextEdited: { - if(textValue.length >= 0 && textValue.length < 65) { - editItem.errorHighlight = false; - editItem.label = ""; - editItem.placeholderText = ""; - } else { - editItem.label = qsTr("Enter 0-64 characters"); - editItem.placeholderText = editItem.label; - editItem.errorHighlight = true; + InformationEditArea { + id: userNameEditArea + visible: true + canEdit: true + headerText: qsTr("Username", "user name of the logged-in profile - header") + text: tdLibWrapper.getUserInformation().username + width: parent.columnWidth + headerLeftAligned: true + + onSaveButtonClicked: { + tdLibWrapper.setUsername(textValue); } } + } SectionHeader { diff --git a/src/tdlibwrapper.cpp b/src/tdlibwrapper.cpp index 7cb2b73..3de2e99 100644 --- a/src/tdlibwrapper.cpp +++ b/src/tdlibwrapper.cpp @@ -1188,6 +1188,68 @@ void TDLibWrapper::setName(const QString &firstName, const QString &lastName) this->sendRequest(requestObject); } +void TDLibWrapper::setUsername(const QString &userName) +{ + LOG("Set username of current user" << userName); + QVariantMap requestObject; + requestObject.insert(_TYPE, "setUsername"); + requestObject.insert("username", userName); + + this->sendRequest(requestObject); +} + +void TDLibWrapper::setUserPrivacySettingRule(TDLibWrapper::UserPrivacySetting setting, TDLibWrapper::UserPrivacySettingRule rule) +{ + LOG("Set user privecy setting rule of current user" << setting << rule); + QVariantMap requestObject; + requestObject.insert(_TYPE, "setUserPrivacySettingRules"); + + QVariantMap settingMap; + switch (setting) { + case SettingShowStatus: + settingMap.insert(_TYPE, "userPrivacySettingShowStatus"); + break; + case SettingShowPhoneNumber: + settingMap.insert(_TYPE, "userPrivacySettingShowPhoneNumber"); + break; + case SettingAllowChatInvites: + settingMap.insert(_TYPE, "userPrivacySettingAllowChatInvites"); + break; + case SettingShowProfilePhoto: + settingMap.insert(_TYPE, "userPrivacySettingShowProfilePhoto"); + break; + case SettingAllowFindingByPhoneNumber: + settingMap.insert(_TYPE, "userPrivacySettingAllowFindingByPhoneNumber"); + break; + case SettingShowLinkInForwardedMessages: + settingMap.insert(_TYPE, "userPrivacySettingShowLinkInForwardedMessages"); + break; + } + requestObject.insert("setting", settingMap); + + + QVariantMap ruleMap; + switch (rule) { + case RuleAllowAll: + ruleMap.insert(_TYPE, "userPrivacySettingRuleAllowAll"); + break; + case RuleAllowContacts: + ruleMap.insert(_TYPE, "userPrivacySettingRuleAllowContacts"); + break; + case RuleRestrictAll: + ruleMap.insert(_TYPE, "userPrivacySettingRuleRestrictAll"); + break; + case RuleRestrictContacts: + ruleMap.insert(_TYPE, "userPrivacySettingRuleRestrictContacts"); + break; + } + QVariantList ruleMaps; + ruleMaps.append(ruleMap); + requestObject.insert("rules", ruleMaps); + + this->sendRequest(requestObject); +} + void TDLibWrapper::searchEmoji(const QString &queryString) { LOG("Searching emoji" << queryString); diff --git a/src/tdlibwrapper.h b/src/tdlibwrapper.h index 8a5e81b..e4b8791 100644 --- a/src/tdlibwrapper.h +++ b/src/tdlibwrapper.h @@ -89,6 +89,24 @@ public: }; Q_ENUM(SecretChatState) + enum UserPrivacySetting { + SettingAllowChatInvites, + SettingAllowFindingByPhoneNumber, + SettingShowLinkInForwardedMessages, + SettingShowPhoneNumber, + SettingShowProfilePhoto, + SettingShowStatus + }; + Q_ENUM(UserPrivacySetting) + + enum UserPrivacySettingRule { + RuleAllowAll, + RuleAllowContacts, + RuleRestrictAll, + RuleRestrictContacts + }; + Q_ENUM(UserPrivacySettingRule) + class Group { public: Group(qlonglong id) : groupId(id) { } @@ -197,6 +215,8 @@ public: Q_INVOKABLE void cancelUploadFile(int fileId); Q_INVOKABLE void deleteFile(int fileId); Q_INVOKABLE void setName(const QString &firstName, const QString &lastName); + Q_INVOKABLE void setUsername(const QString &userName); + Q_INVOKABLE void setUserPrivacySettingRule(UserPrivacySetting setting, UserPrivacySettingRule rule); // Others (candidates for extraction ;)) Q_INVOKABLE void searchEmoji(const QString &queryString); diff --git a/translations/harbour-fernschreiber-de.ts b/translations/harbour-fernschreiber-de.ts index 201cc4c..64d3fb2 100644 --- a/translations/harbour-fernschreiber-de.ts +++ b/translations/harbour-fernschreiber-de.ts @@ -1530,6 +1530,11 @@ Enter 0-64 characters Geben Sie 1-128 Zeichen ein {0-64 ?} + + Username + user name of the logged-in profile - header + + StickerPicker diff --git a/translations/harbour-fernschreiber-en.ts b/translations/harbour-fernschreiber-en.ts index 29bd00f..bde4a28 100644 --- a/translations/harbour-fernschreiber-en.ts +++ b/translations/harbour-fernschreiber-en.ts @@ -1530,6 +1530,11 @@ Enter 0-64 characters Enter 1-128 characters {0-64 ?} + + Username + user name of the logged-in profile - header + + StickerPicker diff --git a/translations/harbour-fernschreiber-es.ts b/translations/harbour-fernschreiber-es.ts index ff8d1cb..1f535e3 100644 --- a/translations/harbour-fernschreiber-es.ts +++ b/translations/harbour-fernschreiber-es.ts @@ -1530,6 +1530,11 @@ Enter 0-64 characters Marcar caracteres 1-128 {0-64 ?} + + Username + user name of the logged-in profile - header + + StickerPicker diff --git a/translations/harbour-fernschreiber-fi.ts b/translations/harbour-fernschreiber-fi.ts index 2f6c57a..86246b6 100644 --- a/translations/harbour-fernschreiber-fi.ts +++ b/translations/harbour-fernschreiber-fi.ts @@ -1531,6 +1531,11 @@ Enter 0-64 characters Syötä 1-128 merkkiä {0-64 ?} + + Username + user name of the logged-in profile - header + + StickerPicker diff --git a/translations/harbour-fernschreiber-hu.ts b/translations/harbour-fernschreiber-hu.ts index 8add7fa..9a22ce9 100644 --- a/translations/harbour-fernschreiber-hu.ts +++ b/translations/harbour-fernschreiber-hu.ts @@ -1505,6 +1505,11 @@ Enter 0-64 characters + + Username + user name of the logged-in profile - header + + StickerPicker diff --git a/translations/harbour-fernschreiber-it.ts b/translations/harbour-fernschreiber-it.ts index 0d084c6..37de8d1 100644 --- a/translations/harbour-fernschreiber-it.ts +++ b/translations/harbour-fernschreiber-it.ts @@ -1530,6 +1530,11 @@ Enter 0-64 characters Inserisci da 1 a 128 caratteri {0-64 ?} + + Username + user name of the logged-in profile - header + + StickerPicker diff --git a/translations/harbour-fernschreiber-pl.ts b/translations/harbour-fernschreiber-pl.ts index bcdfec7..7fcc53b 100644 --- a/translations/harbour-fernschreiber-pl.ts +++ b/translations/harbour-fernschreiber-pl.ts @@ -1555,6 +1555,11 @@ Enter 0-64 characters Wprowadź znaki 1-128 {0-64 ?} + + Username + user name of the logged-in profile - header + + StickerPicker diff --git a/translations/harbour-fernschreiber-ru.ts b/translations/harbour-fernschreiber-ru.ts index fe8f812..d5838fc 100644 --- a/translations/harbour-fernschreiber-ru.ts +++ b/translations/harbour-fernschreiber-ru.ts @@ -1555,6 +1555,11 @@ Enter 0-64 characters Введите 1-128 символов {0-64 ?} + + Username + user name of the logged-in profile - header + + StickerPicker diff --git a/translations/harbour-fernschreiber-sv.ts b/translations/harbour-fernschreiber-sv.ts index 86456bc..bbe7ff7 100644 --- a/translations/harbour-fernschreiber-sv.ts +++ b/translations/harbour-fernschreiber-sv.ts @@ -1530,6 +1530,11 @@ Enter 0-64 characters Ange 1-128 tecken {0-64 ?} + + Username + user name of the logged-in profile - header + + StickerPicker diff --git a/translations/harbour-fernschreiber-zh_CN.ts b/translations/harbour-fernschreiber-zh_CN.ts index 1e3a881..4bf6589 100644 --- a/translations/harbour-fernschreiber-zh_CN.ts +++ b/translations/harbour-fernschreiber-zh_CN.ts @@ -1505,6 +1505,11 @@ Enter 0-64 characters 输入 1-128 个字符 {0-64 ?} + + Username + user name of the logged-in profile - header + + StickerPicker diff --git a/translations/harbour-fernschreiber.ts b/translations/harbour-fernschreiber.ts index 9039576..ab8b218 100644 --- a/translations/harbour-fernschreiber.ts +++ b/translations/harbour-fernschreiber.ts @@ -1530,6 +1530,11 @@ Enter 0-64 characters Enter 1-128 characters {0-64 ?} + + Username + user name of the logged-in profile - header + + StickerPicker From 9a5db3e83feccd9d3b7b1b2a3d8b6d8ce12396b3 Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Sun, 24 Jan 2021 23:46:30 +0100 Subject: [PATCH 3/8] Next steps towards supporting user preferences --- qml/components/InformationEditArea.qml | 4 +- qml/components/InformationTextItem.qml | 2 +- qml/pages/OverviewPage.qml | 6 + qml/pages/SettingsPage.qml | 224 ++++++++++++++++++++ src/tdlibreceiver.cpp | 15 +- src/tdlibreceiver.h | 4 + src/tdlibwrapper.cpp | 102 ++++++++- src/tdlibwrapper.h | 12 +- translations/harbour-fernschreiber-de.ts | 60 ++++++ translations/harbour-fernschreiber-en.ts | 60 ++++++ translations/harbour-fernschreiber-es.ts | 60 ++++++ translations/harbour-fernschreiber-fi.ts | 60 ++++++ translations/harbour-fernschreiber-hu.ts | 60 ++++++ translations/harbour-fernschreiber-it.ts | 60 ++++++ translations/harbour-fernschreiber-pl.ts | 60 ++++++ translations/harbour-fernschreiber-ru.ts | 60 ++++++ translations/harbour-fernschreiber-sv.ts | 60 ++++++ translations/harbour-fernschreiber-zh_CN.ts | 60 ++++++ translations/harbour-fernschreiber.ts | 60 ++++++ 19 files changed, 1017 insertions(+), 12 deletions(-) diff --git a/qml/components/InformationEditArea.qml b/qml/components/InformationEditArea.qml index 347882d..7659ff2 100644 --- a/qml/components/InformationEditArea.qml +++ b/qml/components/InformationEditArea.qml @@ -55,7 +55,7 @@ Column { width: parent.width - editAreaButton.width textLeftMargin: 0 anchors.verticalCenter: parent.verticalCenter - font.pixelSize: Theme.fontSizeSmall + font.pixelSize: Theme.fontSizeMedium } TextField { id: editAreaTextField @@ -68,7 +68,7 @@ Column { editAreaColumn.saveButtonClicked(editAreaColumn.editItem.text); } EnterKey.iconSource: editAreaButton.icon.source - font.pixelSize: Theme.fontSizeSmall + font.pixelSize: Theme.fontSizeMedium } InformationTextItem { id: editAreaTextItem diff --git a/qml/components/InformationTextItem.qml b/qml/components/InformationTextItem.qml index 6bf0ad0..1dee1bb 100644 --- a/qml/components/InformationTextItem.qml +++ b/qml/components/InformationTextItem.qml @@ -48,7 +48,7 @@ Column { id: labelComponent Label { wrapMode: Text.WrapAtWordBoundaryOrAnywhere - font.pixelSize: Theme.fontSizeSmall + font.pixelSize: Theme.fontSizeMedium textFormat: Text.StyledText color: Theme.primaryColor text: Emoji.emojify( Functions.replaceUrlsWithLinks(textItem.text).replace(/\n/g, "
"), Theme.fontSizeExtraSmall) diff --git a/qml/pages/OverviewPage.qml b/qml/pages/OverviewPage.qml index 40a9bc1..7a55c39 100644 --- a/qml/pages/OverviewPage.qml +++ b/qml/pages/OverviewPage.qml @@ -92,6 +92,12 @@ Page { tdLibWrapper.getRecentStickers(); tdLibWrapper.getInstalledStickerSets(); tdLibWrapper.getContacts(); + tdLibWrapper.getUserPrivacySettingRules(TelegramAPI.SettingAllowChatInvites); + tdLibWrapper.getUserPrivacySettingRules(TelegramAPI.SettingAllowFindingByPhoneNumber); + tdLibWrapper.getUserPrivacySettingRules(TelegramAPI.SettingShowLinkInForwardedMessages); + tdLibWrapper.getUserPrivacySettingRules(TelegramAPI.SettingShowPhoneNumber); + tdLibWrapper.getUserPrivacySettingRules(TelegramAPI.SettingShowProfilePhoto); + tdLibWrapper.getUserPrivacySettingRules(TelegramAPI.SettingShowStatus); } } diff --git a/qml/pages/SettingsPage.qml b/qml/pages/SettingsPage.qml index 94fc6dd..af215e2 100644 --- a/qml/pages/SettingsPage.qml +++ b/qml/pages/SettingsPage.qml @@ -21,6 +21,7 @@ import Sailfish.Silica 1.0 import WerkWolf.Fernschreiber 1.0 import "../components" import "../js/functions.js" as Functions +import "../js/debug.js" as Debug Page { id: settingsPage @@ -138,6 +139,229 @@ Page { } + Grid { + width: parent.width + columns: landscapeLayout ? 2 : 1 + columnSpacing: Theme.horizontalPageMargin + anchors.horizontalCenter: parent.horizontalCenter + + readonly property real columnWidth: width/columns + + Connections { + target: tdLibWrapper + onUserPrivacySettingUpdated: { + Debug.log("Received updated privacy setting: " + setting + ":" + rule); + switch (setting) { + case TelegramAPI.SettingAllowChatInvites: + allowChatInvitesComboBox.currentIndex = rule; + break; + case TelegramAPI.SettingAllowFindingByPhoneNumber: + allowFindingByPhoneNumberComboBox.currentIndex = rule; + break; + case TelegramAPI.SettingShowLinkInForwardedMessages: + showLinkInForwardedMessagesComboBox.currentIndex = rule; + break; + case TelegramAPI.SettingShowPhoneNumber: + showPhoneNumberComboBox.currentIndex = rule; + break; + case TelegramAPI.SettingShowProfilePhoto: + showProfilePhotoComboBox.currentIndex = rule; + break; + case TelegramAPI.SettingShowStatus: + showStatusComboBox.currentIndex = rule; + break; + } + } + } + + ComboBox { + id: allowChatInvitesComboBox + width: parent.columnWidth + label: qsTr("Allow chat invites") + description: qsTr("Privacy setting for managing whether you can be invited to chats.") + menu: ContextMenu { + + MenuItem { + text: qsTr("Yes") + onClicked: { + tdLibWrapper.setUserPrivacySettingRule(TelegramAPI.SettingAllowChatInvites, TelegramAPI.RuleAllowAll); + } + } + MenuItem { + text: qsTr("Your contacts only") + onClicked: { + tdLibWrapper.setUserPrivacySettingRule(TelegramAPI.SettingAllowChatInvites, TelegramAPI.RuleAllowContacts); + } + } + MenuItem { + text: qsTr("No") + onClicked: { + tdLibWrapper.setUserPrivacySettingRule(TelegramAPI.SettingAllowChatInvites, TelegramAPI.RuleRestrictAll); + } + } + } + + Component.onCompleted: { + currentIndex = tdLibWrapper.getUserPrivacySettingRule(TelegramAPI.SettingAllowChatInvites); + } + } + + ComboBox { + id: allowFindingByPhoneNumberComboBox + width: parent.columnWidth + label: qsTr("Allow finding by phone number") + description: qsTr("Privacy setting for managing whether you can be found by your phone number.") + menu: ContextMenu { + + MenuItem { + text: qsTr("Yes") + onClicked: { + tdLibWrapper.setUserPrivacySettingRule(TelegramAPI.SettingAllowFindingByPhoneNumber, TelegramAPI.RuleAllowAll); + } + } + MenuItem { + text: qsTr("Your contacts only") + onClicked: { + tdLibWrapper.setUserPrivacySettingRule(TelegramAPI.SettingAllowFindingByPhoneNumber, TelegramAPI.RuleAllowContacts); + } + } + } + + Component.onCompleted: { + currentIndex = tdLibWrapper.getUserPrivacySettingRule(TelegramAPI.SettingAllowFindingByPhoneNumber); + } + } + + ComboBox { + id: showLinkInForwardedMessagesComboBox + width: parent.columnWidth + label: qsTr("Show link in forwarded messages") + description: qsTr("Privacy setting for managing whether a link to your account is included in forwarded messages.") + menu: ContextMenu { + + MenuItem { + text: qsTr("Yes") + onClicked: { + tdLibWrapper.setUserPrivacySettingRule(TelegramAPI.SettingShowLinkInForwardedMessages, TelegramAPI.RuleAllowAll); + } + } + MenuItem { + text: qsTr("Your contacts only") + onClicked: { + tdLibWrapper.setUserPrivacySettingRule(TelegramAPI.SettingShowLinkInForwardedMessages, TelegramAPI.RuleAllowContacts); + } + } + MenuItem { + text: qsTr("No") + onClicked: { + tdLibWrapper.setUserPrivacySettingRule(TelegramAPI.SettingShowLinkInForwardedMessages, TelegramAPI.RuleRestrictAll); + } + } + } + + Component.onCompleted: { + currentIndex = tdLibWrapper.getUserPrivacySettingRule(TelegramAPI.SettingShowLinkInForwardedMessages); + } + } + + ComboBox { + id: showPhoneNumberComboBox + width: parent.columnWidth + label: qsTr("Show phone number") + description: qsTr("Privacy setting for managing whether your phone number is visible.") + menu: ContextMenu { + + MenuItem { + text: qsTr("Yes") + onClicked: { + tdLibWrapper.setUserPrivacySettingRule(TelegramAPI.SettingShowPhoneNumber, TelegramAPI.RuleAllowAll); + } + } + MenuItem { + text: qsTr("Your contacts only") + onClicked: { + tdLibWrapper.setUserPrivacySettingRule(TelegramAPI.SettingShowPhoneNumber, TelegramAPI.RuleAllowContacts); + } + } + MenuItem { + text: qsTr("No") + onClicked: { + tdLibWrapper.setUserPrivacySettingRule(TelegramAPI.SettingShowPhoneNumber, TelegramAPI.RuleRestrictAll); + } + } + } + + Component.onCompleted: { + currentIndex = tdLibWrapper.getUserPrivacySettingRule(TelegramAPI.SettingShowPhoneNumber); + } + } + + ComboBox { + id: showProfilePhotoComboBox + width: parent.columnWidth + label: qsTr("Show profile photo") + description: qsTr("Privacy setting for managing whether your profile photo is visible.") + menu: ContextMenu { + + MenuItem { + text: qsTr("Yes") + onClicked: { + tdLibWrapper.setUserPrivacySettingRule(TelegramAPI.SettingShowProfilePhoto, TelegramAPI.RuleAllowAll); + } + } + MenuItem { + text: qsTr("Your contacts only") + onClicked: { + tdLibWrapper.setUserPrivacySettingRule(TelegramAPI.SettingShowProfilePhoto, TelegramAPI.RuleAllowContacts); + } + } + MenuItem { + text: qsTr("No") + onClicked: { + tdLibWrapper.setUserPrivacySettingRule(TelegramAPI.SettingShowProfilePhoto, TelegramAPI.RuleRestrictAll); + } + } + } + + Component.onCompleted: { + currentIndex = tdLibWrapper.getUserPrivacySettingRule(TelegramAPI.SettingShowProfilePhoto); + } + } + + ComboBox { + id: showStatusComboBox + width: parent.columnWidth + label: qsTr("Show status") + description: qsTr("Privacy setting for managing whether your online status is visible.") + menu: ContextMenu { + + MenuItem { + text: qsTr("Yes") + onClicked: { + tdLibWrapper.setUserPrivacySettingRule(TelegramAPI.SettingShowStatus, TelegramAPI.RuleAllowAll); + } + } + MenuItem { + text: qsTr("Your contacts only") + onClicked: { + tdLibWrapper.setUserPrivacySettingRule(TelegramAPI.SettingShowStatus, TelegramAPI.RuleAllowContacts); + } + } + MenuItem { + text: qsTr("No") + onClicked: { + tdLibWrapper.setUserPrivacySettingRule(TelegramAPI.SettingShowStatus, TelegramAPI.RuleRestrictAll); + } + } + } + + Component.onCompleted: { + currentIndex = tdLibWrapper.getUserPrivacySettingRule(TelegramAPI.SettingShowStatus); + } + } + + } + SectionHeader { text: qsTr("Behavior") } diff --git a/src/tdlibreceiver.cpp b/src/tdlibreceiver.cpp index 6a62d28..d55cfde 100644 --- a/src/tdlibreceiver.cpp +++ b/src/tdlibreceiver.cpp @@ -139,6 +139,8 @@ TDLibReceiver::TDLibReceiver(void *tdLibClient, QObject *parent) : QThread(paren handlers.insert("updateChatDraftMessage", &TDLibReceiver::processUpdateChatDraftMessage); handlers.insert("inlineQueryResults", &TDLibReceiver::processInlineQueryResults); handlers.insert("callbackQueryAnswer", &TDLibReceiver::processCallbackQueryAnswer); + handlers.insert("userPrivacySettingRules", &TDLibReceiver::processUserPrivacySettingRules); + handlers.insert("updateUserPrivacySettingRules", &TDLibReceiver::processUpdateUserPrivacySettingRules); } void TDLibReceiver::setActive(bool active) @@ -607,7 +609,18 @@ void TDLibReceiver::processInlineQueryResults(const QVariantMap &receivedInforma void TDLibReceiver::processCallbackQueryAnswer(const QVariantMap &receivedInformation) { - LOG("Callback Query answer"); emit callbackQueryAnswer(receivedInformation.value(TEXT).toString(), receivedInformation.value("alert").toBool(), receivedInformation.value("url").toString()); } + +void TDLibReceiver::processUserPrivacySettingRules(const QVariantMap &receivedInformation) +{ + LOG("User privacy setting rules"); + emit userPrivacySettingRules(receivedInformation); +} + +void TDLibReceiver::processUpdateUserPrivacySettingRules(const QVariantMap &receivedInformation) +{ + LOG("User privacy setting rules updated"); + emit userPrivacySettingRulesUpdated(receivedInformation); +} diff --git a/src/tdlibreceiver.h b/src/tdlibreceiver.h index 4ffbe58..cb92f04 100644 --- a/src/tdlibreceiver.h +++ b/src/tdlibreceiver.h @@ -95,6 +95,8 @@ signals: void chatDraftMessageUpdated(qlonglong chatId, const QVariantMap &draftMessage, const QString &order); void inlineQueryResults(const QString &inlineQueryId, const QString &nextOffset, const QVariantList &results, const QString &switchPmText, const QString &switchPmParameter, const QString &extra); void callbackQueryAnswer(const QString &text, bool alert, const QString &url); + void userPrivacySettingRules(const QVariantMap &rules); + void userPrivacySettingRulesUpdated(const QVariantMap &updatedRules); private: typedef void (TDLibReceiver::*Handler)(const QVariantMap &); @@ -164,6 +166,8 @@ private: void processUpdateChatDraftMessage(const QVariantMap &receivedInformation); void processInlineQueryResults(const QVariantMap &receivedInformation); void processCallbackQueryAnswer(const QVariantMap &receivedInformation); + void processUserPrivacySettingRules(const QVariantMap &receivedInformation); + void processUpdateUserPrivacySettingRules(const QVariantMap &receivedInformation); }; #endif // TDLIBRECEIVER_H diff --git a/src/tdlibwrapper.cpp b/src/tdlibwrapper.cpp index ec03779..15cf157 100644 --- a/src/tdlibwrapper.cpp +++ b/src/tdlibwrapper.cpp @@ -158,6 +158,8 @@ void TDLibWrapper::initializeTDLibReciever() { connect(this->tdLibReceiver, SIGNAL(chatDraftMessageUpdated(qlonglong, QVariantMap, QString)), this, SIGNAL(chatDraftMessageUpdated(qlonglong, QVariantMap, QString))); connect(this->tdLibReceiver, SIGNAL(inlineQueryResults(QString, QString, QVariantList, QString, QString, QString)), this, SIGNAL(inlineQueryResults(QString, QString, QVariantList, QString, QString, QString))); connect(this->tdLibReceiver, SIGNAL(callbackQueryAnswer(QString, bool, QString)), this, SIGNAL(callbackQueryAnswer(QString, bool, QString))); + connect(this->tdLibReceiver, SIGNAL(userPrivacySettingRules(QVariantMap)), this, SLOT(handleUserPrivacySettingRules(QVariantMap))); + connect(this->tdLibReceiver, SIGNAL(userPrivacySettingRulesUpdated(QVariantMap)), this, SLOT(handleUpdatedUserPrivacySettingRules(QVariantMap))); this->tdLibReceiver->start(); } @@ -1205,7 +1207,7 @@ void TDLibWrapper::setUsername(const QString &userName) void TDLibWrapper::setUserPrivacySettingRule(TDLibWrapper::UserPrivacySetting setting, TDLibWrapper::UserPrivacySettingRule rule) { - LOG("Set user privecy setting rule of current user" << setting << rule); + LOG("Set user privacy setting rule of current user" << setting << rule); QVariantMap requestObject; requestObject.insert(_TYPE, "setUserPrivacySettingRules"); @@ -1229,6 +1231,8 @@ void TDLibWrapper::setUserPrivacySettingRule(TDLibWrapper::UserPrivacySetting se case SettingShowLinkInForwardedMessages: settingMap.insert(_TYPE, "userPrivacySettingShowLinkInForwardedMessages"); break; + case SettingUnknown: + return; } requestObject.insert("setting", settingMap); @@ -1244,13 +1248,48 @@ void TDLibWrapper::setUserPrivacySettingRule(TDLibWrapper::UserPrivacySetting se case RuleRestrictAll: ruleMap.insert(_TYPE, "userPrivacySettingRuleRestrictAll"); break; - case RuleRestrictContacts: - ruleMap.insert(_TYPE, "userPrivacySettingRuleRestrictContacts"); - break; } QVariantList ruleMaps; ruleMaps.append(ruleMap); - requestObject.insert("rules", ruleMaps); + QVariantMap encapsulatedRules; + encapsulatedRules.insert(_TYPE, "userPrivacySettingRules"); + encapsulatedRules.insert("rules", ruleMaps); + requestObject.insert("rules", encapsulatedRules); + + this->sendRequest(requestObject); +} + +void TDLibWrapper::getUserPrivacySettingRules(TDLibWrapper::UserPrivacySetting setting) +{ + LOG("Getting user privacy setting rules of current user" << setting); + QVariantMap requestObject; + requestObject.insert(_TYPE, "getUserPrivacySettingRules"); + requestObject.insert(_EXTRA, setting); + + QVariantMap settingMap; + switch (setting) { + case SettingShowStatus: + settingMap.insert(_TYPE, "userPrivacySettingShowStatus"); + break; + case SettingShowPhoneNumber: + settingMap.insert(_TYPE, "userPrivacySettingShowPhoneNumber"); + break; + case SettingAllowChatInvites: + settingMap.insert(_TYPE, "userPrivacySettingAllowChatInvites"); + break; + case SettingShowProfilePhoto: + settingMap.insert(_TYPE, "userPrivacySettingShowProfilePhoto"); + break; + case SettingAllowFindingByPhoneNumber: + settingMap.insert(_TYPE, "userPrivacySettingAllowFindingByPhoneNumber"); + break; + case SettingShowLinkInForwardedMessages: + settingMap.insert(_TYPE, "userPrivacySettingShowLinkInForwardedMessages"); + break; + case SettingUnknown: + return; + } + requestObject.insert("setting", settingMap); this->sendRequest(requestObject); } @@ -1286,6 +1325,11 @@ QVariantMap TDLibWrapper::getUserInformationByName(const QString &userName) return this->allUserNames.value(userName).toMap(); } +TDLibWrapper::UserPrivacySettingRule TDLibWrapper::getUserPrivacySettingRule(TDLibWrapper::UserPrivacySetting userPrivacySetting) +{ + return this->userPrivacySettingRules.value(userPrivacySetting, UserPrivacySettingRule::RuleAllowAll); +} + QVariantMap TDLibWrapper::getUnreadMessageInformation() { return this->unreadMessageInformation; @@ -1670,6 +1714,54 @@ void TDLibWrapper::handleMessageIsPinnedUpdated(qlonglong chatId, qlonglong mess } } +void TDLibWrapper::handleUserPrivacySettingRules(const QVariantMap &rules) +{ + QVariantList newGivenRules = rules.value("rules").toList(); + UserPrivacySettingRule newAppliedRule = UserPrivacySettingRule::RuleAllowAll; + QListIterator givenRulesIterator(newGivenRules); + while (givenRulesIterator.hasNext()) { + QString givenRule = givenRulesIterator.next().toMap().value(_TYPE).toString(); + if (givenRule == "userPrivacySettingRuleAllowContacts") { + newAppliedRule = UserPrivacySettingRule::RuleAllowContacts; + } + if (givenRule == "userPrivacySettingRuleRestrictAll") { + newAppliedRule = UserPrivacySettingRule::RuleRestrictAll; + } + } + UserPrivacySetting usedSetting = static_cast(rules.value(_EXTRA).toInt()); + this->userPrivacySettingRules.insert(usedSetting, newAppliedRule); + emit userPrivacySettingUpdated(usedSetting, newAppliedRule); +} + +void TDLibWrapper::handleUpdatedUserPrivacySettingRules(const QVariantMap &updatedRules) +{ + QString rawSetting = updatedRules.value("setting").toMap().value(_TYPE).toString(); + UserPrivacySetting usedSetting = UserPrivacySetting::SettingUnknown; + if (rawSetting == "userPrivacySettingAllowChatInvites") { + usedSetting = UserPrivacySetting::SettingAllowChatInvites; + } + if (rawSetting == "userPrivacySettingAllowFindingByPhoneNumber") { + usedSetting = UserPrivacySetting::SettingAllowFindingByPhoneNumber; + } + if (rawSetting == "userPrivacySettingShowLinkInForwardedMessages") { + usedSetting = UserPrivacySetting::SettingShowLinkInForwardedMessages; + } + if (rawSetting == "userPrivacySettingShowPhoneNumber") { + usedSetting = UserPrivacySetting::SettingShowPhoneNumber; + } + if (rawSetting == "userPrivacySettingShowProfilePhoto") { + usedSetting = UserPrivacySetting::SettingShowProfilePhoto; + } + if (rawSetting == "userPrivacySettingShowStatus") { + usedSetting = UserPrivacySetting::SettingShowStatus; + } + if (usedSetting != UserPrivacySetting::SettingUnknown) { + QVariantMap rawRules = updatedRules.value("rules").toMap(); + rawRules.insert(_TYPE, usedSetting); + this->handleUserPrivacySettingRules(rawRules); + } +} + void TDLibWrapper::setInitialParameters() { LOG("Sending initial parameters to TD Lib"); diff --git a/src/tdlibwrapper.h b/src/tdlibwrapper.h index 4ba3f5e..662f1db 100644 --- a/src/tdlibwrapper.h +++ b/src/tdlibwrapper.h @@ -95,15 +95,15 @@ public: SettingShowLinkInForwardedMessages, SettingShowPhoneNumber, SettingShowProfilePhoto, - SettingShowStatus + SettingShowStatus, + SettingUnknown }; Q_ENUM(UserPrivacySetting) enum UserPrivacySettingRule { RuleAllowAll, RuleAllowContacts, - RuleRestrictAll, - RuleRestrictContacts + RuleRestrictAll }; Q_ENUM(UserPrivacySettingRule) @@ -124,6 +124,7 @@ public: Q_INVOKABLE QVariantMap getUserInformation(const QString &userId); Q_INVOKABLE bool hasUserInformation(const QString &userId); Q_INVOKABLE QVariantMap getUserInformationByName(const QString &userName); + Q_INVOKABLE UserPrivacySettingRule getUserPrivacySettingRule(UserPrivacySetting userPrivacySetting); Q_INVOKABLE QVariantMap getUnreadMessageInformation(); Q_INVOKABLE QVariantMap getUnreadChatInformation(); Q_INVOKABLE QVariantMap getBasicGroup(qlonglong groupId) const; @@ -217,6 +218,7 @@ public: Q_INVOKABLE void setName(const QString &firstName, const QString &lastName); Q_INVOKABLE void setUsername(const QString &userName); Q_INVOKABLE void setUserPrivacySettingRule(UserPrivacySetting setting, UserPrivacySettingRule rule); + Q_INVOKABLE void getUserPrivacySettingRules(UserPrivacySetting setting); // Others (candidates for extraction ;)) Q_INVOKABLE void searchEmoji(const QString &queryString); @@ -292,6 +294,7 @@ signals: void chatDraftMessageUpdated(qlonglong chatId, const QVariantMap &draftMessage, const QString &order); void inlineQueryResults(const QString &inlineQueryId, const QString &nextOffset, const QVariantList &results, const QString &switchPmText, const QString &switchPmParameter, const QString &extra); void callbackQueryAnswer(const QString &text, bool alert, const QString &url); + void userPrivacySettingUpdated(UserPrivacySetting setting, UserPrivacySettingRule rule); public slots: void handleVersionDetected(const QString &version); @@ -316,6 +319,8 @@ public slots: void handleErrorReceived(int code, const QString &message, const QString &extra); void handleMessageInformation(qlonglong chatId, qlonglong messageId, const QVariantMap &receivedInformation); void handleMessageIsPinnedUpdated(qlonglong chatId, qlonglong messageId, bool isPinned); + void handleUserPrivacySettingRules(const QVariantMap &rules); + void handleUpdatedUserPrivacySettingRules(const QVariantMap &updatedRules); private: void setOption(const QString &name, const QString &type, const QVariant &value); @@ -337,6 +342,7 @@ private: TDLibWrapper::ConnectionState connectionState; QVariantMap options; QVariantMap userInformation; + QMap userPrivacySettingRules; QVariantMap allUsers; QVariantMap allUserNames; QVariantMap chats; diff --git a/translations/harbour-fernschreiber-de.ts b/translations/harbour-fernschreiber-de.ts index a5abc89..13127ed 100644 --- a/translations/harbour-fernschreiber-de.ts +++ b/translations/harbour-fernschreiber-de.ts @@ -1556,6 +1556,66 @@ user name of the logged-in profile - header + + Allow chat invites + + + + Privacy setting for managing whether you can be invited to chats. + + + + Yes + + + + Your contacts only + + + + No + + + + Allow finding by phone number + + + + Privacy setting for managing whether you can be found by your phone number. + + + + Show link in forwarded messages + + + + Privacy setting for managing whether a link to your account is included in forwarded messages. + + + + Show phone number + + + + Privacy setting for managing whether your phone number is visible. + + + + Show profile photo + + + + Privacy setting for managing whether your profile photo is visible. + + + + Show status + + + + Privacy setting for managing whether your online status is visible. + +
StickerPicker diff --git a/translations/harbour-fernschreiber-en.ts b/translations/harbour-fernschreiber-en.ts index d0b27a4..606c5bc 100644 --- a/translations/harbour-fernschreiber-en.ts +++ b/translations/harbour-fernschreiber-en.ts @@ -1556,6 +1556,66 @@ user name of the logged-in profile - header + + Allow chat invites + + + + Privacy setting for managing whether you can be invited to chats. + + + + Yes + + + + Your contacts only + + + + No + + + + Allow finding by phone number + + + + Privacy setting for managing whether you can be found by your phone number. + + + + Show link in forwarded messages + + + + Privacy setting for managing whether a link to your account is included in forwarded messages. + + + + Show phone number + + + + Privacy setting for managing whether your phone number is visible. + + + + Show profile photo + + + + Privacy setting for managing whether your profile photo is visible. + + + + Show status + + + + Privacy setting for managing whether your online status is visible. + + StickerPicker diff --git a/translations/harbour-fernschreiber-es.ts b/translations/harbour-fernschreiber-es.ts index c585c0e..4f8cc22 100644 --- a/translations/harbour-fernschreiber-es.ts +++ b/translations/harbour-fernschreiber-es.ts @@ -1556,6 +1556,66 @@ user name of the logged-in profile - header + + Allow chat invites + + + + Privacy setting for managing whether you can be invited to chats. + + + + Yes + + + + Your contacts only + + + + No + + + + Allow finding by phone number + + + + Privacy setting for managing whether you can be found by your phone number. + + + + Show link in forwarded messages + + + + Privacy setting for managing whether a link to your account is included in forwarded messages. + + + + Show phone number + + + + Privacy setting for managing whether your phone number is visible. + + + + Show profile photo + + + + Privacy setting for managing whether your profile photo is visible. + + + + Show status + + + + Privacy setting for managing whether your online status is visible. + + StickerPicker diff --git a/translations/harbour-fernschreiber-fi.ts b/translations/harbour-fernschreiber-fi.ts index 673ed6d..b036792 100644 --- a/translations/harbour-fernschreiber-fi.ts +++ b/translations/harbour-fernschreiber-fi.ts @@ -1557,6 +1557,66 @@ user name of the logged-in profile - header + + Allow chat invites + + + + Privacy setting for managing whether you can be invited to chats. + + + + Yes + + + + Your contacts only + + + + No + + + + Allow finding by phone number + + + + Privacy setting for managing whether you can be found by your phone number. + + + + Show link in forwarded messages + + + + Privacy setting for managing whether a link to your account is included in forwarded messages. + + + + Show phone number + + + + Privacy setting for managing whether your phone number is visible. + + + + Show profile photo + + + + Privacy setting for managing whether your profile photo is visible. + + + + Show status + + + + Privacy setting for managing whether your online status is visible. + + StickerPicker diff --git a/translations/harbour-fernschreiber-hu.ts b/translations/harbour-fernschreiber-hu.ts index ac46773..a788edc 100644 --- a/translations/harbour-fernschreiber-hu.ts +++ b/translations/harbour-fernschreiber-hu.ts @@ -1531,6 +1531,66 @@ user name of the logged-in profile - header + + Allow chat invites + + + + Privacy setting for managing whether you can be invited to chats. + + + + Yes + + + + Your contacts only + + + + No + + + + Allow finding by phone number + + + + Privacy setting for managing whether you can be found by your phone number. + + + + Show link in forwarded messages + + + + Privacy setting for managing whether a link to your account is included in forwarded messages. + + + + Show phone number + + + + Privacy setting for managing whether your phone number is visible. + + + + Show profile photo + + + + Privacy setting for managing whether your profile photo is visible. + + + + Show status + + + + Privacy setting for managing whether your online status is visible. + + StickerPicker diff --git a/translations/harbour-fernschreiber-it.ts b/translations/harbour-fernschreiber-it.ts index 6af6462..3e99343 100644 --- a/translations/harbour-fernschreiber-it.ts +++ b/translations/harbour-fernschreiber-it.ts @@ -1556,6 +1556,66 @@ user name of the logged-in profile - header + + Allow chat invites + + + + Privacy setting for managing whether you can be invited to chats. + + + + Yes + + + + Your contacts only + + + + No + + + + Allow finding by phone number + + + + Privacy setting for managing whether you can be found by your phone number. + + + + Show link in forwarded messages + + + + Privacy setting for managing whether a link to your account is included in forwarded messages. + + + + Show phone number + + + + Privacy setting for managing whether your phone number is visible. + + + + Show profile photo + + + + Privacy setting for managing whether your profile photo is visible. + + + + Show status + + + + Privacy setting for managing whether your online status is visible. + + StickerPicker diff --git a/translations/harbour-fernschreiber-pl.ts b/translations/harbour-fernschreiber-pl.ts index dae786c..598e234 100644 --- a/translations/harbour-fernschreiber-pl.ts +++ b/translations/harbour-fernschreiber-pl.ts @@ -1581,6 +1581,66 @@ user name of the logged-in profile - header + + Allow chat invites + + + + Privacy setting for managing whether you can be invited to chats. + + + + Yes + + + + Your contacts only + + + + No + + + + Allow finding by phone number + + + + Privacy setting for managing whether you can be found by your phone number. + + + + Show link in forwarded messages + + + + Privacy setting for managing whether a link to your account is included in forwarded messages. + + + + Show phone number + + + + Privacy setting for managing whether your phone number is visible. + + + + Show profile photo + + + + Privacy setting for managing whether your profile photo is visible. + + + + Show status + + + + Privacy setting for managing whether your online status is visible. + + StickerPicker diff --git a/translations/harbour-fernschreiber-ru.ts b/translations/harbour-fernschreiber-ru.ts index 0a3bb18..96e588f 100644 --- a/translations/harbour-fernschreiber-ru.ts +++ b/translations/harbour-fernschreiber-ru.ts @@ -1581,6 +1581,66 @@ user name of the logged-in profile - header + + Allow chat invites + + + + Privacy setting for managing whether you can be invited to chats. + + + + Yes + + + + Your contacts only + + + + No + + + + Allow finding by phone number + + + + Privacy setting for managing whether you can be found by your phone number. + + + + Show link in forwarded messages + + + + Privacy setting for managing whether a link to your account is included in forwarded messages. + + + + Show phone number + + + + Privacy setting for managing whether your phone number is visible. + + + + Show profile photo + + + + Privacy setting for managing whether your profile photo is visible. + + + + Show status + + + + Privacy setting for managing whether your online status is visible. + + StickerPicker diff --git a/translations/harbour-fernschreiber-sv.ts b/translations/harbour-fernschreiber-sv.ts index d5ee25e..6b52cd1 100644 --- a/translations/harbour-fernschreiber-sv.ts +++ b/translations/harbour-fernschreiber-sv.ts @@ -1556,6 +1556,66 @@ user name of the logged-in profile - header + + Allow chat invites + + + + Privacy setting for managing whether you can be invited to chats. + + + + Yes + + + + Your contacts only + + + + No + + + + Allow finding by phone number + + + + Privacy setting for managing whether you can be found by your phone number. + + + + Show link in forwarded messages + + + + Privacy setting for managing whether a link to your account is included in forwarded messages. + + + + Show phone number + + + + Privacy setting for managing whether your phone number is visible. + + + + Show profile photo + + + + Privacy setting for managing whether your profile photo is visible. + + + + Show status + + + + Privacy setting for managing whether your online status is visible. + + StickerPicker diff --git a/translations/harbour-fernschreiber-zh_CN.ts b/translations/harbour-fernschreiber-zh_CN.ts index 994ad8a..16e0204 100644 --- a/translations/harbour-fernschreiber-zh_CN.ts +++ b/translations/harbour-fernschreiber-zh_CN.ts @@ -1531,6 +1531,66 @@ user name of the logged-in profile - header + + Allow chat invites + + + + Privacy setting for managing whether you can be invited to chats. + + + + Yes + + + + Your contacts only + + + + No + + + + Allow finding by phone number + + + + Privacy setting for managing whether you can be found by your phone number. + + + + Show link in forwarded messages + + + + Privacy setting for managing whether a link to your account is included in forwarded messages. + + + + Show phone number + + + + Privacy setting for managing whether your phone number is visible. + + + + Show profile photo + + + + Privacy setting for managing whether your profile photo is visible. + + + + Show status + + + + Privacy setting for managing whether your online status is visible. + + StickerPicker diff --git a/translations/harbour-fernschreiber.ts b/translations/harbour-fernschreiber.ts index cff9e86..14ed7f4 100644 --- a/translations/harbour-fernschreiber.ts +++ b/translations/harbour-fernschreiber.ts @@ -1556,6 +1556,66 @@ user name of the logged-in profile - header + + Allow chat invites + + + + Privacy setting for managing whether you can be invited to chats. + + + + Yes + + + + Your contacts only + + + + No + + + + Allow finding by phone number + + + + Privacy setting for managing whether you can be found by your phone number. + + + + Show link in forwarded messages + + + + Privacy setting for managing whether a link to your account is included in forwarded messages. + + + + Show phone number + + + + Privacy setting for managing whether your phone number is visible. + + + + Show profile photo + + + + Privacy setting for managing whether your profile photo is visible. + + + + Show status + + + + Privacy setting for managing whether your online status is visible. + + StickerPicker From bcbbf5616d887449254a53a26531990bc55f020c Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Mon, 25 Jan 2021 20:52:40 +0100 Subject: [PATCH 4/8] Fix two bugs in user privacy settings --- src/tdlibwrapper.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/tdlibwrapper.cpp b/src/tdlibwrapper.cpp index 15cf157..0300c47 100644 --- a/src/tdlibwrapper.cpp +++ b/src/tdlibwrapper.cpp @@ -1717,15 +1717,16 @@ void TDLibWrapper::handleMessageIsPinnedUpdated(qlonglong chatId, qlonglong mess void TDLibWrapper::handleUserPrivacySettingRules(const QVariantMap &rules) { QVariantList newGivenRules = rules.value("rules").toList(); - UserPrivacySettingRule newAppliedRule = UserPrivacySettingRule::RuleAllowAll; + // If nothing (or something unsupported is sent out) it is considered to be restricted completely + UserPrivacySettingRule newAppliedRule = UserPrivacySettingRule::RuleRestrictAll; QListIterator givenRulesIterator(newGivenRules); while (givenRulesIterator.hasNext()) { QString givenRule = givenRulesIterator.next().toMap().value(_TYPE).toString(); if (givenRule == "userPrivacySettingRuleAllowContacts") { newAppliedRule = UserPrivacySettingRule::RuleAllowContacts; } - if (givenRule == "userPrivacySettingRuleRestrictAll") { - newAppliedRule = UserPrivacySettingRule::RuleRestrictAll; + if (givenRule == "userPrivacySettingRuleAllowAll") { + newAppliedRule = UserPrivacySettingRule::RuleAllowAll; } } UserPrivacySetting usedSetting = static_cast(rules.value(_EXTRA).toInt()); @@ -1757,7 +1758,7 @@ void TDLibWrapper::handleUpdatedUserPrivacySettingRules(const QVariantMap &updat } if (usedSetting != UserPrivacySetting::SettingUnknown) { QVariantMap rawRules = updatedRules.value("rules").toMap(); - rawRules.insert(_TYPE, usedSetting); + rawRules.insert(_EXTRA, usedSetting); this->handleUserPrivacySettingRules(rawRules); } } From 1b653eb55474bc9f401270f56167ab3b526d6485 Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Mon, 25 Jan 2021 21:29:40 +0100 Subject: [PATCH 5/8] Translation files for user preferences --- translations/harbour-fernschreiber-de.ts | 42 ++++++++++++------------ translations/harbour-fernschreiber-en.ts | 42 ++++++++++++------------ 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/translations/harbour-fernschreiber-de.ts b/translations/harbour-fernschreiber-de.ts index 13127ed..2c89199 100644 --- a/translations/harbour-fernschreiber-de.ts +++ b/translations/harbour-fernschreiber-de.ts @@ -1531,90 +1531,90 @@ User Profile - + Nutzungsprofil First Name first name of the logged-in profile - header - + Vorname Enter 1-64 characters - Geben Sie 1-128 Zeichen ein {1-64 ?} + Geben Sie 1-64 Zeichen ein Last Name last name of the logged-in profile - header - + Nachname Enter 0-64 characters - Geben Sie 1-128 Zeichen ein {0-64 ?} + Geben Sie 0-64 Zeichen ein Username user name of the logged-in profile - header - + Benutzername Allow chat invites - + Chateinladungen erlauben Privacy setting for managing whether you can be invited to chats. - + Privatsphären-Einstellung zur Regelung, ob Sie zu Chats eingeladen werden können. Yes - + Ja Your contacts only - + Nur Ihre Kontakte No - + Nein Allow finding by phone number - + Auffinden per Telefonnummer erlauben Privacy setting for managing whether you can be found by your phone number. - + Privatsphären-Einstellung zur Regelung, ob Sie per Telefonnummer gefunden werden können. Show link in forwarded messages - + Link in weitergeleiteten Nachrichten anzeigen Privacy setting for managing whether a link to your account is included in forwarded messages. - + Privatsphären-Einstellung zur Regelung, ob ein Link zu Ihrem Profil in weitergeleiteten Nachrichten eingebettet wird. Show phone number - + Telefonnummer anzeigen Privacy setting for managing whether your phone number is visible. - + Privatsphären-Einstellung zur Regelung, ob Ihre Telefonnummer sichtbar ist. Show profile photo - + Profilfoto anzeigen Privacy setting for managing whether your profile photo is visible. - + Privatsphären-Einstellung zur Regelung, ob Ihr Profilfoto sichtbar ist. Show status - + Status anzeigen Privacy setting for managing whether your online status is visible. - + Privatsphären-Einstellung zur Regelung, ob Ihr Onlinestatus sichtbar ist. diff --git a/translations/harbour-fernschreiber-en.ts b/translations/harbour-fernschreiber-en.ts index 606c5bc..bcf0fe3 100644 --- a/translations/harbour-fernschreiber-en.ts +++ b/translations/harbour-fernschreiber-en.ts @@ -1531,90 +1531,90 @@ User Profile - + User Profile First Name first name of the logged-in profile - header - + First Name Enter 1-64 characters - Enter 1-128 characters {1-64 ?} + Enter 1-64 characters Last Name last name of the logged-in profile - header - + Last Name Enter 0-64 characters - Enter 1-128 characters {0-64 ?} + Enter 0-64 characters Username user name of the logged-in profile - header - + Username Allow chat invites - + Allow chat invites Privacy setting for managing whether you can be invited to chats. - + Privacy setting for managing whether you can be invited to chats. Yes - + Yes Your contacts only - + Your contacts only No - + No Allow finding by phone number - + Allow finding by phone number Privacy setting for managing whether you can be found by your phone number. - + Privacy setting for managing whether you can be found by your phone number. Show link in forwarded messages - + Show link in forwarded messages Privacy setting for managing whether a link to your account is included in forwarded messages. - + Privacy setting for managing whether a link to your account is included in forwarded messages. Show phone number - + Show phone number Privacy setting for managing whether your phone number is visible. - + Privacy setting for managing whether your phone number is visible. Show profile photo - + Show profile photo Privacy setting for managing whether your profile photo is visible. - + Privacy setting for managing whether your profile photo is visible. Show status - + Show status Privacy setting for managing whether your online status is visible. - + Privacy setting for managing whether your online status is visible. From 5e6cd6f4b4368dfc2cd721868a9e7c7c477fce4c Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Mon, 25 Jan 2021 23:39:54 +0100 Subject: [PATCH 6/8] 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 From 9b820dad2b2815dd5195daf200a2b32d65e92cfb Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Tue, 26 Jan 2021 23:26:40 +0100 Subject: [PATCH 7/8] Add and delete profile pictures --- qml/components/ProfilePictureList.qml | 6 +- qml/pages/SettingsPage.qml | 61 +++++++++++++++++++-- src/tdlibreceiver.cpp | 6 +- src/tdlibreceiver.h | 1 + src/tdlibwrapper.cpp | 30 ++++++++++ src/tdlibwrapper.h | 3 + translations/harbour-fernschreiber-de.ts | 16 ++++-- translations/harbour-fernschreiber-en.ts | 16 ++++-- translations/harbour-fernschreiber-es.ts | 14 +++-- translations/harbour-fernschreiber-fi.ts | 14 +++-- translations/harbour-fernschreiber-hu.ts | 14 +++-- translations/harbour-fernschreiber-it.ts | 14 +++-- translations/harbour-fernschreiber-pl.ts | 14 +++-- translations/harbour-fernschreiber-ru.ts | 14 +++-- translations/harbour-fernschreiber-sv.ts | 14 +++-- translations/harbour-fernschreiber-zh_CN.ts | 14 +++-- translations/harbour-fernschreiber.ts | 14 +++-- 17 files changed, 201 insertions(+), 64 deletions(-) diff --git a/qml/components/ProfilePictureList.qml b/qml/components/ProfilePictureList.qml index 58656bd..8e1f2fd 100644 --- a/qml/components/ProfilePictureList.qml +++ b/qml/components/ProfilePictureList.qml @@ -23,6 +23,7 @@ Item { id: profilePictureListItem visible: imageContainer.thumbnailVisible && bigProfilePictureList.count > 0 property bool isActive: imageContainer.thumbnailActive + readonly property int currentPictureIndex: bigProfilePictureList.currentIndex opacity: isActive ? 1.0 : 0.0 Behavior on opacity { FadeAnimation {} } @@ -57,14 +58,15 @@ Item { Text { visible: bigProfilePictureList.count > 1 - width: parent.width + width: parent.width - Theme.paddingSmall anchors { bottomMargin: Theme.paddingSmall bottom: parent.bottom } horizontalAlignment: Text.AlignHCenter property var baseString: new Array(bigProfilePictureList.count+1).join(" ○ ") - text: baseString.substring(0,bigProfilePictureList.currentIndex*3) + " ● " + baseString.substring((bigProfilePictureList.currentIndex+1)*3) + text: (baseString.substring(0,bigProfilePictureList.currentIndex*3) + " ● " + baseString.substring((bigProfilePictureList.currentIndex+1)*3)).trim() + font.pixelSize: Theme.fontSizeTiny color: Theme.primaryColor style: Text.Raised styleColor: Theme.highlightDimmerColor diff --git a/qml/pages/SettingsPage.qml b/qml/pages/SettingsPage.qml index 29f84b4..47df8d3 100644 --- a/qml/pages/SettingsPage.qml +++ b/qml/pages/SettingsPage.qml @@ -18,6 +18,7 @@ */ import QtQuick 2.6 import Sailfish.Silica 1.0 +import Sailfish.Pickers 1.0 import WerkWolf.Fernschreiber 1.0 import "../components" import "../js/functions.js" as Functions @@ -29,6 +30,7 @@ Page { readonly property bool landscapeLayout: (width > height && Screen.sizeCategory > Screen.Small) || Screen.sizeCategory > Screen.Medium readonly property var userInformation: tdLibWrapper.getUserInformation() + property bool uploadInProgress: false onStatusChanged: { if (status === PageStatus.Active) { @@ -48,6 +50,21 @@ Page { imageContainer.thumbnailModel = photos; } } + onFileUpdated: { + if (uploadInProgress) { + profilePictureButtonColumn.visible = !fileInformation.remote.is_uploading_active; + uploadInProgress = fileInformation.remote.is_uploading_active; + if (!fileInformation.remote.is_uploading_active) { + uploadInProgress = false; + tdLibWrapper.getUserProfilePhotos(userInformation.id, 100, 0); + } + } + } + onOkReceived: { + if (request === "deleteProfilePhoto") { + tdLibWrapper.getUserProfilePhotos(userInformation.id, 100, 0); + } + } } SilicaFlickable { @@ -182,6 +199,7 @@ Page { } Column { + id: profilePictureButtonColumn spacing: Theme.paddingSmall width: parent.width / 2 @@ -192,27 +210,62 @@ Page { horizontalCenter: parent.horizontalCenter } onClicked: { - + pageStack.push(imagePickerPage); } } Button { id: removeProfilePictureButton - text: qsTr("Remove Picture") + text: qsTr("Delete Picture") anchors { horizontalCenter: parent.horizontalCenter } onClicked: { - + var pictureIdForDeletion = imageContainer.thumbnailModel[profilePictureLoader.item.currentPictureIndex].id; + Remorse.popupAction(settingsPage, qsTr("Deleting profile picture"), function() { tdLibWrapper.deleteProfilePhoto(pictureIdForDeletion) }); } } + } + + Column { + id: uploadStatusColumn + visible: !profilePictureButtonColumn.visible + spacing: Theme.paddingMedium + width: parent.width / 2 + + Text { + id: uploadingText + font.pixelSize: Theme.fontSizeSmall + text: qsTr("Uploading...") + horizontalAlignment: Text.AlignHCenter + color: Theme.secondaryColor + width: parent.width + } + + BusyIndicator { + anchors.horizontalCenter: parent.horizontalCenter + running: uploadStatusColumn.visible + size: BusyIndicatorSize.Medium + } } + } + Component { + id: imagePickerPage + ImagePickerPage { + onSelectedContentPropertiesChanged: { + profilePictureButtonColumn.visible = false; + uploadInProgress = true; + tdLibWrapper.setProfilePhoto(selectedContentProperties.filePath); + } + } + } + SectionHeader { horizontalAlignment: Text.AlignLeft - text: qsTr("Privacy Options") + text: qsTr("Privacy") } Grid { diff --git a/src/tdlibreceiver.cpp b/src/tdlibreceiver.cpp index d55cfde..0637403 100644 --- a/src/tdlibreceiver.cpp +++ b/src/tdlibreceiver.cpp @@ -558,8 +558,12 @@ void TDLibReceiver::processError(const QVariantMap &receivedInformation) emit errorReceived(receivedInformation.value("code").toInt(), receivedInformation.value(MESSAGE).toString(), receivedInformation.value(EXTRA).toString()); } -void TDLibReceiver::nop(const QVariantMap &) +void TDLibReceiver::nop(const QVariantMap &receivedInformation) { + LOG("Received an OK"); + if (receivedInformation.contains(EXTRA)) { + emit okReceived(receivedInformation.value(EXTRA).toString()); + } } void TDLibReceiver::processSecretChat(const QVariantMap &receivedInformation) diff --git a/src/tdlibreceiver.h b/src/tdlibreceiver.h index cb92f04..9e46f82 100644 --- a/src/tdlibreceiver.h +++ b/src/tdlibreceiver.h @@ -97,6 +97,7 @@ signals: void callbackQueryAnswer(const QString &text, bool alert, const QString &url); void userPrivacySettingRules(const QVariantMap &rules); void userPrivacySettingRulesUpdated(const QVariantMap &updatedRules); + void okReceived(const QString &request); private: typedef void (TDLibReceiver::*Handler)(const QVariantMap &); diff --git a/src/tdlibwrapper.cpp b/src/tdlibwrapper.cpp index 0300c47..9b0f942 100644 --- a/src/tdlibwrapper.cpp +++ b/src/tdlibwrapper.cpp @@ -160,6 +160,7 @@ void TDLibWrapper::initializeTDLibReciever() { connect(this->tdLibReceiver, SIGNAL(callbackQueryAnswer(QString, bool, QString)), this, SIGNAL(callbackQueryAnswer(QString, bool, QString))); connect(this->tdLibReceiver, SIGNAL(userPrivacySettingRules(QVariantMap)), this, SLOT(handleUserPrivacySettingRules(QVariantMap))); connect(this->tdLibReceiver, SIGNAL(userPrivacySettingRulesUpdated(QVariantMap)), this, SLOT(handleUpdatedUserPrivacySettingRules(QVariantMap))); + connect(this->tdLibReceiver, SIGNAL(okReceived(QString)), this, SIGNAL(okReceived(QString))); this->tdLibReceiver->start(); } @@ -1294,6 +1295,35 @@ void TDLibWrapper::getUserPrivacySettingRules(TDLibWrapper::UserPrivacySetting s this->sendRequest(requestObject); } +void TDLibWrapper::setProfilePhoto(const QString &filePath) +{ + LOG("Set a profile photo" << filePath); + + QVariantMap requestObject; + requestObject.insert(_TYPE, "setProfilePhoto"); + QVariantMap inputChatPhoto; + inputChatPhoto.insert(_TYPE, "inputChatPhotoStatic"); + QVariantMap inputFile; + inputFile.insert(_TYPE, "inputFileLocal"); + inputFile.insert("path", filePath); + inputChatPhoto.insert("photo", inputFile); + requestObject.insert("photo", inputChatPhoto); + + this->sendRequest(requestObject); +} + +void TDLibWrapper::deleteProfilePhoto(const QString &profilePhotoId) +{ + LOG("Delete a profile photo" << profilePhotoId); + + QVariantMap requestObject; + requestObject.insert(_TYPE, "deleteProfilePhoto"); + requestObject.insert(_EXTRA, "deleteProfilePhoto"); + requestObject.insert("profile_photo_id", profilePhotoId); + + this->sendRequest(requestObject); +} + void TDLibWrapper::searchEmoji(const QString &queryString) { LOG("Searching emoji" << queryString); diff --git a/src/tdlibwrapper.h b/src/tdlibwrapper.h index 662f1db..f715b96 100644 --- a/src/tdlibwrapper.h +++ b/src/tdlibwrapper.h @@ -219,6 +219,8 @@ public: Q_INVOKABLE void setUsername(const QString &userName); Q_INVOKABLE void setUserPrivacySettingRule(UserPrivacySetting setting, UserPrivacySettingRule rule); Q_INVOKABLE void getUserPrivacySettingRules(UserPrivacySetting setting); + Q_INVOKABLE void setProfilePhoto(const QString &filePath); + Q_INVOKABLE void deleteProfilePhoto(const QString &profilePhotoId); // Others (candidates for extraction ;)) Q_INVOKABLE void searchEmoji(const QString &queryString); @@ -295,6 +297,7 @@ signals: void inlineQueryResults(const QString &inlineQueryId, const QString &nextOffset, const QVariantList &results, const QString &switchPmText, const QString &switchPmParameter, const QString &extra); void callbackQueryAnswer(const QString &text, bool alert, const QString &url); void userPrivacySettingUpdated(UserPrivacySetting setting, UserPrivacySettingRule rule); + void okReceived(const QString &request); public slots: void handleVersionDetected(const QString &version); diff --git a/translations/harbour-fernschreiber-de.ts b/translations/harbour-fernschreiber-de.ts index aeda11f..898fffa 100644 --- a/translations/harbour-fernschreiber-de.ts +++ b/translations/harbour-fernschreiber-de.ts @@ -1620,17 +1620,21 @@ Add Picture Bild hinzufügen - - Remove Picture - Bild löschen - Profile Pictures Profilbilder - Privacy Options - Optionen zur Privatsphäre + Delete Picture + Bild löschen + + + Uploading... + Lade hoch... + + + Deleting profile picture + Lösche Profilbild diff --git a/translations/harbour-fernschreiber-en.ts b/translations/harbour-fernschreiber-en.ts index 480cb70..293a372 100644 --- a/translations/harbour-fernschreiber-en.ts +++ b/translations/harbour-fernschreiber-en.ts @@ -1620,17 +1620,21 @@ Add Picture Add Picture - - Remove Picture - Remove Picture - Profile Pictures Profile Pictures - Privacy Options - Privacy Options + Delete Picture + Delete Picture + + + Uploading... + Uploading... + + + Deleting profile picture + Deleting profile picture diff --git a/translations/harbour-fernschreiber-es.ts b/translations/harbour-fernschreiber-es.ts index 53e86b0..8000a26 100644 --- a/translations/harbour-fernschreiber-es.ts +++ b/translations/harbour-fernschreiber-es.ts @@ -1620,16 +1620,20 @@ Add Picture - - Remove Picture - - Profile Pictures - Privacy Options + Delete Picture + + + + Uploading... + Subiendo... + + + Deleting profile picture diff --git a/translations/harbour-fernschreiber-fi.ts b/translations/harbour-fernschreiber-fi.ts index a9065fe..821f26f 100644 --- a/translations/harbour-fernschreiber-fi.ts +++ b/translations/harbour-fernschreiber-fi.ts @@ -1621,16 +1621,20 @@ Add Picture - - Remove Picture - - Profile Pictures - Privacy Options + Delete Picture + + + + Uploading... + Lähetetään... + + + Deleting profile picture diff --git a/translations/harbour-fernschreiber-hu.ts b/translations/harbour-fernschreiber-hu.ts index ccc0d70..d717b46 100644 --- a/translations/harbour-fernschreiber-hu.ts +++ b/translations/harbour-fernschreiber-hu.ts @@ -1595,16 +1595,20 @@ Add Picture - - Remove Picture - - Profile Pictures - Privacy Options + Delete Picture + + + + Uploading... + + + + Deleting profile picture diff --git a/translations/harbour-fernschreiber-it.ts b/translations/harbour-fernschreiber-it.ts index 31c6ad9..90aac41 100644 --- a/translations/harbour-fernschreiber-it.ts +++ b/translations/harbour-fernschreiber-it.ts @@ -1620,16 +1620,20 @@ Add Picture - - Remove Picture - - Profile Pictures - Privacy Options + Delete Picture + + + + Uploading... + Carica... + + + Deleting profile picture diff --git a/translations/harbour-fernschreiber-pl.ts b/translations/harbour-fernschreiber-pl.ts index a73d813..80305a8 100644 --- a/translations/harbour-fernschreiber-pl.ts +++ b/translations/harbour-fernschreiber-pl.ts @@ -1645,16 +1645,20 @@ Add Picture - - Remove Picture - - Profile Pictures - Privacy Options + Delete Picture + + + + Uploading... + Przesyłanie... + + + Deleting profile picture diff --git a/translations/harbour-fernschreiber-ru.ts b/translations/harbour-fernschreiber-ru.ts index 72e4189..4e44562 100644 --- a/translations/harbour-fernschreiber-ru.ts +++ b/translations/harbour-fernschreiber-ru.ts @@ -1645,16 +1645,20 @@ Add Picture - - Remove Picture - - Profile Pictures - Privacy Options + Delete Picture + + + + Uploading... + Отправка... + + + Deleting profile picture diff --git a/translations/harbour-fernschreiber-sv.ts b/translations/harbour-fernschreiber-sv.ts index b9aa8c0..01b319d 100644 --- a/translations/harbour-fernschreiber-sv.ts +++ b/translations/harbour-fernschreiber-sv.ts @@ -1620,16 +1620,20 @@ Add Picture - - Remove Picture - - Profile Pictures - Privacy Options + Delete Picture + + + + Uploading... + Ladda upp... + + + Deleting profile picture diff --git a/translations/harbour-fernschreiber-zh_CN.ts b/translations/harbour-fernschreiber-zh_CN.ts index 728a33f..a9a6319 100644 --- a/translations/harbour-fernschreiber-zh_CN.ts +++ b/translations/harbour-fernschreiber-zh_CN.ts @@ -1595,16 +1595,20 @@ Add Picture - - Remove Picture - - Profile Pictures - Privacy Options + Delete Picture + + + + Uploading... + 正在上传… + + + Deleting profile picture diff --git a/translations/harbour-fernschreiber.ts b/translations/harbour-fernschreiber.ts index d4f5395..a9ef6e2 100644 --- a/translations/harbour-fernschreiber.ts +++ b/translations/harbour-fernschreiber.ts @@ -1620,16 +1620,20 @@ Add Picture - - Remove Picture - - Profile Pictures - Privacy Options + Delete Picture + + + + Uploading... + Uploading... + + + Deleting profile picture From e2b6d25aa854f774cae5a331e0279b79b821604b Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Tue, 26 Jan 2021 23:54:37 +0100 Subject: [PATCH 8/8] Show picture placeholder in settings, handle first upload properly --- qml/components/ProfilePictureList.qml | 1 + qml/pages/SettingsPage.qml | 15 ++++ src/tdlibwrapper.cpp | 1 + translations/harbour-fernschreiber-ru.ts | 4 +- translations/harbour-fernschreiber-sk.ts | 107 +++++++++++++++++++++++ 5 files changed, 126 insertions(+), 2 deletions(-) diff --git a/qml/components/ProfilePictureList.qml b/qml/components/ProfilePictureList.qml index 8e1f2fd..d88ea09 100644 --- a/qml/components/ProfilePictureList.qml +++ b/qml/components/ProfilePictureList.qml @@ -71,4 +71,5 @@ Item { style: Text.Raised styleColor: Theme.highlightDimmerColor } + } diff --git a/qml/pages/SettingsPage.qml b/qml/pages/SettingsPage.qml index 47df8d3..bbcf1ab 100644 --- a/qml/pages/SettingsPage.qml +++ b/qml/pages/SettingsPage.qml @@ -64,6 +64,11 @@ Page { if (request === "deleteProfilePhoto") { tdLibWrapper.getUserProfilePhotos(userInformation.id, 100, 0); } + if (request === "setProfilePhoto") { + tdLibWrapper.getUserProfilePhotos(userInformation.id, 100, 0); + profilePictureButtonColumn.visible = true; + uploadInProgress = false; + } } } @@ -196,6 +201,16 @@ Page { anchors.horizontalCenter: parent.horizontalCenter source: "../components/ProfilePictureList.qml" } + + ProfileThumbnail { + id: chatPictureReplacement + visible: !profilePictureLoader.active + replacementStringHint: Functions.getUserName(settingsPage.userInformation) + radius: imageContainer.thumbnailRadius + anchors.horizontalCenter: parent.horizontalCenter + width: Theme.itemSizeExtraLarge + height: Theme.itemSizeExtraLarge + } } Column { diff --git a/src/tdlibwrapper.cpp b/src/tdlibwrapper.cpp index 9b0f942..6b5b339 100644 --- a/src/tdlibwrapper.cpp +++ b/src/tdlibwrapper.cpp @@ -1301,6 +1301,7 @@ void TDLibWrapper::setProfilePhoto(const QString &filePath) QVariantMap requestObject; requestObject.insert(_TYPE, "setProfilePhoto"); + requestObject.insert(_EXTRA, "setProfilePhoto"); QVariantMap inputChatPhoto; inputChatPhoto.insert(_TYPE, "inputChatPhotoStatic"); QVariantMap inputFile; diff --git a/translations/harbour-fernschreiber-ru.ts b/translations/harbour-fernschreiber-ru.ts index 391b880..3a1a6ca 100644 --- a/translations/harbour-fernschreiber-ru.ts +++ b/translations/harbour-fernschreiber-ru.ts @@ -2140,11 +2140,11 @@ sent a game myself - + отправлена игра sent a game - + отправлена игра diff --git a/translations/harbour-fernschreiber-sk.ts b/translations/harbour-fernschreiber-sk.ts index 8b9059b..02d7726 100644 --- a/translations/harbour-fernschreiber-sk.ts +++ b/translations/harbour-fernschreiber-sk.ts @@ -1554,6 +1554,113 @@ Some inline bots request location data when using them Niektorí inline roboti požadujú údaje o polohe ak ich používajú + + User Profile + + + + First Name + first name of the logged-in profile - header + + + + Enter 1-64 characters + Zadať 1-128 znakov {1-64 ?} + + + Last Name + last name of the logged-in profile - header + + + + Enter 0-64 characters + Zadať 1-128 znakov {0-64 ?} + + + Username + user name of the logged-in profile - header + + + + Profile Pictures + + + + Add Picture + + + + Delete Picture + + + + Deleting profile picture + + + + Uploading... + Zapisovanie... + + + Allow chat invites + + + + Privacy setting for managing whether you can be invited to chats. + + + + Yes + + + + Your contacts only + + + + No + + + + Allow finding by phone number + + + + Privacy setting for managing whether you can be found by your phone number. + + + + Show link in forwarded messages + + + + Privacy setting for managing whether a link to your account is included in forwarded messages. + + + + Show phone number + + + + Privacy setting for managing whether your phone number is visible. + + + + Show profile photo + + + + Privacy setting for managing whether your profile photo is visible. + + + + Show status + + + + Privacy setting for managing whether your online status is visible. + + StickerPicker