Start with personal profile settings

This commit is contained in:
Sebastian Wolf 2021-01-19 00:02:37 +01:00
parent 32f884e547
commit 4e6d012a7d
No known key found for this signature in database
GPG key ID: CEA9522B5F38A90A
21 changed files with 360 additions and 20 deletions

View file

@ -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 \

View file

@ -18,7 +18,7 @@ PhotoTextsListItem {
// chat title
primaryText.text: title ? Emoji.emojify(title, Theme.fontSizeMedium) : qsTr("Unknown")
// last user
prologSecondaryText.text: showDraft ? "<i>"+qsTr("Draft")+"</i>" : (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 ? "<i>"+qsTr("Draft")+"</i>" : (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) : "<i>" + qsTr("No message in this chat.") + "</i>"
// message date

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
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

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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")
}

View file

@ -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);

View file

@ -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);

View file

@ -1508,6 +1508,28 @@
<source>Some inline bots request location data when using them</source>
<translation>Einige Inline-Bots fragen bei Nutzung Standortdaten an</translation>
</message>
<message>
<source>User Profile</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>First Name</source>
<comment>first name of the logged-in profile - header</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter 1-64 characters</source>
<translation type="unfinished">Geben Sie 1-128 Zeichen ein {1-64 ?}</translation>
</message>
<message>
<source>Last Name</source>
<comment>last name of the logged-in profile - header</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter 0-64 characters</source>
<translation type="unfinished">Geben Sie 1-128 Zeichen ein {0-64 ?}</translation>
</message>
</context>
<context>
<name>StickerPicker</name>

View file

@ -1508,6 +1508,28 @@
<source>Some inline bots request location data when using them</source>
<translation>Some inline bots request location data when using them</translation>
</message>
<message>
<source>User Profile</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>First Name</source>
<comment>first name of the logged-in profile - header</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter 1-64 characters</source>
<translation type="unfinished">Enter 1-128 characters {1-64 ?}</translation>
</message>
<message>
<source>Last Name</source>
<comment>last name of the logged-in profile - header</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter 0-64 characters</source>
<translation type="unfinished">Enter 1-128 characters {0-64 ?}</translation>
</message>
</context>
<context>
<name>StickerPicker</name>

View file

@ -1508,6 +1508,28 @@
<source>Some inline bots request location data when using them</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>User Profile</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>First Name</source>
<comment>first name of the logged-in profile - header</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter 1-64 characters</source>
<translation type="unfinished">Marcar caracteres 1-128 {1-64 ?}</translation>
</message>
<message>
<source>Last Name</source>
<comment>last name of the logged-in profile - header</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter 0-64 characters</source>
<translation type="unfinished">Marcar caracteres 1-128 {0-64 ?}</translation>
</message>
</context>
<context>
<name>StickerPicker</name>

View file

@ -1509,6 +1509,28 @@
<source>Some inline bots request location data when using them</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>User Profile</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>First Name</source>
<comment>first name of the logged-in profile - header</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter 1-64 characters</source>
<translation type="unfinished">Syötä 1-128 merkkiä {1-64 ?}</translation>
</message>
<message>
<source>Last Name</source>
<comment>last name of the logged-in profile - header</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter 0-64 characters</source>
<translation type="unfinished">Syötä 1-128 merkkiä {0-64 ?}</translation>
</message>
</context>
<context>
<name>StickerPicker</name>

View file

@ -1483,6 +1483,28 @@
<source>Some inline bots request location data when using them</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>User Profile</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>First Name</source>
<comment>first name of the logged-in profile - header</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter 1-64 characters</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Last Name</source>
<comment>last name of the logged-in profile - header</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter 0-64 characters</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>StickerPicker</name>

View file

@ -1508,6 +1508,28 @@
<source>Some inline bots request location data when using them</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>User Profile</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>First Name</source>
<comment>first name of the logged-in profile - header</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter 1-64 characters</source>
<translation type="unfinished">Inserisci da 1 a 128 caratteri {1-64 ?}</translation>
</message>
<message>
<source>Last Name</source>
<comment>last name of the logged-in profile - header</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter 0-64 characters</source>
<translation type="unfinished">Inserisci da 1 a 128 caratteri {0-64 ?}</translation>
</message>
</context>
<context>
<name>StickerPicker</name>

View file

@ -1533,6 +1533,28 @@
<source>Some inline bots request location data when using them</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>User Profile</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>First Name</source>
<comment>first name of the logged-in profile - header</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter 1-64 characters</source>
<translation type="unfinished">Wprowadź znaki 1-128 {1-64 ?}</translation>
</message>
<message>
<source>Last Name</source>
<comment>last name of the logged-in profile - header</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter 0-64 characters</source>
<translation type="unfinished">Wprowadź znaki 1-128 {0-64 ?}</translation>
</message>
</context>
<context>
<name>StickerPicker</name>

View file

@ -1533,6 +1533,28 @@
<source>Some inline bots request location data when using them</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>User Profile</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>First Name</source>
<comment>first name of the logged-in profile - header</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter 1-64 characters</source>
<translation type="unfinished">Введите 1-128 символов {1-64 ?}</translation>
</message>
<message>
<source>Last Name</source>
<comment>last name of the logged-in profile - header</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter 0-64 characters</source>
<translation type="unfinished">Введите 1-128 символов {0-64 ?}</translation>
</message>
</context>
<context>
<name>StickerPicker</name>

View file

@ -1508,6 +1508,28 @@
<source>Some inline bots request location data when using them</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>User Profile</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>First Name</source>
<comment>first name of the logged-in profile - header</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter 1-64 characters</source>
<translation type="unfinished">Ange 1-128 tecken {1-64 ?}</translation>
</message>
<message>
<source>Last Name</source>
<comment>last name of the logged-in profile - header</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter 0-64 characters</source>
<translation type="unfinished">Ange 1-128 tecken {0-64 ?}</translation>
</message>
</context>
<context>
<name>StickerPicker</name>

View file

@ -1483,6 +1483,28 @@
<source>Some inline bots request location data when using them</source>
<translation>使</translation>
</message>
<message>
<source>User Profile</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>First Name</source>
<comment>first name of the logged-in profile - header</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter 1-64 characters</source>
<translation type="unfinished"> 1-128 {1-64 ?}</translation>
</message>
<message>
<source>Last Name</source>
<comment>last name of the logged-in profile - header</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter 0-64 characters</source>
<translation type="unfinished"> 1-128 {0-64 ?}</translation>
</message>
</context>
<context>
<name>StickerPicker</name>

View file

@ -1508,6 +1508,28 @@
<source>Some inline bots request location data when using them</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>User Profile</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>First Name</source>
<comment>first name of the logged-in profile - header</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter 1-64 characters</source>
<translation type="unfinished">Enter 1-128 characters {1-64 ?}</translation>
</message>
<message>
<source>Last Name</source>
<comment>last name of the logged-in profile - header</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter 0-64 characters</source>
<translation type="unfinished">Enter 1-128 characters {0-64 ?}</translation>
</message>
</context>
<context>
<name>StickerPicker</name>