Add reply and menu buttons to TimelineItem
This commit is contained in:
parent
4cb27f34f2
commit
7c630b1363
BIN
resources/icons/ui/mail-reply.png
Normal file
BIN
resources/icons/ui/mail-reply.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 373 B |
@ -63,6 +63,8 @@
|
|||||||
<file>icons/ui/edit.png</file>
|
<file>icons/ui/edit.png</file>
|
||||||
<file>icons/ui/edit@2x.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.png</file>
|
||||||
<file>icons/emoji-categories/people@2x.png</file>
|
<file>icons/emoji-categories/people@2x.png</file>
|
||||||
<file>icons/emoji-categories/nature.png</file>
|
<file>icons/emoji-categories/nature.png</file>
|
||||||
|
@ -126,11 +126,17 @@ void
|
|||||||
TimelineItem::adjustMessageLayoutForWidget()
|
TimelineItem::adjustMessageLayoutForWidget()
|
||||||
{
|
{
|
||||||
messageLayout_->addLayout(widgetLayout_, 1);
|
messageLayout_->addLayout(widgetLayout_, 1);
|
||||||
|
actionLayout_->addWidget(replyBtn_);
|
||||||
|
actionLayout_->addWidget(contextBtn_);
|
||||||
|
messageLayout_->addLayout(actionLayout_);
|
||||||
messageLayout_->addWidget(statusIndicator_);
|
messageLayout_->addWidget(statusIndicator_);
|
||||||
messageLayout_->addWidget(timestamp_);
|
messageLayout_->addWidget(timestamp_);
|
||||||
|
|
||||||
|
actionLayout_->setAlignment(replyBtn_, Qt::AlignTop | Qt::AlignRight);
|
||||||
|
actionLayout_->setAlignment(contextBtn_, Qt::AlignTop | Qt::AlignRight);
|
||||||
messageLayout_->setAlignment(statusIndicator_, Qt::AlignTop);
|
messageLayout_->setAlignment(statusIndicator_, Qt::AlignTop);
|
||||||
messageLayout_->setAlignment(timestamp_, Qt::AlignTop);
|
messageLayout_->setAlignment(timestamp_, Qt::AlignTop);
|
||||||
|
messageLayout_->setAlignment(actionLayout_, Qt::AlignTop);
|
||||||
|
|
||||||
mainLayout_->addLayout(messageLayout_);
|
mainLayout_->addLayout(messageLayout_);
|
||||||
}
|
}
|
||||||
@ -139,11 +145,17 @@ void
|
|||||||
TimelineItem::adjustMessageLayout()
|
TimelineItem::adjustMessageLayout()
|
||||||
{
|
{
|
||||||
messageLayout_->addWidget(body_, 1);
|
messageLayout_->addWidget(body_, 1);
|
||||||
|
actionLayout_->addWidget(replyBtn_);
|
||||||
|
actionLayout_->addWidget(contextBtn_);
|
||||||
|
messageLayout_->addLayout(actionLayout_);
|
||||||
messageLayout_->addWidget(statusIndicator_);
|
messageLayout_->addWidget(statusIndicator_);
|
||||||
messageLayout_->addWidget(timestamp_);
|
messageLayout_->addWidget(timestamp_);
|
||||||
|
|
||||||
|
actionLayout_->setAlignment(replyBtn_, Qt::AlignTop | Qt::AlignRight);
|
||||||
|
actionLayout_->setAlignment(contextBtn_, Qt::AlignTop | Qt::AlignRight);
|
||||||
messageLayout_->setAlignment(statusIndicator_, Qt::AlignTop);
|
messageLayout_->setAlignment(statusIndicator_, Qt::AlignTop);
|
||||||
messageLayout_->setAlignment(timestamp_, Qt::AlignTop);
|
messageLayout_->setAlignment(timestamp_, Qt::AlignTop);
|
||||||
|
messageLayout_->setAlignment(actionLayout_, Qt::AlignTop);
|
||||||
|
|
||||||
mainLayout_->addLayout(messageLayout_);
|
mainLayout_->addLayout(messageLayout_);
|
||||||
}
|
}
|
||||||
@ -155,6 +167,7 @@ TimelineItem::init()
|
|||||||
timestamp_ = nullptr;
|
timestamp_ = nullptr;
|
||||||
userName_ = nullptr;
|
userName_ = nullptr;
|
||||||
body_ = nullptr;
|
body_ = nullptr;
|
||||||
|
auto buttonSize_ = 32;
|
||||||
|
|
||||||
contextMenu_ = new QMenu(this);
|
contextMenu_ = new QMenu(this);
|
||||||
showReadReceipts_ = new QAction("Read receipts", this);
|
showReadReceipts_ = new QAction("Read receipts", this);
|
||||||
@ -166,6 +179,7 @@ TimelineItem::init()
|
|||||||
contextMenu_->addAction(markAsRead_);
|
contextMenu_->addAction(markAsRead_);
|
||||||
contextMenu_->addAction(redactMsg_);
|
contextMenu_->addAction(redactMsg_);
|
||||||
|
|
||||||
|
|
||||||
connect(showReadReceipts_, &QAction::triggered, this, [this]() {
|
connect(showReadReceipts_, &QAction::triggered, this, [this]() {
|
||||||
if (!event_id_.isEmpty())
|
if (!event_id_.isEmpty())
|
||||||
MainWindow::instance()->openReadReceiptsDialog(event_id_);
|
MainWindow::instance()->openReadReceiptsDialog(event_id_);
|
||||||
@ -207,9 +221,13 @@ TimelineItem::init()
|
|||||||
topLayout_ = new QHBoxLayout(this);
|
topLayout_ = new QHBoxLayout(this);
|
||||||
mainLayout_ = new QVBoxLayout;
|
mainLayout_ = new QVBoxLayout;
|
||||||
messageLayout_ = new QHBoxLayout;
|
messageLayout_ = new QHBoxLayout;
|
||||||
|
actionLayout_ = new QHBoxLayout;
|
||||||
messageLayout_->setContentsMargins(0, 0, MSG_RIGHT_MARGIN, 0);
|
messageLayout_->setContentsMargins(0, 0, MSG_RIGHT_MARGIN, 0);
|
||||||
messageLayout_->setSpacing(MSG_PADDING);
|
messageLayout_->setSpacing(MSG_PADDING);
|
||||||
|
|
||||||
|
actionLayout_->setContentsMargins(13, 1, 13, 0);
|
||||||
|
actionLayout_->setSpacing(0);
|
||||||
|
|
||||||
topLayout_->setContentsMargins(
|
topLayout_->setContentsMargins(
|
||||||
conf::timeline::msgLeftMargin, conf::timeline::msgTopMargin, 0, 0);
|
conf::timeline::msgLeftMargin, conf::timeline::msgTopMargin, 0, 0);
|
||||||
topLayout_->setSpacing(0);
|
topLayout_->setSpacing(0);
|
||||||
@ -218,6 +236,28 @@ TimelineItem::init()
|
|||||||
mainLayout_->setContentsMargins(conf::timeline::headerLeftMargin, 0, 0, 0);
|
mainLayout_->setContentsMargins(conf::timeline::headerLeftMargin, 0, 0, 0);
|
||||||
mainLayout_->setSpacing(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_.setPointSizeF(timestampFont_.pointSizeF() * 0.9);
|
||||||
timestampFont_.setFamily("Monospace");
|
timestampFont_.setFamily("Monospace");
|
||||||
timestampFont_.setStyleHint(QFont::Monospace);
|
timestampFont_.setStyleHint(QFont::Monospace);
|
||||||
@ -825,15 +865,18 @@ TimelineItem::addReplyAction()
|
|||||||
auto replyAction = new QAction("Reply", this);
|
auto replyAction = new QAction("Reply", this);
|
||||||
contextMenu_->addAction(replyAction);
|
contextMenu_->addAction(replyAction);
|
||||||
|
|
||||||
connect(replyAction, &QAction::triggered, this, [this]() {
|
connect(replyAction, &QAction::triggered, this, &TimelineItem::replyAction);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
TimelineItem::replyAction() {
|
||||||
if (!body_)
|
if (!body_)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
emit ChatPage::instance()->messageReply(
|
emit ChatPage::instance()->messageReply(
|
||||||
Cache::displayName(room_id_, descriptionMsg_.userid),
|
Cache::displayName(room_id_, descriptionMsg_.userid),
|
||||||
body_->toPlainText());
|
body_->toPlainText());
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -35,6 +35,8 @@
|
|||||||
#include "Cache.h"
|
#include "Cache.h"
|
||||||
#include "MatrixClient.h"
|
#include "MatrixClient.h"
|
||||||
|
|
||||||
|
#include "ui/FlatButton.h"
|
||||||
|
|
||||||
class ImageItem;
|
class ImageItem;
|
||||||
class StickerItem;
|
class StickerItem;
|
||||||
class AudioItem;
|
class AudioItem;
|
||||||
@ -222,6 +224,7 @@ public:
|
|||||||
void setRoomId(QString room_id) { room_id_ = room_id; }
|
void setRoomId(QString room_id) { room_id_ = room_id; }
|
||||||
void sendReadReceipt() const;
|
void sendReadReceipt() const;
|
||||||
void openRawMessageViewer() const;
|
void openRawMessageViewer() const;
|
||||||
|
void replyAction();
|
||||||
|
|
||||||
//! Add a user avatar for this event.
|
//! Add a user avatar for this event.
|
||||||
void addAvatar();
|
void addAvatar();
|
||||||
@ -286,6 +289,7 @@ private:
|
|||||||
|
|
||||||
QHBoxLayout *topLayout_ = nullptr;
|
QHBoxLayout *topLayout_ = nullptr;
|
||||||
QHBoxLayout *messageLayout_ = nullptr;
|
QHBoxLayout *messageLayout_ = nullptr;
|
||||||
|
QHBoxLayout *actionLayout_ = nullptr;
|
||||||
QVBoxLayout *mainLayout_ = nullptr;
|
QVBoxLayout *mainLayout_ = nullptr;
|
||||||
QHBoxLayout *widgetLayout_ = nullptr;
|
QHBoxLayout *widgetLayout_ = nullptr;
|
||||||
|
|
||||||
@ -300,6 +304,10 @@ private:
|
|||||||
TextLabel *body_;
|
TextLabel *body_;
|
||||||
|
|
||||||
QColor backgroundColor_;
|
QColor backgroundColor_;
|
||||||
|
|
||||||
|
FlatButton *replyBtn_;
|
||||||
|
FlatButton *contextBtn_;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class Widget>
|
template<class Widget>
|
||||||
|
Loading…
Reference in New Issue
Block a user