Update mentions dialog
Mentions are now separated into 'this room' and 'all rooms' tab., which allows the user to filter on the current room if they desire. Should add additional logic in the future to show which room the mention was in the for the 'all rooms' view.
This commit is contained in:
parent
497774d623
commit
fd2d4d6db3
12 changed files with 271 additions and 105 deletions
|
|
@ -91,12 +91,11 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent)
|
|||
connect(sidebarActions_, &SideBarActions::createRoom, this, &ChatPage::createRoom);
|
||||
|
||||
user_info_widget_ = new UserInfoWidget(sideBar_);
|
||||
// user_mentions_widget_ = new UserMentionsWidget(sideBar_);
|
||||
// user_mentions_widget_ = new UserMentionsWidget(top_bar_);
|
||||
room_list_ = new RoomList(sideBar_);
|
||||
connect(room_list_, &RoomList::joinRoom, this, &ChatPage::joinRoom);
|
||||
|
||||
sideBarLayout_->addWidget(user_info_widget_);
|
||||
// sideBarLayout_->addWidget(user_mentions_widget_);
|
||||
sideBarLayout_->addWidget(room_list_);
|
||||
sideBarLayout_->addWidget(sidebarActions_);
|
||||
|
||||
|
|
@ -1000,7 +999,7 @@ ChatPage::showNotificationsDialog(const mtx::responses::Notifications &res, cons
|
|||
const auto user_id = utils::event_sender(item.event);
|
||||
const auto body = utils::event_body(item.event);
|
||||
|
||||
notifDialog->pushItem(event_id, user_id, body, room_id);
|
||||
notifDialog->pushItem(event_id, user_id, body, room_id, current_room_);
|
||||
|
||||
} catch (const lmdb::error &e) {
|
||||
nhlog::db()->warn("error while sending desktop notification: {}", e.what());
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
#include <QTabWidget>
|
||||
#include <QTimer>
|
||||
|
||||
#include "UserMentions.h"
|
||||
|
|
@ -8,31 +9,50 @@ using namespace dialogs;
|
|||
UserMentions::UserMentions(QWidget *parent)
|
||||
: QWidget{parent}
|
||||
{
|
||||
tab_layout_ = new QTabWidget(this);
|
||||
|
||||
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);
|
||||
local_scroll_area_ = new QScrollArea(this);
|
||||
local_scroll_area_->setWidgetResizable(true);
|
||||
local_scroll_area_->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
|
||||
scroll_widget_ = new QWidget(this);
|
||||
scroll_widget_->setObjectName("scroll_widget");
|
||||
local_scroll_widget_ = new QWidget(this);
|
||||
local_scroll_widget_->setObjectName("local_scroll_widget");
|
||||
|
||||
all_scroll_area_ = new QScrollArea(this);
|
||||
all_scroll_area_->setWidgetResizable(true);
|
||||
all_scroll_area_->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
|
||||
all_scroll_widget_ = new QWidget(this);
|
||||
all_scroll_widget_->setObjectName("all_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");
|
||||
local_scroll_layout_ = new QVBoxLayout(local_scroll_widget_);
|
||||
local_scroll_layout_->setContentsMargins(4, 0, 15, bottomMargin);
|
||||
local_scroll_layout_->setSpacing(0);
|
||||
local_scroll_layout_->setObjectName("localcrollarea");
|
||||
|
||||
scroll_area_->setWidget(scroll_widget_);
|
||||
scroll_area_->setAlignment(Qt::AlignBottom);
|
||||
all_scroll_layout_ = new QVBoxLayout(all_scroll_widget_);
|
||||
all_scroll_layout_->setContentsMargins(4, 0, 15, bottomMargin);
|
||||
all_scroll_layout_->setSpacing(0);
|
||||
all_scroll_layout_->setObjectName("allcrollarea");
|
||||
|
||||
top_layout_->addWidget(scroll_area_);
|
||||
local_scroll_area_->setWidget(local_scroll_widget_);
|
||||
local_scroll_area_->setAlignment(Qt::AlignBottom);
|
||||
|
||||
all_scroll_area_->setWidget(all_scroll_widget_);
|
||||
all_scroll_area_->setAlignment(Qt::AlignBottom);
|
||||
|
||||
tab_layout_->addTab(local_scroll_area_, tr("This Room"));
|
||||
tab_layout_->addTab(all_scroll_area_, tr("All Rooms"));
|
||||
top_layout_->addWidget(tab_layout_);
|
||||
|
||||
setLayout(top_layout_);
|
||||
}
|
||||
|
|
@ -41,18 +61,41 @@ void
|
|||
UserMentions::pushItem(const QString &event_id,
|
||||
const QString &user_id,
|
||||
const QString &body,
|
||||
const QString &room_id)
|
||||
const QString &room_id,
|
||||
const QString ¤t_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);
|
||||
|
||||
// Add to the 'all' section
|
||||
TimelineItem *view_item = new TimelineItem(
|
||||
mtx::events::MessageType::Text, user_id, body, true, room_id, all_scroll_widget_);
|
||||
view_item->setEventId(event_id);
|
||||
view_item->hide();
|
||||
|
||||
scroll_layout_->addWidget(view_item);
|
||||
all_scroll_layout_->addWidget(view_item);
|
||||
QTimer::singleShot(0, this, [view_item, this]() {
|
||||
view_item->show();
|
||||
view_item->adjustSize();
|
||||
setUpdatesEnabled(true);
|
||||
});
|
||||
|
||||
// if it matches the current room... add it to the current room as well.
|
||||
if (QString::compare(room_id, current_room_id, Qt::CaseInsensitive) == 0) {
|
||||
// Add to the 'local' section
|
||||
TimelineItem *local_view_item = new TimelineItem(mtx::events::MessageType::Text,
|
||||
user_id,
|
||||
body,
|
||||
true,
|
||||
room_id,
|
||||
local_scroll_widget_);
|
||||
local_view_item->setEventId(event_id);
|
||||
local_view_item->hide();
|
||||
|
||||
local_scroll_layout_->addWidget(local_view_item);
|
||||
|
||||
QTimer::singleShot(0, this, [local_view_item, this]() {
|
||||
local_view_item->show();
|
||||
local_view_item->adjustSize();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <QScrollArea>
|
||||
#include <QScrollBar>
|
||||
#include <QTabWidget>
|
||||
#include <QVBoxLayout>
|
||||
#include <QWidget>
|
||||
|
||||
|
|
@ -15,14 +16,20 @@ public:
|
|||
void pushItem(const QString &event_id,
|
||||
const QString &user_id,
|
||||
const QString &body,
|
||||
const QString &room_id);
|
||||
const QString &room_id,
|
||||
const QString ¤t_room_id);
|
||||
|
||||
private:
|
||||
QTabWidget *tab_layout_;
|
||||
QVBoxLayout *top_layout_;
|
||||
QVBoxLayout *scroll_layout_;
|
||||
QVBoxLayout *local_scroll_layout_;
|
||||
QVBoxLayout *all_scroll_layout_;
|
||||
|
||||
QScrollArea *scroll_area_;
|
||||
QWidget *scroll_widget_;
|
||||
QScrollArea *local_scroll_area_;
|
||||
QWidget *local_scroll_widget_;
|
||||
|
||||
QScrollArea *all_scroll_area_;
|
||||
QWidget *all_scroll_widget_;
|
||||
};
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue