diff --git a/src/TextInputWidget.cpp b/src/TextInputWidget.cpp
index 8becf5ce..1ae26c2d 100644
--- a/src/TextInputWidget.cpp
+++ b/src/TextInputWidget.cpp
@@ -440,12 +440,13 @@ FilteredTextEdit::submit()
}
void
-FilteredTextEdit::showReplyPopup(const QString &user, const QString &msg, const QString &event_id)
+FilteredTextEdit::showReplyPopup(const RelatedInfo &related)
{
QPoint pos = viewport()->mapToGlobal(this->pos());
- replyPopup_.setReplyContent(user, msg, event_id);
+ replyPopup_.setReplyContent(related);
replyPopup_.move(pos.x(), pos.y() - replyPopup_.height() - 10);
+ replyPopup_.setFixedWidth(this->parentWidget()->width());
replyPopup_.show();
}
@@ -699,8 +700,7 @@ TextInputWidget::addReply(const RelatedInfo &related)
// input_->setText(QString("> %1: %2\n\n").arg(username).arg(msg));
input_->setFocus();
- input_->showReplyPopup(
- related.quoted_user, related.quoted_body, QString::fromStdString(related.related_event));
+ input_->showReplyPopup(related);
auto cursor = input_->textCursor();
cursor.movePosition(QTextCursor::End);
input_->setTextCursor(cursor);
diff --git a/src/TextInputWidget.h b/src/TextInputWidget.h
index f68560e9..4a726364 100644
--- a/src/TextInputWidget.h
+++ b/src/TextInputWidget.h
@@ -57,7 +57,7 @@ public:
void submit();
void setRelated(const RelatedInfo &related) { related_ = related; }
- void showReplyPopup(const QString &user, const QString &msg, const QString &event_id);
+ void showReplyPopup(const RelatedInfo &related);
signals:
void heightChanged(int height);
diff --git a/src/popups/ReplyPopup.cpp b/src/popups/ReplyPopup.cpp
index 3c7c482a..0ebf7c88 100644
--- a/src/popups/ReplyPopup.cpp
+++ b/src/popups/ReplyPopup.cpp
@@ -7,6 +7,7 @@
#include "../Utils.h"
#include "../ui/Avatar.h"
#include "../ui/DropShadow.h"
+#include "../ui/TextLabel.h"
#include "ReplyPopup.h"
ReplyPopup::ReplyPopup(QWidget *parent)
@@ -42,7 +43,7 @@ ReplyPopup::ReplyPopup(QWidget *parent)
closeBtn_ = new FlatButton(this);
closeBtn_->setToolTip(tr("Logout"));
- closeBtn_->setCornerRadius(buttonSize_ / 2);
+ closeBtn_->setCornerRadius(buttonSize_ / 4);
closeBtn_->setText("X");
QIcon icon;
@@ -57,7 +58,8 @@ ReplyPopup::ReplyPopup(QWidget *parent)
topLayout_->addLayout(buttonLayout_);
mainLayout_->addLayout(topLayout_);
- msgLabel_ = new QLabel(this);
+ msgLabel_ = new TextLabel(this);
+ msgLabel_->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextBrowserInteraction);
mainLayout_->addWidget(msgLabel_);
eventLabel_ = new QLabel(this);
mainLayout_->addWidget(eventLabel_);
@@ -66,14 +68,16 @@ ReplyPopup::ReplyPopup(QWidget *parent)
}
void
-ReplyPopup::setReplyContent(const QString &user, const QString &msg, const QString &srcEvent)
+ReplyPopup::setReplyContent(const RelatedInfo &related)
{
// Update the current widget with the new data.
- userItem_->updateItem(user);
+ userItem_->updateItem(related.quoted_user);
- msgLabel_->setText(msg);
+ msgLabel_->setText(utils::getFormattedQuoteBody(related, "")
+ .replace("<mx-reply>", "")
+ .replace("</mx-reply>", ""));
- eventLabel_->setText(srcEvent);
+ // eventLabel_->setText(srcEvent);
adjustSize();
}
diff --git a/src/popups/ReplyPopup.h b/src/popups/ReplyPopup.h
index 829f707b..b28cd0cf 100644
--- a/src/popups/ReplyPopup.h
+++ b/src/popups/ReplyPopup.h
@@ -9,7 +9,9 @@
#include "../AvatarProvider.h"
#include "../Cache.h"
#include "../ChatPage.h"
+#include "../Utils.h"
#include "../ui/FlatButton.h"
+#include "../ui/TextLabel.h"
#include "PopupItem.h"
class ReplyPopup : public QWidget
@@ -20,7 +22,7 @@ public:
explicit ReplyPopup(QWidget *parent = nullptr);
public slots:
- void setReplyContent(const QString &user, const QString &msg, const QString &srcEvent);
+ void setReplyContent(const RelatedInfo &related);
protected:
void paintEvent(QPaintEvent *event) override;
@@ -38,7 +40,7 @@ private:
UserItem *userItem_;
FlatButton *closeBtn_;
- QLabel *msgLabel_;
+ TextLabel *msgLabel_;
QLabel *eventLabel_;
int buttonSize_;
diff --git a/src/timeline/TimelineItem.cpp b/src/timeline/TimelineItem.cpp
index bf5b1b53..1094bde5 100644
--- a/src/timeline/TimelineItem.cpp
+++ b/src/timeline/TimelineItem.cpp
@@ -316,6 +316,8 @@ TimelineItem::TimelineItem(mtx::events::MessageType ty,
}
formatted_body = utils::linkifyMessage(formatted_body);
+ formatted_body.replace("mx-reply", "div");
+ nhlog::ui()->info("formatted_body: {}", formatted_body.toStdString());
generateTimestamp(timestamp);
diff --git a/src/timeline/TimelineView.cpp b/src/timeline/TimelineView.cpp
index fc89fd38..18b73eb0 100644
--- a/src/timeline/TimelineView.cpp
+++ b/src/timeline/TimelineView.cpp
@@ -696,15 +696,21 @@ TimelineView::addUserMessage(mtx::events::MessageType ty,
{
auto with_sender = (lastSender_ != local_user_) || isDateDifference(lastMsgTimestamp_);
+ QString full_body;
+ if (related.related_event.empty()) {
+ full_body = body;
+ } else {
+ full_body = utils::getFormattedQuoteBody(related, body);
+ }
TimelineItem *view_item =
- new TimelineItem(ty, local_user_, body, with_sender, room_id_, scroll_widget_);
+ new TimelineItem(ty, local_user_, full_body, with_sender, room_id_, scroll_widget_);
PendingMessage message;
message.ty = ty;
message.txn_id = http::client()->generate_txn_id();
message.body = body;
- message.widget = view_item;
message.related = related;
+ message.widget = view_item;
try {
message.is_encrypted = cache::client()->isRoomEncrypted(room_id_.toStdString());
|