Show some love to the editing functionality
This commit is contained in:
parent
cccbfc88f1
commit
98d07c86c4
9 changed files with 27 additions and 32 deletions
|
@ -37,7 +37,7 @@ Row {
|
|||
onInReplyToMessageChanged: {
|
||||
if (inReplyToMessage) {
|
||||
inReplyToUserText.text = (inReplyToRow.inReplyToMessage.sender_user_id !== inReplyToRow.myUserId) ? Emoji.emojify(Functions.getUserName(tdLibWrapper.getUserInformation(inReplyToRow.inReplyToMessage.sender_user_id)), inReplyToUserText.font.pixelSize) : qsTr("You");
|
||||
inReplyToMessageText.text = Emoji.emojify(Functions.getMessageText(inReplyToRow.inReplyToMessage, true, inReplyToRow.inReplyToMessage.sender_user_id === inReplyToRow.myUserId), inReplyToMessageText.font.pixelSize);
|
||||
inReplyToMessageText.text = Emoji.emojify(Functions.getMessageText(inReplyToRow.inReplyToMessage, true, inReplyToRow.inReplyToMessage.sender_user_id === inReplyToRow.myUserId, false), inReplyToMessageText.font.pixelSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,6 +76,7 @@ Row {
|
|||
width: parent.width
|
||||
textFormat: Text.StyledText
|
||||
truncationMode: TruncationMode.Fade
|
||||
maximumLineCount: 1
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ ListItem {
|
|||
MenuItem {
|
||||
onClicked: {
|
||||
newMessageColumn.editMessageId = myMessage.id;
|
||||
newMessageTextField.text = Functions.getMessageText(myMessage, false, false);
|
||||
newMessageTextField.text = Functions.getMessageText(myMessage, false, false, true);
|
||||
newMessageTextField.focus = true;
|
||||
}
|
||||
text: qsTr("Edit Message")
|
||||
|
@ -92,7 +92,7 @@ ListItem {
|
|||
}
|
||||
MenuItem {
|
||||
onClicked: {
|
||||
Clipboard.text = Functions.getMessageText(myMessage, true, false);
|
||||
Clipboard.text = Functions.getMessageText(myMessage, true, false, true);
|
||||
}
|
||||
text: qsTr("Copy Message to Clipboard")
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ ListItem {
|
|||
if (index === modelIndex) {
|
||||
Debug.log("[ChatModel] This message was updated, index ", index, ", updating content...");
|
||||
messageDateText.text = getMessageStatusText(myMessage, index, chatView.lastReadSentIndex, messageDateText.useElapsed);
|
||||
messageText.text = Emoji.emojify(Functions.getMessageText(myMessage, false, messageListItem.isOwnMessage), messageText.font.pixelSize);
|
||||
messageText.text = Emoji.emojify(Functions.getMessageText(myMessage, false, messageListItem.isOwnMessage. false), messageText.font.pixelSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -368,7 +368,7 @@ ListItem {
|
|||
Text {
|
||||
id: messageText
|
||||
width: parent.width
|
||||
text: Emoji.emojify(Functions.getMessageText(myMessage, false, messageListItem.isOwnMessage), font.pixelSize)
|
||||
text: Emoji.emojify(Functions.getMessageText(myMessage, false, messageListItem.isOwnMessage, false), font.pixelSize)
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: messageListItem.textColor
|
||||
wrapMode: Text.Wrap
|
||||
|
|
|
@ -43,7 +43,7 @@ Item {
|
|||
color: Theme.highlightColor
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
font.pixelSize: Theme.fontSizeExtraSmall
|
||||
text: "<a style=\"text-decoration: none; font-weight: bold; color:"+Theme.primaryColor+"\" href=\"userId://" + messageListItem.userInformation.id + "\">" + (!messageListItem.isOwnMessage ? Emoji.emojify(Functions.getUserName(messageListItem.userInformation), font.pixelSize) : qsTr("You")) + "</a> " + Emoji.emojify(Functions.getMessageText(messageListItem.myMessage, false, messageListItem.isOwnMessage), font.pixelSize)
|
||||
text: "<a style=\"text-decoration: none; font-weight: bold; color:"+Theme.primaryColor+"\" href=\"userId://" + messageListItem.userInformation.id + "\">" + (!messageListItem.isOwnMessage ? Emoji.emojify(Functions.getUserName(messageListItem.userInformation), font.pixelSize) : qsTr("You")) + "</a> " + Emoji.emojify(Functions.getMessageText(messageListItem.myMessage, false, messageListItem.isOwnMessage, false), font.pixelSize)
|
||||
textFormat: Text.RichText
|
||||
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
|
||||
onLinkActivated: {
|
||||
|
|
|
@ -138,7 +138,7 @@ Flickable {
|
|||
Text {
|
||||
id: overlayMessageText
|
||||
width: parent.width
|
||||
text: Emoji.emojify(Functions.getMessageText(overlayMessage, false, messageOverlayFlickable.isOwnMessage), font.pixelSize)
|
||||
text: Emoji.emojify(Functions.getMessageText(overlayMessage, false, messageOverlayFlickable.isOwnMessage, false), font.pixelSize)
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
color: Theme.primaryColor
|
||||
wrapMode: Text.Wrap
|
||||
|
|
|
@ -35,7 +35,7 @@ Item {
|
|||
Debug.log("[ChatPage] Activating pinned message");
|
||||
var messageUserText = (pinnedMessage.sender_user_id !== chatPage.myUserId) ? Emoji.emojify(Functions.getUserName(tdLibWrapper.getUserInformation(pinnedMessage.sender_user_id)), pinnedMessageUserText.font.pixelSize) : qsTr("You");
|
||||
pinnedMessageUserText.text = (messageUserText === "" ? qsTr("Pinned Message") : messageUserText );
|
||||
pinnedMessageText.text = Emoji.emojify(Functions.getMessageText(pinnedMessage, true, pinnedMessage.sender_user_id === chatPage.myUserId), pinnedMessageText.font.pixelSize);
|
||||
pinnedMessageText.text = Emoji.emojify(Functions.getMessageText(pinnedMessage, true, pinnedMessage.sender_user_id === chatPage.myUserId, false), pinnedMessageText.font.pixelSize);
|
||||
pinnedMessageItem.visible = true;
|
||||
} else {
|
||||
pinnedMessageItem.visible = false;
|
||||
|
|
|
@ -34,12 +34,12 @@ function getUserName(userInformation) {
|
|||
return (firstName + " " + lastName).trim();
|
||||
}
|
||||
|
||||
function getMessageText(message, simple, myself) {
|
||||
function getMessageText(message, simple, myself, ignoreEntities) {
|
||||
if (message.content['@type'] === 'messageText') {
|
||||
if (simple) {
|
||||
return message.content.text.text;
|
||||
} else {
|
||||
return enhanceMessageText(message.content.text);
|
||||
return enhanceMessageText(message.content.text, ignoreEntities);
|
||||
}
|
||||
}
|
||||
if (message.content['@type'] === 'messageSticker') {
|
||||
|
@ -47,14 +47,14 @@ function getMessageText(message, simple, myself) {
|
|||
}
|
||||
if (message.content['@type'] === 'messagePhoto') {
|
||||
if (message.content.caption.text !== "") {
|
||||
return simple ? qsTr("Picture: %1").arg(message.content.caption.text) : enhanceMessageText(message.content.caption)
|
||||
return simple ? qsTr("Picture: %1").arg(message.content.caption.text) : enhanceMessageText(message.content.caption, ignoreEntities)
|
||||
} else {
|
||||
return simple ? (myself ? qsTr("sent a picture", "myself") : qsTr("sent a picture")) : "";
|
||||
}
|
||||
}
|
||||
if (message.content['@type'] === 'messageVideo') {
|
||||
if (message.content.caption.text !== "") {
|
||||
return simple ? qsTr("Video: %1").arg(message.content.caption.text) : enhanceMessageText(message.content.caption)
|
||||
return simple ? qsTr("Video: %1").arg(message.content.caption.text) : enhanceMessageText(message.content.caption, ignoreEntities)
|
||||
} else {
|
||||
return simple ? (myself ? qsTr("sent a video", "myself") : qsTr("sent a video")) : "";
|
||||
}
|
||||
|
@ -64,28 +64,28 @@ function getMessageText(message, simple, myself) {
|
|||
}
|
||||
if (message.content['@type'] === 'messageAnimation') {
|
||||
if (message.content.caption.text !== "") {
|
||||
return simple ? qsTr("Animation: %1").arg(message.content.caption.text) : enhanceMessageText(message.content.caption)
|
||||
return simple ? qsTr("Animation: %1").arg(message.content.caption.text) : enhanceMessageText(message.content.caption, ignoreEntities)
|
||||
} else {
|
||||
return simple ? (myself ? qsTr("sent an animation", "myself") : qsTr("sent an animation")) : "";
|
||||
}
|
||||
}
|
||||
if (message.content['@type'] === 'messageAudio') {
|
||||
if (message.content.caption.text !== "") {
|
||||
return simple ? qsTr("Audio: %1").arg(message.content.caption.text) : enhanceMessageText(message.content.caption)
|
||||
return simple ? qsTr("Audio: %1").arg(message.content.caption.text) : enhanceMessageText(message.content.caption, ignoreEntities)
|
||||
} else {
|
||||
return simple ? (myself ? qsTr("sent an audio", "myself") : qsTr("sent an audio")) : "";
|
||||
}
|
||||
}
|
||||
if (message.content['@type'] === 'messageVoiceNote') {
|
||||
if (message.content.caption.text !== "") {
|
||||
return simple ? qsTr("Voice Note: %1").arg(message.content.caption.text) : enhanceMessageText(message.content.caption)
|
||||
return simple ? qsTr("Voice Note: %1").arg(message.content.caption.text) : enhanceMessageText(message.content.caption, ignoreEntities)
|
||||
} else {
|
||||
return simple ? (myself ? qsTr("sent a voice note", "myself") : qsTr("sent a voice note")) : "";
|
||||
}
|
||||
}
|
||||
if (message.content['@type'] === 'messageDocument') {
|
||||
if (message.content.document.file_name !== "") {
|
||||
return simple ? qsTr("Document: %1").arg(message.content.document.file_name) : (message.content.document.file_name + ( message.content.caption.text !== "" ? ("<br />" + enhanceMessageText(message.content.caption) ) : "")).trim();
|
||||
return simple ? qsTr("Document: %1").arg(message.content.document.file_name) : (message.content.document.file_name + ( message.content.caption.text !== "" ? ("<br />" + enhanceMessageText(message.content.caption, ignoreEntities) ) : "")).trim();
|
||||
} else {
|
||||
return simple ? (myself ? qsTr("sent a document", "myself") : qsTr("sent a document")) : "";
|
||||
}
|
||||
|
@ -269,11 +269,15 @@ function enhanceHtmlEntities(simpleText) {
|
|||
|
||||
}
|
||||
|
||||
function enhanceMessageText(formattedText) {
|
||||
function enhanceMessageText(formattedText, ignoreEntities) {
|
||||
|
||||
var messageInsertions = [];
|
||||
var messageText = formattedText.text;
|
||||
|
||||
if (ignoreEntities) {
|
||||
return messageText;
|
||||
}
|
||||
|
||||
handleHtmlEntity(messageText, messageInsertions, "&", "&");
|
||||
handleHtmlEntity(messageText, messageInsertions, "<", "<");
|
||||
handleHtmlEntity(messageText, messageInsertions, ">", ">");
|
||||
|
@ -341,16 +345,6 @@ function enhanceMessageText(formattedText) {
|
|||
|
||||
messageText = messageText.replace(new RegExp("\r?\n", "g"), "<br>");
|
||||
|
||||
// var spaceRegex = /\s{2,}/g;
|
||||
// function spaceReplacer(match, p1, offset, string) {
|
||||
// var replaceString = "";
|
||||
// for (var i = 0; i < match.length; i++) {
|
||||
// replaceString += " ";
|
||||
// }
|
||||
// return replaceString;
|
||||
// }
|
||||
// messageText = messageText.replace(spaceRegex, spaceReplacer);
|
||||
|
||||
return messageText;
|
||||
|
||||
}
|
||||
|
|
|
@ -11,8 +11,8 @@ Name: harbour-fernschreiber
|
|||
# << macros
|
||||
|
||||
Summary: Fernschreiber is a Telegram client for Sailfish OS
|
||||
Version: 0.5
|
||||
Release: 2
|
||||
Version: 0.5.1
|
||||
Release: 1
|
||||
Group: Qt/Qt
|
||||
License: LICENSE
|
||||
URL: http://werkwolf.eu/
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
Name: harbour-fernschreiber
|
||||
Summary: Fernschreiber is a Telegram client for Sailfish OS
|
||||
Version: 0.5
|
||||
Release: 2
|
||||
Version: 0.5.1
|
||||
Release: 1
|
||||
# The contents of the Group field should be one of the groups listed here:
|
||||
# https://github.com/mer-tools/spectacle/blob/master/data/GROUPS
|
||||
Group: Qt/Qt
|
||||
|
|
|
@ -336,8 +336,8 @@ void ChatModel::handleMessageContentUpdated(const QString &id, const QString &me
|
|||
this->messages.replace(messageIndex, messageToBeUpdated);
|
||||
this->calculateMessageIndexMap();
|
||||
LOG("Message was replaced at index" << messageIndex);
|
||||
emit messageUpdated(messageIndex);
|
||||
emit dataChanged(index(messageIndex), index(messageIndex));
|
||||
emit messageUpdated(messageIndex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue