Add reply and menu buttons to TimelineItem

remotes/origin/0.7.0-dev
redsky17 6 years ago
parent 4cb27f34f2
commit 7c630b1363
No known key found for this signature in database
GPG Key ID: E8A1D78EF044B0CB
  1. BIN
      resources/icons/ui/mail-reply.png
  2. 2
      resources/res.qrc
  3. 49
      src/timeline/TimelineItem.cpp
  4. 8
      src/timeline/TimelineItem.h

Binary file not shown.

After

Width:  |  Height:  |  Size: 373 B

@ -63,6 +63,8 @@
<file>icons/ui/edit.png</file>
<file>icons/ui/edit@2x.png</file>
<file>icons/ui/mail-reply.png</file>
<file>icons/emoji-categories/people.png</file>
<file>icons/emoji-categories/people@2x.png</file>
<file>icons/emoji-categories/nature.png</file>

@ -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

@ -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<class Widget>

Loading…
Cancel
Save