summary refs log tree commit diff
path: root/src/dialogs
diff options
context:
space:
mode:
authorJoseph Donofry <joedonofry@gmail.com>2019-07-16 22:36:55 -0400
committerJoseph Donofry <joedonofry@gmail.com>2019-07-16 22:39:10 -0400
commit579bf234606a8974a457f244195d2b4f3594d294 (patch)
treef5289bf6d91731a0d4711ff5438c3e57d9f42d6d /src/dialogs
parentUpdate Travis webhook URL for new nheko room (diff)
downloadnheko-579bf234606a8974a457f244195d2b4f3594d294.tar.xz
Add User Mentions Dialog
Add a RoomListItem-like button that opens a dialog
containing all of the messages that would result in a
highlight from the server (for example, the user is mentioned,
or @room is mentioned).

This is VERY rudimentary and will be completely reworked in the future
to take advantage of the existing TimelineView class, instead of
using a dialog like it does now. The button to show the mentions
also needs work.
Diffstat (limited to 'src/dialogs')
-rw-r--r--src/dialogs/UserMentions.cpp59
-rw-r--r--src/dialogs/UserMentions.h26
2 files changed, 85 insertions, 0 deletions
diff --git a/src/dialogs/UserMentions.cpp b/src/dialogs/UserMentions.cpp
new file mode 100644

index 00000000..1a6c17e5 --- /dev/null +++ b/src/dialogs/UserMentions.cpp
@@ -0,0 +1,59 @@ +#include <QTimer> + +#include "UserMentions.h" +#include "timeline/TimelineItem.h" + +using namespace dialogs; + +UserMentions::UserMentions(QWidget *parent) + : QWidget{parent} +{ + top_layout_ = new QVBoxLayout(this); + top_layout_->setSpacing(0); + top_layout_->setMargin(0); + + scroll_area_ = new QScrollArea(this); + scroll_area_->setWidgetResizable(true); + scroll_area_->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + + scroll_widget_ = new QWidget(this); + scroll_widget_->setObjectName("scroll_widget"); + + // Height of the typing display. + QFont f; + f.setPointSizeF(f.pointSizeF() * 0.9); + const int bottomMargin = QFontMetrics(f).height() + 6; + + scroll_layout_ = new QVBoxLayout(scroll_widget_); + scroll_layout_->setContentsMargins(4, 0, 15, bottomMargin); + scroll_layout_->setSpacing(0); + scroll_layout_->setObjectName("timelinescrollarea"); + + scroll_area_->setWidget(scroll_widget_); + scroll_area_->setAlignment(Qt::AlignBottom); + + top_layout_->addWidget(scroll_area_); + + setLayout(top_layout_); +} + +void +UserMentions::pushItem(const QString &event_id, const QString &user_id, const QString &body, const QString &room_id) { + TimelineItem *view_item = + new TimelineItem(mtx::events::MessageType::Text, + user_id, + body, + true, + room_id, + scroll_widget_); + view_item->setEventId(event_id); + setUpdatesEnabled(false); + view_item->hide(); + + scroll_layout_->addWidget(view_item); + QTimer::singleShot(0, this, [view_item, this]() { + view_item->show(); + view_item->adjustSize(); + setUpdatesEnabled(true); + }); +} \ No newline at end of file diff --git a/src/dialogs/UserMentions.h b/src/dialogs/UserMentions.h new file mode 100644
index 00000000..ff68d8c8 --- /dev/null +++ b/src/dialogs/UserMentions.h
@@ -0,0 +1,26 @@ +#pragma once + +#include <QWidget> +#include <QVBoxLayout> +#include <QScrollArea> +#include <QScrollBar> + +namespace dialogs { + +class UserMentions : public QWidget +{ + Q_OBJECT +public: + UserMentions(QWidget *parent = nullptr); + void pushItem(const QString &event_id, const QString &user_id, const QString &body, const QString &room_id); +private: + QVBoxLayout *top_layout_; + QVBoxLayout *scroll_layout_; + + QScrollArea *scroll_area_; + QWidget *scroll_widget_; + + +}; + +} \ No newline at end of file