From 6ef7e4cd1c7ad57e2aa62222dae267682c4499c2 Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Tue, 24 Nov 2020 11:41:15 +0100 Subject: [PATCH] Add quick way to reply to messages --- .../Component/Timeline/MessageDelegate.qml | 25 ++++++++++++++++++- imports/NeoChat/Page/RoomPage.qml | 21 ++++++++++++---- 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/imports/NeoChat/Component/Timeline/MessageDelegate.qml b/imports/NeoChat/Component/Timeline/MessageDelegate.qml index e48e92594..292f62443 100644 --- a/imports/NeoChat/Component/Timeline/MessageDelegate.qml +++ b/imports/NeoChat/Component/Timeline/MessageDelegate.qml @@ -31,6 +31,7 @@ RowLayout { signal saveFileAs() signal openExternally() signal replyClicked(string eventID) + signal replyToMessageClicked(var replyUser, string replyContent, string eventID) id: root @@ -77,11 +78,15 @@ RowLayout { Layout.fillWidth: true topPadding: 0 bottomPadding: 0 + hoverEnabled: true contentItem: ColumnLayout { id: column spacing: Kirigami.Units.smallSpacing RowLayout { + id: rowLayout + Layout.fillWidth: true + Layout.minimumHeight: 1 QQC2.Label { Layout.fillWidth: true topInset: 0 @@ -93,7 +98,6 @@ RowLayout { color: author.color wrapMode: Text.Wrap } - QQC2.Label { visible: showAuthor text: time.toLocaleTimeString(Locale.ShortFormat) @@ -110,5 +114,24 @@ RowLayout { onClicked: replyClicked(reply.eventId) } } + RowLayout { + z: 2 + anchors.bottom: controlContainer.top + anchors.bottomMargin: -Kirigami.Units.gridUnit + anchors.right: controlContainer.right + spacing: 0 + QQC2.Button { + QQC2.ToolTip.text: i18n("React") + visible: controlContainer.hovered + icon.name: "preferences-desktop-emoticons" + // TODO onClicked + } + QQC2.Button { + QQC2.ToolTip.text: i18n("Reply") + visible: controlContainer.hovered + icon.name: "mail-replied-symbolic" + onClicked: replyToMessage(author, message, eventId) + } + } } } diff --git a/imports/NeoChat/Page/RoomPage.qml b/imports/NeoChat/Page/RoomPage.qml index d0cd5a37c..0e02ac8b2 100644 --- a/imports/NeoChat/Page/RoomPage.qml +++ b/imports/NeoChat/Page/RoomPage.qml @@ -204,6 +204,7 @@ Kirigami.ScrollablePage { onClicked: openMessageContext(author, display, eventId, toolTip); } onReplyClicked: goToEvent(eventID) + onReplyToMessageClicked: replyToMessage(replyUser, replyContent, eventId); innerObject: [ TextDelegate { Layout.fillWidth: true @@ -227,6 +228,7 @@ Kirigami.ScrollablePage { innerObject: MessageDelegate { Layout.fillWidth: true onReplyClicked: goToEvent(eventID) + onReplyToMessageClicked: replyToMessage(replyUser, replyContent, eventId); innerObject: TextDelegate { Layout.fillWidth: true @@ -243,6 +245,7 @@ Kirigami.ScrollablePage { innerObject: MessageDelegate { Layout.fillWidth: true onReplyClicked: goToEvent(eventID) + onReplyToMessageClicked: replyToMessage(replyUser, replyContent, eventId); innerObject: [ ImageDelegate { @@ -268,6 +271,7 @@ Kirigami.ScrollablePage { innerObject: MessageDelegate { Layout.fillWidth: true onReplyClicked: goToEvent(eventID) + onReplyToMessageClicked: replyToMessage(replyUser, replyContent, eventId); innerObject: AudioDelegate { Layout.fillWidth: true @@ -284,6 +288,7 @@ Kirigami.ScrollablePage { innerObject: MessageDelegate { Layout.fillWidth: true onReplyClicked: goToEvent(eventID) + onReplyToMessageClicked: replyToMessage(replyUser, replyContent, eventId); innerObject: AudioDelegate { Layout.fillWidth: true @@ -299,6 +304,8 @@ Kirigami.ScrollablePage { innerObject: MessageDelegate { Layout.fillWidth: true + onReplyClicked: goToEvent(eventID) + onReplyToMessageClicked: replyToMessage(replyUser, replyContent, eventId); innerObject: FileDelegate { Layout.fillWidth: true @@ -440,11 +447,7 @@ Kirigami.ScrollablePage { contextMenu.close(); }); contextMenu.reply.connect(function(replyUser, replyContent) { - chatTextInput.replyUser = replyUser; - chatTextInput.replyEventID = eventId; - chatTextInput.replyContent = replyContent; - chatTextInput.isReply = true; - chatTextInput.focus(); + replyToMessage(replyUser, replyContent, eventId); contextMenu.close(); }) contextMenu.remove.connect(function() { @@ -453,4 +456,12 @@ Kirigami.ScrollablePage { }) contextMenu.open() } + + function replyToMessage(replyUser, replyContent, eventId) { + chatTextInput.replyUser = replyUser; + chatTextInput.replyEventID = eventId; + chatTextInput.replyContent = replyContent; + chatTextInput.isReply = true; + chatTextInput.focus(); + } }