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 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)
}
}
}
}

View File

@@ -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();
}
}