From b625ce84ef65c9c49f65761d0c3a5ad377db6148 Mon Sep 17 00:00:00 2001 From: "Sebastian J. Wolf" Date: Fri, 18 Sep 2020 23:43:23 +0200 Subject: [PATCH] Prepare edit message --- qml/pages/ChatPage.qml | 31 +++++++++++++++++++++--- qml/pages/OverviewPage.qml | 1 + translations/harbour-fernschreiber-de.ts | 4 +++ translations/harbour-fernschreiber.ts | 4 +++ 4 files changed, 37 insertions(+), 3 deletions(-) diff --git a/qml/pages/ChatPage.qml b/qml/pages/ChatPage.qml index 6b7d85a..d18a113 100644 --- a/qml/pages/ChatPage.qml +++ b/qml/pages/ChatPage.qml @@ -228,6 +228,7 @@ Page { anchors.fill: parent PullDownMenu { + visible: chatInformation.id !== chatPage.myUserId MenuItem { id: muteChatMenuItem onClicked: { @@ -392,6 +393,14 @@ Page { } 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 { @@ -645,10 +654,10 @@ Page { visible: !chatPage.isChannel property string replyToMessageId: "0"; + property string editMessageId: "0"; InReplyToRow { onInReplyToMessageChanged: { - console.log("This is a reply!"); if (inReplyToMessage) { newMessageColumn.replyToMessageId = newMessageInReplyToRow.inReplyToMessage.id.toString() newMessageInReplyToRow.visible = true; @@ -664,10 +673,21 @@ Page { 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 { id: newMessageRow width: parent.width - height: sendMessageColumn.height + Theme.paddingLarge + height: sendMessageColumn.height + Theme.paddingMedium anchors.horizontalCenter: parent.horizontalCenter Column { @@ -682,9 +702,14 @@ Page { placeholderText: qsTr("Your message") labelVisible: false textLeftMargin: 0 + textTopMargin: 0 onFocusChanged: { if (!focus) { newMessageInReplyToRow.inReplyToMessage = null; + if (newMessageColumn.editMessageId !== "0") { + newMessageColumn.editMessageId = "0"; + newMessageTextField.text = ""; + } } } EnterKey.onClicked: { @@ -720,7 +745,7 @@ Page { Column { anchors.bottom: parent.bottom - anchors.bottomMargin: Theme.paddingLarge + anchors.bottomMargin: Theme.paddingSmall IconButton { id: newMessageSendButton diff --git a/qml/pages/OverviewPage.qml b/qml/pages/OverviewPage.qml index 9a86433..b008849 100644 --- a/qml/pages/OverviewPage.qml +++ b/qml/pages/OverviewPage.qml @@ -232,6 +232,7 @@ Page { } menu: ContextMenu { + visible: display.id !== overviewPage.ownUserId MenuItem { onClicked: { var newNotificationSettings = display.notification_settings; diff --git a/translations/harbour-fernschreiber-de.ts b/translations/harbour-fernschreiber-de.ts index 6cc484f..1e9c143 100644 --- a/translations/harbour-fernschreiber-de.ts +++ b/translations/harbour-fernschreiber-de.ts @@ -161,6 +161,10 @@ Mute Chat Chat stummschalten + + Edit Message + Nachricht ändern + CoverPage diff --git a/translations/harbour-fernschreiber.ts b/translations/harbour-fernschreiber.ts index ea5fc89..6d6c549 100644 --- a/translations/harbour-fernschreiber.ts +++ b/translations/harbour-fernschreiber.ts @@ -161,6 +161,10 @@ Mute Chat + + Edit Message + + CoverPage