diff --git a/resources/icons/ui/mail-reply.png b/resources/icons/ui/mail-reply.png
new file mode 100644
index 00000000..a9d377d0
Binary files /dev/null and b/resources/icons/ui/mail-reply.png differ
diff --git a/resources/res.qrc b/resources/res.qrc
index cef55773..6930909e 100644
--- a/resources/res.qrc
+++ b/resources/res.qrc
@@ -62,6 +62,8 @@
icons/ui/edit.png
icons/ui/edit@2x.png
+
+ icons/ui/mail-reply.png
icons/emoji-categories/people.png
icons/emoji-categories/people@2x.png
diff --git a/src/timeline/TimelineItem.cpp b/src/timeline/TimelineItem.cpp
index d23dbf49..24685641 100644
--- a/src/timeline/TimelineItem.cpp
+++ b/src/timeline/TimelineItem.cpp
@@ -126,11 +126,17 @@ void
TimelineItem::adjustMessageLayoutForWidget()
{
messageLayout_->addLayout(widgetLayout_, 1);
+ actionLayout_->addWidget(replyBtn_);
+ actionLayout_->addWidget(contextBtn_);
+ messageLayout_->addLayout(actionLayout_);
messageLayout_->addWidget(statusIndicator_);
messageLayout_->addWidget(timestamp_);
+ actionLayout_->setAlignment(replyBtn_, Qt::AlignTop | Qt::AlignRight);
+ actionLayout_->setAlignment(contextBtn_, Qt::AlignTop | Qt::AlignRight);
messageLayout_->setAlignment(statusIndicator_, Qt::AlignTop);
messageLayout_->setAlignment(timestamp_, Qt::AlignTop);
+ messageLayout_->setAlignment(actionLayout_, Qt::AlignTop);
mainLayout_->addLayout(messageLayout_);
}
@@ -139,11 +145,17 @@ void
TimelineItem::adjustMessageLayout()
{
messageLayout_->addWidget(body_, 1);
+ actionLayout_->addWidget(replyBtn_);
+ actionLayout_->addWidget(contextBtn_);
+ messageLayout_->addLayout(actionLayout_);
messageLayout_->addWidget(statusIndicator_);
messageLayout_->addWidget(timestamp_);
+ actionLayout_->setAlignment(replyBtn_, Qt::AlignTop | Qt::AlignRight);
+ actionLayout_->setAlignment(contextBtn_, Qt::AlignTop | Qt::AlignRight);
messageLayout_->setAlignment(statusIndicator_, Qt::AlignTop);
messageLayout_->setAlignment(timestamp_, Qt::AlignTop);
+ messageLayout_->setAlignment(actionLayout_, Qt::AlignTop);
mainLayout_->addLayout(messageLayout_);
}
@@ -155,6 +167,7 @@ TimelineItem::init()
timestamp_ = nullptr;
userName_ = nullptr;
body_ = nullptr;
+ auto buttonSize_ = 32;
contextMenu_ = new QMenu(this);
showReadReceipts_ = new QAction("Read receipts", this);
@@ -166,6 +179,7 @@ TimelineItem::init()
contextMenu_->addAction(markAsRead_);
contextMenu_->addAction(redactMsg_);
+
connect(showReadReceipts_, &QAction::triggered, this, [this]() {
if (!event_id_.isEmpty())
MainWindow::instance()->openReadReceiptsDialog(event_id_);
@@ -207,9 +221,13 @@ TimelineItem::init()
topLayout_ = new QHBoxLayout(this);
mainLayout_ = new QVBoxLayout;
messageLayout_ = new QHBoxLayout;
+ actionLayout_ = new QHBoxLayout;
messageLayout_->setContentsMargins(0, 0, MSG_RIGHT_MARGIN, 0);
messageLayout_->setSpacing(MSG_PADDING);
+ actionLayout_->setContentsMargins(13, 1, 13, 0);
+ actionLayout_->setSpacing(0);
+
topLayout_->setContentsMargins(
conf::timeline::msgLeftMargin, conf::timeline::msgTopMargin, 0, 0);
topLayout_->setSpacing(0);
@@ -218,6 +236,28 @@ TimelineItem::init()
mainLayout_->setContentsMargins(conf::timeline::headerLeftMargin, 0, 0, 0);
mainLayout_->setSpacing(0);
+ replyBtn_ = new FlatButton(this);
+ replyBtn_->setToolTip(tr("Reply"));
+ replyBtn_->setFixedSize(buttonSize_, buttonSize_);
+ replyBtn_->setCornerRadius(buttonSize_ / 2);
+
+ QIcon reply_icon;
+ reply_icon.addFile(":/icons/icons/ui/mail-reply.png");
+ replyBtn_->setIcon(reply_icon);
+ replyBtn_->setIconSize(QSize(buttonSize_ / 2, buttonSize_ / 2));
+ connect(replyBtn_, &FlatButton::clicked, this, &TimelineItem::replyAction);
+
+ contextBtn_ = new FlatButton(this);
+ contextBtn_->setToolTip(tr("Options"));
+ contextBtn_->setFixedSize(buttonSize_, buttonSize_);
+ contextBtn_->setCornerRadius(buttonSize_ / 2);
+
+ QIcon context_icon;
+ context_icon.addFile(":/icons/icons/ui/vertical-ellipsis.png");
+ contextBtn_->setIcon(context_icon);
+ contextBtn_->setIconSize(QSize(buttonSize_ / 2, buttonSize_ / 2));
+ contextBtn_->setMenu(contextMenu_);
+
timestampFont_.setPointSizeF(timestampFont_.pointSizeF() * 0.9);
timestampFont_.setFamily("Monospace");
timestampFont_.setStyleHint(QFont::Monospace);
@@ -825,15 +865,18 @@ TimelineItem::addReplyAction()
auto replyAction = new QAction("Reply", this);
contextMenu_->addAction(replyAction);
- connect(replyAction, &QAction::triggered, this, [this]() {
+ connect(replyAction, &QAction::triggered, this, &TimelineItem::replyAction);
+ }
+}
+
+void
+TimelineItem::replyAction() {
if (!body_)
return;
emit ChatPage::instance()->messageReply(
Cache::displayName(room_id_, descriptionMsg_.userid),
body_->toPlainText());
- });
- }
}
void
diff --git a/src/timeline/TimelineItem.h b/src/timeline/TimelineItem.h
index 7bf6a076..b0fabdcf 100644
--- a/src/timeline/TimelineItem.h
+++ b/src/timeline/TimelineItem.h
@@ -35,6 +35,8 @@
#include "Cache.h"
#include "MatrixClient.h"
+#include "ui/FlatButton.h"
+
class ImageItem;
class StickerItem;
class AudioItem;
@@ -222,6 +224,7 @@ public:
void setRoomId(QString room_id) { room_id_ = room_id; }
void sendReadReceipt() const;
void openRawMessageViewer() const;
+ void replyAction();
//! Add a user avatar for this event.
void addAvatar();
@@ -286,6 +289,7 @@ private:
QHBoxLayout *topLayout_ = nullptr;
QHBoxLayout *messageLayout_ = nullptr;
+ QHBoxLayout *actionLayout_ = nullptr;
QVBoxLayout *mainLayout_ = nullptr;
QHBoxLayout *widgetLayout_ = nullptr;
@@ -300,6 +304,10 @@ private:
TextLabel *body_;
QColor backgroundColor_;
+
+ FlatButton *replyBtn_;
+ FlatButton *contextBtn_;
+
};
template