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 @@
Einige Inline-Bots fragen bei Nutzung Standortdaten an
+
+
+
+
+
+
+ first name of the logged-in profile - header
+
+
+
+
+ Geben Sie 1-128 Zeichen ein {1-64 ?}
+
+
+
+ last name of the logged-in profile - header
+
+
+
+
+ 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
+
+
+
+
+
+
+ first name of the logged-in profile - header
+
+
+
+
+ Enter 1-128 characters {1-64 ?}
+
+
+
+ last name of the logged-in profile - header
+
+
+
+
+ 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 @@
+
+
+
+
+
+
+ first name of the logged-in profile - header
+
+
+
+
+ Marcar caracteres 1-128 {1-64 ?}
+
+
+
+ last name of the logged-in profile - header
+
+
+
+
+ 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 @@
+
+
+
+
+
+
+ first name of the logged-in profile - header
+
+
+
+
+ Syötä 1-128 merkkiä {1-64 ?}
+
+
+
+ last name of the logged-in profile - header
+
+
+
+
+ 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 @@
+
+
+
+
+
+
+ first name of the logged-in profile - header
+
+
+
+
+
+
+
+
+ last name of the logged-in profile - header
+
+
+
+
+
+
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 @@
+
+
+
+
+
+
+ first name of the logged-in profile - header
+
+
+
+
+ Inserisci da 1 a 128 caratteri {1-64 ?}
+
+
+
+ last name of the logged-in profile - header
+
+
+
+
+ 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 @@
+
+
+
+
+
+
+ first name of the logged-in profile - header
+
+
+
+
+ Wprowadź znaki 1-128 {1-64 ?}
+
+
+
+ last name of the logged-in profile - header
+
+
+
+
+ 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 @@
+
+
+
+
+
+
+ first name of the logged-in profile - header
+
+
+
+
+ Введите 1-128 символов {1-64 ?}
+
+
+
+ last name of the logged-in profile - header
+
+
+
+
+ Введите 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 @@
+
+
+
+
+
+
+ first name of the logged-in profile - header
+
+
+
+
+ Ange 1-128 tecken {1-64 ?}
+
+
+
+ last name of the logged-in profile - header
+
+
+
+
+ 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 @@
使用某些内联机器人时会请求位置数据
+
+
+
+
+
+
+ first name of the logged-in profile - header
+
+
+
+
+ 输入 1-128 个字符 {1-64 ?}
+
+
+
+ last name of the logged-in profile - header
+
+
+
+
+ 输入 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 @@
+
+
+
+
+
+
+ first name of the logged-in profile - header
+
+
+
+
+ Enter 1-128 characters {1-64 ?}
+
+
+
+ last name of the logged-in profile - header
+
+
+
+
+ Enter 1-128 characters {0-64 ?}
+
StickerPicker