Commit a791c574 authored by Jonah Brüchert's avatar Jonah Brüchert 🌳 Committed by Linus Jahn

ChatPage: Add message action for quoting

Signed-off-by: Linus Jahn's avatarLinus Jahn <lnj@kaidan.im>
parent a232118a
Pipeline #13996 passed with stages
in 39 minutes and 18 seconds
......@@ -245,5 +245,10 @@ QString QmlUtils::processMsgFormatting(const QStringList &list, bool isFirst)
return (isFirst ? QString() : " ") + QString("<a href='%1'>%1</a>").arg(list.first())
+ processMsgFormatting(list.mid(1), false);
// preserve newlines
if (list.first().contains("\n"))
return (isFirst ? QString() : " ") + QString(list.first()).replace("\n", "<br>")
+ processMsgFormatting(list.mid(1), false);
return (isFirst ? QString() : " ") + list.first() + processMsgFormatting(list.mid(1), false);
}
......@@ -453,6 +453,16 @@ ChatPageBase {
messageField.text = body
messageField.state = "edit"
}
onQuoteRequested: {
var quotedText = ""
var lines = body.split("\n")
for (var line in lines) {
quotedText += "> " + lines[line] + "\n"
}
messageField.insert(0, quotedText)
}
}
}
......
......@@ -65,6 +65,7 @@ RowLayout {
property string avatarUrl: kaidan.avatarStorage.getAvatarUrl(sender)
signal messageEditRequested(string id, string body)
signal quoteRequested(string body)
// Own messages are on the right, others on the left side.
layoutDirection: sentByMe ? Qt.RightToLeft : Qt.LeftToRight
......@@ -143,6 +144,13 @@ RowLayout {
enabled: mediaGetUrl
onTriggered: Utils.copyToClipboard(mediaGetUrl)
}
Controls.MenuItem {
text: qsTr("Quote")
onTriggered: {
root.quoteRequested(messageBody)
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment