diff --git a/imports/Spectral/Component/Timeline/MessageDelegate.qml b/imports/Spectral/Component/Timeline/MessageDelegate.qml
index 19db8f9..2baf43a 100644
--- a/imports/Spectral/Component/Timeline/MessageDelegate.qml
+++ b/imports/Spectral/Component/Timeline/MessageDelegate.qml
@@ -98,7 +98,7 @@ ColumnLayout {
id: contentLabel
- text: "" + display
+ text: "" + display
color: "white"
@@ -111,7 +111,17 @@ ColumnLayout {
selectionColor: "white"
textFormat: Text.RichText
- onLinkActivated: Qt.openUrlExternally(link)
+ onLinkActivated: {
+ if (link.startsWith("https://matrix.to/")) {
+ var result = link.replace(/\?.*/, "").match("https://matrix.to/#/(!.*:.*)/(\\$.*:.*)")
+ if (result.length < 3) return
+ if (result[1] != currentRoom.id) return
+ if (!result[2]) return
+ goToEvent(result[2])
+ } else {
+ Qt.openUrlExternally(link)
+ }
+ }
MouseArea {
anchors.fill: parent
diff --git a/src/utils.h b/src/utils.h
index 2304610..1310f00 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -2,6 +2,7 @@
#define Utils_H
#include "room.h"
+#include "user.h"
#include
#include
@@ -32,11 +33,18 @@ QString eventToString(const BaseEventT& evt,
if (prettyPrint && e.hasTextContent() &&
e.mimeType().name() != "text/plain") {
static const QRegExp userPillRegExp(
- "(.*)");
+ ".*");
QString formattedStr(
static_cast(e.content())->body);
- formattedStr.replace(userPillRegExp,
- "\\1");
+ int pos = 0;
+ while ((pos = userPillRegExp.indexIn(formattedStr, pos)) != -1) {
+ QString userId = userPillRegExp.cap(1);
+ formattedStr.remove(pos, userPillRegExp.matchedLength());
+ formattedStr.insert(pos, "" +
+ room->user(userId)->displayname() +
+ "");
+ pos += userPillRegExp.matchedLength();
+ }
return formattedStr;
}
if (e.hasFileContent()) {