Add quick way to reply to messages

This commit is contained in:
Carl Schwan
2020-11-24 11:41:15 +01:00
parent b6ad038a54
commit 6ef7e4cd1c
2 changed files with 40 additions and 6 deletions

View File

@@ -31,6 +31,7 @@ RowLayout {
signal saveFileAs() signal saveFileAs()
signal openExternally() signal openExternally()
signal replyClicked(string eventID) signal replyClicked(string eventID)
signal replyToMessageClicked(var replyUser, string replyContent, string eventID)
id: root id: root
@@ -77,11 +78,15 @@ RowLayout {
Layout.fillWidth: true Layout.fillWidth: true
topPadding: 0 topPadding: 0
bottomPadding: 0 bottomPadding: 0
hoverEnabled: true
contentItem: ColumnLayout { contentItem: ColumnLayout {
id: column id: column
spacing: Kirigami.Units.smallSpacing spacing: Kirigami.Units.smallSpacing
RowLayout { RowLayout {
id: rowLayout
Layout.fillWidth: true
Layout.minimumHeight: 1
QQC2.Label { QQC2.Label {
Layout.fillWidth: true Layout.fillWidth: true
topInset: 0 topInset: 0
@@ -93,7 +98,6 @@ RowLayout {
color: author.color color: author.color
wrapMode: Text.Wrap wrapMode: Text.Wrap
} }
QQC2.Label { QQC2.Label {
visible: showAuthor visible: showAuthor
text: time.toLocaleTimeString(Locale.ShortFormat) text: time.toLocaleTimeString(Locale.ShortFormat)
@@ -110,5 +114,24 @@ RowLayout {
onClicked: replyClicked(reply.eventId) 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)
}
}
} }
} }

View File

@@ -204,6 +204,7 @@ Kirigami.ScrollablePage {
onClicked: openMessageContext(author, display, eventId, toolTip); onClicked: openMessageContext(author, display, eventId, toolTip);
} }
onReplyClicked: goToEvent(eventID) onReplyClicked: goToEvent(eventID)
onReplyToMessageClicked: replyToMessage(replyUser, replyContent, eventId);
innerObject: [ innerObject: [
TextDelegate { TextDelegate {
Layout.fillWidth: true Layout.fillWidth: true
@@ -227,6 +228,7 @@ Kirigami.ScrollablePage {
innerObject: MessageDelegate { innerObject: MessageDelegate {
Layout.fillWidth: true Layout.fillWidth: true
onReplyClicked: goToEvent(eventID) onReplyClicked: goToEvent(eventID)
onReplyToMessageClicked: replyToMessage(replyUser, replyContent, eventId);
innerObject: TextDelegate { innerObject: TextDelegate {
Layout.fillWidth: true Layout.fillWidth: true
@@ -243,6 +245,7 @@ Kirigami.ScrollablePage {
innerObject: MessageDelegate { innerObject: MessageDelegate {
Layout.fillWidth: true Layout.fillWidth: true
onReplyClicked: goToEvent(eventID) onReplyClicked: goToEvent(eventID)
onReplyToMessageClicked: replyToMessage(replyUser, replyContent, eventId);
innerObject: [ innerObject: [
ImageDelegate { ImageDelegate {
@@ -268,6 +271,7 @@ Kirigami.ScrollablePage {
innerObject: MessageDelegate { innerObject: MessageDelegate {
Layout.fillWidth: true Layout.fillWidth: true
onReplyClicked: goToEvent(eventID) onReplyClicked: goToEvent(eventID)
onReplyToMessageClicked: replyToMessage(replyUser, replyContent, eventId);
innerObject: AudioDelegate { innerObject: AudioDelegate {
Layout.fillWidth: true Layout.fillWidth: true
@@ -284,6 +288,7 @@ Kirigami.ScrollablePage {
innerObject: MessageDelegate { innerObject: MessageDelegate {
Layout.fillWidth: true Layout.fillWidth: true
onReplyClicked: goToEvent(eventID) onReplyClicked: goToEvent(eventID)
onReplyToMessageClicked: replyToMessage(replyUser, replyContent, eventId);
innerObject: AudioDelegate { innerObject: AudioDelegate {
Layout.fillWidth: true Layout.fillWidth: true
@@ -299,6 +304,8 @@ Kirigami.ScrollablePage {
innerObject: MessageDelegate { innerObject: MessageDelegate {
Layout.fillWidth: true Layout.fillWidth: true
onReplyClicked: goToEvent(eventID)
onReplyToMessageClicked: replyToMessage(replyUser, replyContent, eventId);
innerObject: FileDelegate { innerObject: FileDelegate {
Layout.fillWidth: true Layout.fillWidth: true
@@ -440,11 +447,7 @@ Kirigami.ScrollablePage {
contextMenu.close(); contextMenu.close();
}); });
contextMenu.reply.connect(function(replyUser, replyContent) { contextMenu.reply.connect(function(replyUser, replyContent) {
chatTextInput.replyUser = replyUser; replyToMessage(replyUser, replyContent, eventId);
chatTextInput.replyEventID = eventId;
chatTextInput.replyContent = replyContent;
chatTextInput.isReply = true;
chatTextInput.focus();
contextMenu.close(); contextMenu.close();
}) })
contextMenu.remove.connect(function() { contextMenu.remove.connect(function() {
@@ -453,4 +456,12 @@ Kirigami.ScrollablePage {
}) })
contextMenu.open() contextMenu.open()
} }
function replyToMessage(replyUser, replyContent, eventId) {
chatTextInput.replyUser = replyUser;
chatTextInput.replyEventID = eventId;
chatTextInput.replyContent = replyContent;
chatTextInput.isReply = true;
chatTextInput.focus();
}
} }