Fix #65.
This commit is contained in:
parent
5b029ed906
commit
c9d1d68877
|
@ -72,7 +72,7 @@ RowLayout {
|
||||||
TextEdit {
|
TextEdit {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|
||||||
text: (highlighted ? "<style>a{color: white;}</style>" : "") + display
|
text: (highlighted ? "<style>a{color: white;} .user-pill{color: white}</style>" : "<style>a{color: " + Material.accent + ";} .user-pill{color: " + Material.accent + "}</style>") + display
|
||||||
|
|
||||||
visible: isText
|
visible: isText
|
||||||
color: highlighted ? "white": Material.foreground
|
color: highlighted ? "white": Material.foreground
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include <events/roommemberevent.h>
|
#include <events/roommemberevent.h>
|
||||||
#include <events/simplestateevents.h>
|
#include <events/simplestateevents.h>
|
||||||
|
|
||||||
|
#include <QRegExp>
|
||||||
#include <QtCore/QDebug>
|
#include <QtCore/QDebug>
|
||||||
#include <QtQml> // for qmlRegisterType()
|
#include <QtQml> // for qmlRegisterType()
|
||||||
|
|
||||||
|
@ -327,8 +328,14 @@ QVariant MessageEventModel::data(const QModelIndex& idx, int role) const {
|
||||||
[this](const RoomMessageEvent& e) {
|
[this](const RoomMessageEvent& e) {
|
||||||
using namespace MessageEventContent;
|
using namespace MessageEventContent;
|
||||||
|
|
||||||
if (e.hasTextContent() && e.mimeType().name() != "text/plain")
|
if (e.hasTextContent() && e.mimeType().name() != "text/plain") {
|
||||||
return static_cast<const TextContent*>(e.content())->body;
|
static const QRegExp userPillRegExp(
|
||||||
|
"<a (href=\"https://matrix.to/#/@.*:.*\")>(.*)</a>");
|
||||||
|
static const QRegExp replyToRegExp(
|
||||||
|
"<a href=\"https://matrix.to/#/!.*:.*/\\$.*:.*\">In reply to</a>");
|
||||||
|
return QString(static_cast<const TextContent*>(e.content())->body)
|
||||||
|
.replace(userPillRegExp, "<b class=\"user-pill\" \\1>\\2</b>").replace(replyToRegExp, "");
|
||||||
|
}
|
||||||
if (e.hasFileContent()) {
|
if (e.hasFileContent()) {
|
||||||
auto fileCaption = e.content()->fileInfo()->originalName;
|
auto fileCaption = e.content()->fileInfo()->originalName;
|
||||||
if (fileCaption.isEmpty())
|
if (fileCaption.isEmpty())
|
||||||
|
@ -416,7 +423,11 @@ QVariant MessageEventModel::data(const QModelIndex& idx, int role) const {
|
||||||
tr("Unknown Event"));
|
tr("Unknown Event"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (role == MessageRole) return evt.contentJson().value("body");
|
if (role == MessageRole) {
|
||||||
|
static const QRegExp rmReplyRegExp("^> <@.*:.*> .*\n\n(.*)");
|
||||||
|
return evt.contentJson().value("body").toString().replace(rmReplyRegExp,
|
||||||
|
"\\1");
|
||||||
|
}
|
||||||
|
|
||||||
if (role == Qt::ToolTipRole) {
|
if (role == Qt::ToolTipRole) {
|
||||||
return evt.originalJson();
|
return evt.originalJson();
|
||||||
|
|
Loading…
Reference in New Issue