Better rich reply.
This commit is contained in:
parent
cc5ba20375
commit
e7b2698521
|
@ -99,18 +99,32 @@ ColumnLayout {
|
||||||
|
|
||||||
visible: replyEventId || ""
|
visible: replyEventId || ""
|
||||||
|
|
||||||
background: MouseArea {
|
padding: 8
|
||||||
|
|
||||||
|
background: Item {
|
||||||
|
Rectangle {
|
||||||
|
anchors.leftMargin: 0
|
||||||
|
width: 2
|
||||||
|
height: parent.height
|
||||||
|
|
||||||
|
color: "white"
|
||||||
|
}
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
|
||||||
onClicked: goToEvent(replyEventId)
|
onClicked: goToEvent(replyEventId)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
contentItem: RowLayout {
|
contentItem: RowLayout {
|
||||||
spacing: 4
|
spacing: 8
|
||||||
|
|
||||||
Rectangle {
|
ImageItem {
|
||||||
Layout.preferredWidth: 2
|
Layout.preferredWidth: 36
|
||||||
Layout.fillHeight: true
|
Layout.preferredHeight: 36
|
||||||
|
Layout.alignment: Qt.AlignTop
|
||||||
|
|
||||||
color: "white"
|
source: replyAuthor ? replyAuthor.paintable : null
|
||||||
}
|
}
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
|
@ -118,38 +132,21 @@ ColumnLayout {
|
||||||
|
|
||||||
spacing: 0
|
spacing: 0
|
||||||
|
|
||||||
Control {
|
|
||||||
padding: 4
|
|
||||||
|
|
||||||
contentItem: RowLayout {
|
|
||||||
spacing: 4
|
|
||||||
|
|
||||||
ImageItem {
|
|
||||||
Layout.preferredWidth: 16
|
|
||||||
Layout.preferredHeight: 16
|
|
||||||
|
|
||||||
source: replyAuthor ? replyAuthor.paintable : null
|
|
||||||
}
|
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
|
||||||
color: "white"
|
color: "white"
|
||||||
text: replyAuthor ? replyAuthor.displayName : ""
|
text: replyAuthor ? replyAuthor.displayName : ""
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
background: Rectangle {
|
font.pixelSize: 13
|
||||||
color: "black"
|
font.weight: Font.Medium
|
||||||
opacity: 0.2
|
|
||||||
radius: height / 2
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|
||||||
text: "<style>a{color: white;} .user-pill{}</style>" + (replyDisplay ? replyDisplay.replace(/<mx-reply>.*<\/mx-reply>/g, "") : "")
|
|
||||||
|
|
||||||
color: "white"
|
color: "white"
|
||||||
|
text: replyDisplay || ""
|
||||||
|
|
||||||
wrapMode: Label.Wrap
|
wrapMode: Label.Wrap
|
||||||
textFormat: Label.RichText
|
textFormat: Label.RichText
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
#include "csapi/joining.h"
|
#include "csapi/joining.h"
|
||||||
#include "csapi/logout.h"
|
#include "csapi/logout.h"
|
||||||
|
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
@ -242,3 +244,7 @@ int Controller::dpi() {
|
||||||
void Controller::setDpi(int dpi) {
|
void Controller::setDpi(int dpi) {
|
||||||
SettingsGroup("Interface").setValue("dpi", dpi);
|
SettingsGroup("Interface").setValue("dpi", dpi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString Controller::removeReply(const QString& text) {
|
||||||
|
return utils::removeReply(text);
|
||||||
|
}
|
||||||
|
|
|
@ -76,6 +76,8 @@ class Controller : public QObject {
|
||||||
void loadSettings();
|
void loadSettings();
|
||||||
void saveSettings() const;
|
void saveSettings() const;
|
||||||
|
|
||||||
|
Q_INVOKABLE QString removeReply(const QString& text);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void invokeLogin();
|
void invokeLogin();
|
||||||
|
|
||||||
|
|
|
@ -261,7 +261,7 @@ QVariant MessageEventModel::data(const QModelIndex &idx, int role) const {
|
||||||
const auto &evt = isPending ? **pendingIt : **timelineIt;
|
const auto &evt = isPending ? **pendingIt : **timelineIt;
|
||||||
|
|
||||||
if (role == Qt::DisplayRole) {
|
if (role == Qt::DisplayRole) {
|
||||||
return utils::eventToString(evt, m_currentRoom, Qt::RichText);
|
return utils::removeReply(utils::eventToString(evt, m_currentRoom, Qt::RichText));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (role == MessageRole) {
|
if (role == MessageRole) {
|
||||||
|
@ -389,7 +389,7 @@ QVariant MessageEventModel::data(const QModelIndex &idx, int role) const {
|
||||||
case ReplyEventIdRole:
|
case ReplyEventIdRole:
|
||||||
return replyEventId;
|
return replyEventId;
|
||||||
case ReplyDisplayRole:
|
case ReplyDisplayRole:
|
||||||
return utils::eventToString(replyEvt, m_currentRoom, Qt::RichText);
|
return utils::removeReply(utils::eventToString(replyEvt, m_currentRoom, Qt::RichText));
|
||||||
case ReplyAuthorRole:
|
case ReplyAuthorRole:
|
||||||
return QVariant::fromValue(
|
return QVariant::fromValue(
|
||||||
m_currentRoom->user(replyEvt.senderId()));
|
m_currentRoom->user(replyEvt.senderId()));
|
||||||
|
|
|
@ -2,5 +2,7 @@
|
||||||
|
|
||||||
QString utils::removeReply(const QString& text) {
|
QString utils::removeReply(const QString& text) {
|
||||||
QString result(text);
|
QString result(text);
|
||||||
return result.remove(utils::removeReplyRegex);
|
result.remove(utils::removeRichReplyRegex);
|
||||||
|
result.remove(utils::removeReplyRegex);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
namespace utils {
|
namespace utils {
|
||||||
const QRegExp removeReplyRegex{"> <.*>.*\\n\\n"};
|
const QRegExp removeReplyRegex{"> <.*>.*\\n\\n"};
|
||||||
|
const QRegExp removeRichReplyRegex{"<mx-reply>.*</mx-reply>"};
|
||||||
|
|
||||||
QString removeReply(const QString& text);
|
QString removeReply(const QString& text);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue