Prepare edit message

This commit is contained in:
Sebastian J. Wolf 2020-09-18 23:43:23 +02:00
parent 3acdf46439
commit b625ce84ef
4 changed files with 37 additions and 3 deletions

View file

@ -228,6 +228,7 @@ Page {
anchors.fill: parent anchors.fill: parent
PullDownMenu { PullDownMenu {
visible: chatInformation.id !== chatPage.myUserId
MenuItem { MenuItem {
id: muteChatMenuItem id: muteChatMenuItem
onClicked: { onClicked: {
@ -392,6 +393,14 @@ Page {
} }
text: qsTr("Reply to Message") text: qsTr("Reply to Message")
} }
MenuItem {
onClicked: {
newMessageColumn.editMessageId = display.id;
newMessageTextField.text = Functions.getMessageText(display, false);
}
text: qsTr("Edit Message")
visible: display.can_be_edited
}
} }
Connections { Connections {
@ -645,10 +654,10 @@ Page {
visible: !chatPage.isChannel visible: !chatPage.isChannel
property string replyToMessageId: "0"; property string replyToMessageId: "0";
property string editMessageId: "0";
InReplyToRow { InReplyToRow {
onInReplyToMessageChanged: { onInReplyToMessageChanged: {
console.log("This is a reply!");
if (inReplyToMessage) { if (inReplyToMessage) {
newMessageColumn.replyToMessageId = newMessageInReplyToRow.inReplyToMessage.id.toString() newMessageColumn.replyToMessageId = newMessageInReplyToRow.inReplyToMessage.id.toString()
newMessageInReplyToRow.visible = true; newMessageInReplyToRow.visible = true;
@ -664,10 +673,21 @@ Page {
visible: false visible: false
} }
Text {
width: parent.width
id: editMessageText
font.pixelSize: Theme.fontSizeSmall
font.bold: true
text: qsTr("Edit Message")
color: Theme.secondaryColor
visible: newMessageColumn.editMessageId !== "0"
}
Row { Row {
id: newMessageRow id: newMessageRow
width: parent.width width: parent.width
height: sendMessageColumn.height + Theme.paddingLarge height: sendMessageColumn.height + Theme.paddingMedium
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
Column { Column {
@ -682,9 +702,14 @@ Page {
placeholderText: qsTr("Your message") placeholderText: qsTr("Your message")
labelVisible: false labelVisible: false
textLeftMargin: 0 textLeftMargin: 0
textTopMargin: 0
onFocusChanged: { onFocusChanged: {
if (!focus) { if (!focus) {
newMessageInReplyToRow.inReplyToMessage = null; newMessageInReplyToRow.inReplyToMessage = null;
if (newMessageColumn.editMessageId !== "0") {
newMessageColumn.editMessageId = "0";
newMessageTextField.text = "";
}
} }
} }
EnterKey.onClicked: { EnterKey.onClicked: {
@ -720,7 +745,7 @@ Page {
Column { Column {
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.bottomMargin: Theme.paddingLarge anchors.bottomMargin: Theme.paddingSmall
IconButton { IconButton {
id: newMessageSendButton id: newMessageSendButton

View file

@ -232,6 +232,7 @@ Page {
} }
menu: ContextMenu { menu: ContextMenu {
visible: display.id !== overviewPage.ownUserId
MenuItem { MenuItem {
onClicked: { onClicked: {
var newNotificationSettings = display.notification_settings; var newNotificationSettings = display.notification_settings;

View file

@ -161,6 +161,10 @@
<source>Mute Chat</source> <source>Mute Chat</source>
<translation>Chat stummschalten</translation> <translation>Chat stummschalten</translation>
</message> </message>
<message>
<source>Edit Message</source>
<translation>Nachricht ändern</translation>
</message>
</context> </context>
<context> <context>
<name>CoverPage</name> <name>CoverPage</name>

View file

@ -161,6 +161,10 @@
<source>Mute Chat</source> <source>Mute Chat</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Edit Message</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>CoverPage</name> <name>CoverPage</name>