Further UI Updates to Rich Replies
This commit is contained in:
parent
129beb57c9
commit
cfd6c5703a
@ -440,12 +440,13 @@ FilteredTextEdit::submit()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FilteredTextEdit::showReplyPopup(const QString &user, const QString &msg, const QString &event_id)
|
FilteredTextEdit::showReplyPopup(const RelatedInfo &related)
|
||||||
{
|
{
|
||||||
QPoint pos = viewport()->mapToGlobal(this->pos());
|
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_.move(pos.x(), pos.y() - replyPopup_.height() - 10);
|
||||||
|
replyPopup_.setFixedWidth(this->parentWidget()->width());
|
||||||
replyPopup_.show();
|
replyPopup_.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -699,8 +700,7 @@ TextInputWidget::addReply(const RelatedInfo &related)
|
|||||||
// input_->setText(QString("> %1: %2\n\n").arg(username).arg(msg));
|
// input_->setText(QString("> %1: %2\n\n").arg(username).arg(msg));
|
||||||
input_->setFocus();
|
input_->setFocus();
|
||||||
|
|
||||||
input_->showReplyPopup(
|
input_->showReplyPopup(related);
|
||||||
related.quoted_user, related.quoted_body, QString::fromStdString(related.related_event));
|
|
||||||
auto cursor = input_->textCursor();
|
auto cursor = input_->textCursor();
|
||||||
cursor.movePosition(QTextCursor::End);
|
cursor.movePosition(QTextCursor::End);
|
||||||
input_->setTextCursor(cursor);
|
input_->setTextCursor(cursor);
|
||||||
|
@ -57,7 +57,7 @@ public:
|
|||||||
|
|
||||||
void submit();
|
void submit();
|
||||||
void setRelated(const RelatedInfo &related) { related_ = related; }
|
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:
|
signals:
|
||||||
void heightChanged(int height);
|
void heightChanged(int height);
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include "../Utils.h"
|
#include "../Utils.h"
|
||||||
#include "../ui/Avatar.h"
|
#include "../ui/Avatar.h"
|
||||||
#include "../ui/DropShadow.h"
|
#include "../ui/DropShadow.h"
|
||||||
|
#include "../ui/TextLabel.h"
|
||||||
#include "ReplyPopup.h"
|
#include "ReplyPopup.h"
|
||||||
|
|
||||||
ReplyPopup::ReplyPopup(QWidget *parent)
|
ReplyPopup::ReplyPopup(QWidget *parent)
|
||||||
@ -42,7 +43,7 @@ ReplyPopup::ReplyPopup(QWidget *parent)
|
|||||||
|
|
||||||
closeBtn_ = new FlatButton(this);
|
closeBtn_ = new FlatButton(this);
|
||||||
closeBtn_->setToolTip(tr("Logout"));
|
closeBtn_->setToolTip(tr("Logout"));
|
||||||
closeBtn_->setCornerRadius(buttonSize_ / 2);
|
closeBtn_->setCornerRadius(buttonSize_ / 4);
|
||||||
closeBtn_->setText("X");
|
closeBtn_->setText("X");
|
||||||
|
|
||||||
QIcon icon;
|
QIcon icon;
|
||||||
@ -57,7 +58,8 @@ ReplyPopup::ReplyPopup(QWidget *parent)
|
|||||||
topLayout_->addLayout(buttonLayout_);
|
topLayout_->addLayout(buttonLayout_);
|
||||||
|
|
||||||
mainLayout_->addLayout(topLayout_);
|
mainLayout_->addLayout(topLayout_);
|
||||||
msgLabel_ = new QLabel(this);
|
msgLabel_ = new TextLabel(this);
|
||||||
|
msgLabel_->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextBrowserInteraction);
|
||||||
mainLayout_->addWidget(msgLabel_);
|
mainLayout_->addWidget(msgLabel_);
|
||||||
eventLabel_ = new QLabel(this);
|
eventLabel_ = new QLabel(this);
|
||||||
mainLayout_->addWidget(eventLabel_);
|
mainLayout_->addWidget(eventLabel_);
|
||||||
@ -66,14 +68,16 @@ ReplyPopup::ReplyPopup(QWidget *parent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
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.
|
// 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();
|
adjustSize();
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,9 @@
|
|||||||
#include "../AvatarProvider.h"
|
#include "../AvatarProvider.h"
|
||||||
#include "../Cache.h"
|
#include "../Cache.h"
|
||||||
#include "../ChatPage.h"
|
#include "../ChatPage.h"
|
||||||
|
#include "../Utils.h"
|
||||||
#include "../ui/FlatButton.h"
|
#include "../ui/FlatButton.h"
|
||||||
|
#include "../ui/TextLabel.h"
|
||||||
#include "PopupItem.h"
|
#include "PopupItem.h"
|
||||||
|
|
||||||
class ReplyPopup : public QWidget
|
class ReplyPopup : public QWidget
|
||||||
@ -20,7 +22,7 @@ public:
|
|||||||
explicit ReplyPopup(QWidget *parent = nullptr);
|
explicit ReplyPopup(QWidget *parent = nullptr);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setReplyContent(const QString &user, const QString &msg, const QString &srcEvent);
|
void setReplyContent(const RelatedInfo &related);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *event) override;
|
void paintEvent(QPaintEvent *event) override;
|
||||||
@ -38,7 +40,7 @@ private:
|
|||||||
|
|
||||||
UserItem *userItem_;
|
UserItem *userItem_;
|
||||||
FlatButton *closeBtn_;
|
FlatButton *closeBtn_;
|
||||||
QLabel *msgLabel_;
|
TextLabel *msgLabel_;
|
||||||
QLabel *eventLabel_;
|
QLabel *eventLabel_;
|
||||||
|
|
||||||
int buttonSize_;
|
int buttonSize_;
|
||||||
|
@ -316,6 +316,8 @@ TimelineItem::TimelineItem(mtx::events::MessageType ty,
|
|||||||
}
|
}
|
||||||
|
|
||||||
formatted_body = utils::linkifyMessage(formatted_body);
|
formatted_body = utils::linkifyMessage(formatted_body);
|
||||||
|
formatted_body.replace("mx-reply", "div");
|
||||||
|
nhlog::ui()->info("formatted_body: {}", formatted_body.toStdString());
|
||||||
|
|
||||||
generateTimestamp(timestamp);
|
generateTimestamp(timestamp);
|
||||||
|
|
||||||
|
@ -696,15 +696,21 @@ TimelineView::addUserMessage(mtx::events::MessageType ty,
|
|||||||
{
|
{
|
||||||
auto with_sender = (lastSender_ != local_user_) || isDateDifference(lastMsgTimestamp_);
|
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 =
|
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;
|
PendingMessage message;
|
||||||
message.ty = ty;
|
message.ty = ty;
|
||||||
message.txn_id = http::client()->generate_txn_id();
|
message.txn_id = http::client()->generate_txn_id();
|
||||||
message.body = body;
|
message.body = body;
|
||||||
message.widget = view_item;
|
|
||||||
message.related = related;
|
message.related = related;
|
||||||
|
message.widget = view_item;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
message.is_encrypted = cache::client()->isRoomEncrypted(room_id_.toStdString());
|
message.is_encrypted = cache::client()->isRoomEncrypted(room_id_.toStdString());
|
||||||
|
Loading…
Reference in New Issue
Block a user