From 3f563e1e6e5e73b0eb50f53cc4568064a0f2f780 Mon Sep 17 00:00:00 2001 From: Joseph Donofry Date: Fri, 9 Aug 2019 23:34:44 -0400 Subject: Cache User Mentions Cache user mentions when they are retrieved from the server. This logic currently isn't being utilized by the UI. Additionally, the app should use a 'since' value to only get mentions newer than those stored in the DB, to avoid excessive web requests. This will be implemented in a future commit. --- src/popups/UserMentions.cpp | 108 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 src/popups/UserMentions.cpp (limited to 'src/popups/UserMentions.cpp') diff --git a/src/popups/UserMentions.cpp b/src/popups/UserMentions.cpp new file mode 100644 index 00000000..77e5260e --- /dev/null +++ b/src/popups/UserMentions.cpp @@ -0,0 +1,108 @@ +#include +#include + +#include "UserMentions.h" +#include "timeline/TimelineItem.h" + +using namespace popups; + +UserMentions::UserMentions(QWidget *parent) + : QWidget{parent} +{ + tab_layout_ = new QTabWidget(this); + + top_layout_ = new QVBoxLayout(this); + top_layout_->setSpacing(0); + top_layout_->setMargin(0); + + local_scroll_area_ = new QScrollArea(this); + local_scroll_area_->setWidgetResizable(true); + local_scroll_area_->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + + 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; + + 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"); + + 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"); + + 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_); +} + +void +UserMentions::initializeMentions(const std::map ¬ifs) +{ + Q_UNUSED(notifs); + // Very TODO: +} + +void +UserMentions::pushItem(const QString &event_id, + const QString &user_id, + const QString &body, + const QString &room_id, + const QString ¤t_room_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(); + + 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]() { + local_view_item->show(); + local_view_item->adjustSize(); + }); + } +} \ No newline at end of file -- cgit 1.5.1 From 52a262177660da2d541236d597fe34212d078094 Mon Sep 17 00:00:00 2001 From: Joseph Donofry Date: Mon, 12 Aug 2019 22:09:40 -0400 Subject: Fix issues with caching and loading of mentions. Mentions are now loaded from the cache instead of directly from the web request. Mentions are also properly saved to the cache now (instead of as empty strings). Still lots of tweaks left on this feature. --- src/Cache.cpp | 31 +++++++++++++---------- src/Cache.h | 2 +- src/ChatPage.cpp | 62 ++++++++++++++++++++++++++------------------- src/ChatPage.h | 2 +- src/popups/UserMentions.cpp | 51 +++++++++++++++++++++++++++++++++---- src/popups/UserMentions.h | 10 +++++--- 6 files changed, 108 insertions(+), 50 deletions(-) (limited to 'src/popups/UserMentions.cpp') diff --git a/src/Cache.cpp b/src/Cache.cpp index 799dd319..d264b541 100644 --- a/src/Cache.cpp +++ b/src/Cache.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -1232,20 +1233,20 @@ Cache::roomMessages() return msgs; } -std::map +QMap Cache::getTimelineMentions() { // TODO: Should be read-only, but getMentionsDb will attempt to create a DB // if it doesn't exist, throwing an error. auto txn = lmdb::txn::begin(env_, nullptr); - std::map notifs; + QMap notifs; auto room_ids = getRoomIds(txn); for (const auto &room_id : room_ids) { - auto roomNotifs = getTimelineMentionsForRoom(txn, room_id); - notifs.emplace(QString::fromStdString(room_id), roomNotifs); + auto roomNotifs = getTimelineMentionsForRoom(txn, room_id); + notifs[QString::fromStdString(room_id)] = roomNotifs; } txn.commit(); @@ -1973,11 +1974,11 @@ Cache::getTimelineMentionsForRoom(lmdb::txn &txn, const std::string &room_id) while (cursor.get(event_id, msg, MDB_NEXT)) { auto obj = json::parse(msg); - if (obj.count("event") == 0 || obj.count("token") == 0) + if (obj.count("event") == 0) continue; mtx::responses::Notification notification; - mtx::responses::from_json(obj.at("notification"), notification); + mtx::responses::from_json(obj, notification); notif.notifications.push_back(notification); } @@ -1992,18 +1993,25 @@ Cache::getTimelineMentionsForRoom(lmdb::txn &txn, const std::string &room_id) void Cache::saveTimelineMentions(const mtx::responses::Notifications &res) { + json notif = res; + QMap> notifsByRoom; // Sort into room-specific 'buckets' for (const auto ¬if : res.notifications) { + json val = notif; notifsByRoom[notif.room_id].push_back(notif); } auto txn = lmdb::txn::begin(env_); // Insert the entire set of mentions for each room at a time. - for (const auto &room : notifsByRoom.keys()) { - nhlog::db()->debug("Storing notifications for " + room); - saveTimelineMentions(txn, room, notifsByRoom[room]); + QMap>::const_iterator it = + notifsByRoom.constBegin(); + auto end = notifsByRoom.constEnd(); + while (it != end) { + nhlog::db()->debug("Storing notifications for " + it.key()); + saveTimelineMentions(txn, it.key(), std::move(it.value())); + ++it; } txn.commit(); @@ -2019,10 +2027,7 @@ Cache::saveTimelineMentions(lmdb::txn &txn, using namespace mtx::events; using namespace mtx::events::state; - int i = 0; for (const auto ¬if : res) { - nhlog::db()->debug("Storing notification " + std::to_string(i++) + " for room " + - room_id); const auto event_id = utils::event_id(notif.event); // double check that we have the correct room_id... @@ -2030,7 +2035,7 @@ Cache::saveTimelineMentions(lmdb::txn &txn, return; } - json obj = json::object(); + json obj = notif; lmdb::dbi_put(txn, db, lmdb::val(event_id), lmdb::val(obj.dump())); } diff --git a/src/Cache.h b/src/Cache.h index 97b264fc..5ec79c3b 100644 --- a/src/Cache.h +++ b/src/Cache.h @@ -323,7 +323,7 @@ public: std::map roomMessages(); - std::map getTimelineMentions(); + QMap getTimelineMentions(); //! Retrieve all the user ids from a room. std::vector roomMembers(const std::string &room_id); diff --git a/src/ChatPage.cpp b/src/ChatPage.cpp index 54562c82..58f23fef 100644 --- a/src/ChatPage.cpp +++ b/src/ChatPage.cpp @@ -153,21 +153,26 @@ ChatPage::ChatPage(QSharedPointer userSettings, QWidget *parent) }); connect(top_bar_, &TopRoomBar::mentionsClicked, this, [this](const QPoint &mentionsPos) { - http::client()->notifications( - 1000, - "", - "highlight", - [this, mentionsPos](const mtx::responses::Notifications &res, - mtx::http::RequestErr err) { - if (err) { - nhlog::net()->warn("failed to retrieve notifications: {} ({})", - err->matrix_error.error, - static_cast(err->status_code)); - return; - } + if (user_mentions_popup_->isVisible()) { + user_mentions_popup_->hide(); + } else { + http::client()->notifications( + 1000, + "", + "highlight", + [this, mentionsPos](const mtx::responses::Notifications &res, + mtx::http::RequestErr err) { + if (err) { + nhlog::net()->warn( + "failed to retrieve notifications: {} ({})", + err->matrix_error.error, + static_cast(err->status_code)); + return; + } - emit highlightedNotifsRetrieved(std::move(res), mentionsPos); - }); + emit highlightedNotifsRetrieved(std::move(res), mentionsPos); + }); + } }); connectivityTimer_.setInterval(CHECK_CONNECTIVITY_INTERVAL); @@ -1001,28 +1006,32 @@ ChatPage::sendDesktopNotifications(const mtx::responses::Notifications &res) void ChatPage::showNotificationsDialog(const mtx::responses::Notifications &res, const QPoint &widgetPos) { + // TODO: Remove notifications from this function call. + Q_UNUSED(res); + auto notifDialog = user_mentions_popup_; - for (const auto &item : res.notifications) { - const auto event_id = QString::fromStdString(utils::event_id(item.event)); + // for (const auto &item : res.notifications) { + // const auto event_id = QString::fromStdString(utils::event_id(item.event)); - try { - const auto room_id = QString::fromStdString(item.room_id); - const auto user_id = utils::event_sender(item.event); - const auto body = utils::event_body(item.event); + // try { + // const auto room_id = QString::fromStdString(item.room_id); + // 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, current_room_); + // 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()); - } - } + // } catch (const lmdb::error &e) { + // nhlog::db()->warn("error while sending desktop notification: {}", + // e.what()); + // } + // } notifDialog->setGeometry( widgetPos.x() - (width() / 10), widgetPos.y() + 25, width() / 5, height() / 2); // notifDialog->move(widgetPos.x(), widgetPos.y()); // notifDialog->setFixedWidth(width() / 10); // notifDialog->setFixedHeight(height() / 2); notifDialog->raise(); - notifDialog->show(); + notifDialog->showPopup(); } void @@ -1292,6 +1301,7 @@ ChatPage::initialSyncHandler(const mtx::responses::Sync &res, mtx::http::Request emit initializeViews(std::move(res.rooms)); emit initializeRoomList(cache::client()->roomInfo()); + emit initializeMentions(cache::client()->getTimelineMentions()); cache::client()->calculateRoomReadStatus(); emit syncTags(cache::client()->roomInfo().toStdMap()); diff --git a/src/ChatPage.h b/src/ChatPage.h index 87876a09..fb6fbb06 100644 --- a/src/ChatPage.h +++ b/src/ChatPage.h @@ -140,7 +140,7 @@ signals: void initializeRoomList(QMap); void initializeViews(const mtx::responses::Rooms &rooms); void initializeEmptyViews(const std::map &msgs); - void initializeMentions(const std::map ¬ifs); + void initializeMentions(const QMap ¬ifs); void syncUI(const mtx::responses::Rooms &rooms); void syncRoomlist(const std::map &updates); void syncTags(const std::map &updates); diff --git a/src/popups/UserMentions.cpp b/src/popups/UserMentions.cpp index 77e5260e..267540cc 100644 --- a/src/popups/UserMentions.cpp +++ b/src/popups/UserMentions.cpp @@ -1,6 +1,8 @@ #include #include +#include "Cache.h" +#include "ChatPage.h" #include "UserMentions.h" #include "timeline/TimelineItem.h" @@ -9,6 +11,9 @@ using namespace popups; UserMentions::UserMentions(QWidget *parent) : QWidget{parent} { + setAttribute(Qt::WA_ShowWithoutActivating, true); + setWindowFlags(Qt::ToolTip | Qt::NoDropShadowWindowHint); + tab_layout_ = new QTabWidget(this); top_layout_ = new QVBoxLayout(this); @@ -37,12 +42,12 @@ UserMentions::UserMentions(QWidget *parent) 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"); + local_scroll_layout_->setObjectName("localscrollarea"); 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"); + all_scroll_layout_->setObjectName("allscrollarea"); local_scroll_area_->setWidget(local_scroll_widget_); local_scroll_area_->setAlignment(Qt::AlignBottom); @@ -58,10 +63,46 @@ UserMentions::UserMentions(QWidget *parent) } void -UserMentions::initializeMentions(const std::map ¬ifs) +UserMentions::initializeMentions(const QMap ¬ifs) +{ + nhlog::ui()->debug("Initializing " + std::to_string(notifs.size()) + " notifications."); + for (auto widget : all_scroll_layout_->findChildren()) { + delete widget; + } + for (auto widget : local_scroll_layout_->findChildren()) { + delete widget; + } + for (const auto &item : notifs) { + for (const auto notif : item.notifications) { + const auto event_id = QString::fromStdString(utils::event_id(notif.event)); + + try { + const auto room_id = QString::fromStdString(notif.room_id); + const auto user_id = utils::event_sender(notif.event); + const auto body = utils::event_body(notif.event); + + pushItem(event_id, + user_id, + body, + room_id, + ChatPage::instance()->currentRoom()); + + } catch (const lmdb::error &e) { + nhlog::db()->warn("error while sending desktop notification: {}", + e.what()); + } + } + } +} + +void +UserMentions::showPopup() { - Q_UNUSED(notifs); - // Very TODO: + auto notifs = cache::client()->getTimelineMentions(); + + initializeMentions(notifs); + + show(); } void diff --git a/src/popups/UserMentions.h b/src/popups/UserMentions.h index 5dc475bf..0029eedd 100644 --- a/src/popups/UserMentions.h +++ b/src/popups/UserMentions.h @@ -2,6 +2,7 @@ #include +#include #include #include #include @@ -16,15 +17,16 @@ class UserMentions : public QWidget Q_OBJECT public: UserMentions(QWidget *parent = nullptr); + + void showPopup(); + void initializeMentions(const QMap ¬ifs); + +private: void pushItem(const QString &event_id, const QString &user_id, const QString &body, const QString &room_id, const QString ¤t_room_id); - - void initializeMentions(const std::map ¬ifs); - -private: QTabWidget *tab_layout_; QVBoxLayout *top_layout_; QVBoxLayout *local_scroll_layout_; -- cgit 1.5.1 From bcdd97c85fb3b2aeb0cd46c05562f880792737aa Mon Sep 17 00:00:00 2001 From: Joseph Donofry Date: Mon, 19 Aug 2019 18:11:38 -0400 Subject: More updates to mentions functionality --- src/ChatPage.cpp | 27 ++++----------------------- src/ChatPage.h | 2 +- src/popups/UserMentions.cpp | 18 ++++++++++-------- src/popups/UserMentions.h | 7 ++++++- 4 files changed, 21 insertions(+), 33 deletions(-) (limited to 'src/popups/UserMentions.cpp') diff --git a/src/ChatPage.cpp b/src/ChatPage.cpp index 58f23fef..854d57d7 100644 --- a/src/ChatPage.cpp +++ b/src/ChatPage.cpp @@ -156,6 +156,7 @@ ChatPage::ChatPage(QSharedPointer userSettings, QWidget *parent) if (user_mentions_popup_->isVisible()) { user_mentions_popup_->hide(); } else { + showNotificationsDialog(mentionsPos); http::client()->notifications( 1000, "", @@ -525,13 +526,12 @@ ChatPage::ChatPage(QSharedPointer userSettings, QWidget *parent) connect(this, &ChatPage::highlightedNotifsRetrieved, this, - [this](const mtx::responses::Notifications ¬if, const QPoint &widgetPos) { + [this](const mtx::responses::Notifications ¬if) { try { cache::client()->saveTimelineMentions(notif); } catch (const lmdb::error &e) { nhlog::db()->error("failed to save mentions: {}", e.what()); } - showNotificationsDialog(notif, widgetPos); }); connect(communitiesList_, @@ -1004,32 +1004,13 @@ ChatPage::sendDesktopNotifications(const mtx::responses::Notifications &res) } void -ChatPage::showNotificationsDialog(const mtx::responses::Notifications &res, const QPoint &widgetPos) +ChatPage::showNotificationsDialog(const QPoint &widgetPos) { - // TODO: Remove notifications from this function call. - Q_UNUSED(res); - auto notifDialog = user_mentions_popup_; - // for (const auto &item : res.notifications) { - // const auto event_id = QString::fromStdString(utils::event_id(item.event)); - - // try { - // const auto room_id = QString::fromStdString(item.room_id); - // 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, current_room_); - - // } catch (const lmdb::error &e) { - // nhlog::db()->warn("error while sending desktop notification: {}", - // e.what()); - // } - // } notifDialog->setGeometry( widgetPos.x() - (width() / 10), widgetPos.y() + 25, width() / 5, height() / 2); - // notifDialog->move(widgetPos.x(), widgetPos.y()); - // notifDialog->setFixedWidth(width() / 10); - // notifDialog->setFixedHeight(height() / 2); + notifDialog->raise(); notifDialog->showPopup(); } diff --git a/src/ChatPage.h b/src/ChatPage.h index fb6fbb06..189af387 100644 --- a/src/ChatPage.h +++ b/src/ChatPage.h @@ -210,7 +210,7 @@ private: //! Send desktop notification for the received messages. void sendDesktopNotifications(const mtx::responses::Notifications &); - void showNotificationsDialog(const mtx::responses::Notifications &, const QPoint &point); + void showNotificationsDialog(const QPoint &point); QStringList generateTypingUsers(const QString &room_id, const std::vector &typing_users); diff --git a/src/popups/UserMentions.cpp b/src/popups/UserMentions.cpp index 267540cc..152cd82d 100644 --- a/src/popups/UserMentions.cpp +++ b/src/popups/UserMentions.cpp @@ -3,6 +3,7 @@ #include "Cache.h" #include "ChatPage.h" +#include "Logging.h" #include "UserMentions.h" #include "timeline/TimelineItem.h" @@ -12,7 +13,7 @@ UserMentions::UserMentions(QWidget *parent) : QWidget{parent} { setAttribute(Qt::WA_ShowWithoutActivating, true); - setWindowFlags(Qt::ToolTip | Qt::NoDropShadowWindowHint); + setWindowFlags(Qt::FramelessWindowHint | Qt::Popup); tab_layout_ = new QTabWidget(this); @@ -66,12 +67,7 @@ void UserMentions::initializeMentions(const QMap ¬ifs) { nhlog::ui()->debug("Initializing " + std::to_string(notifs.size()) + " notifications."); - for (auto widget : all_scroll_layout_->findChildren()) { - delete widget; - } - for (auto widget : local_scroll_layout_->findChildren()) { - delete widget; - } + for (const auto &item : notifs) { for (const auto notif : item.notifications) { const auto event_id = QString::fromStdString(utils::event_id(notif.event)); @@ -98,10 +94,16 @@ UserMentions::initializeMentions(const QMapfindChildren()) { + delete widget; + } + for (auto widget : local_scroll_layout_->findChildren()) { + delete widget; + } + auto notifs = cache::client()->getTimelineMentions(); initializeMentions(notifs); - show(); } diff --git a/src/popups/UserMentions.h b/src/popups/UserMentions.h index 0029eedd..a74bf2ec 100644 --- a/src/popups/UserMentions.h +++ b/src/popups/UserMentions.h @@ -2,6 +2,8 @@ #include +#include +#include #include #include #include @@ -9,6 +11,9 @@ #include #include #include +#include + +#include "Logging.h" namespace popups { @@ -18,8 +23,8 @@ class UserMentions : public QWidget public: UserMentions(QWidget *parent = nullptr); - void showPopup(); void initializeMentions(const QMap ¬ifs); + void showPopup(); private: void pushItem(const QString &event_id, -- cgit 1.5.1 From 98d4f14bd1ccf4c280be6a5fb965c75217c74b7e Mon Sep 17 00:00:00 2001 From: Joseph Donofry Date: Thu, 29 Aug 2019 18:01:20 -0400 Subject: Fix themeing issues on mentions --- resources/styles/nheko-dark.qss | 11 +++++++++++ resources/styles/nheko.qss | 11 +++++++++++ resources/styles/system.qss | 10 ++++++++++ src/popups/UserMentions.cpp | 12 +++++++++++- src/popups/UserMentions.h | 4 ++++ 5 files changed, 47 insertions(+), 1 deletion(-) (limited to 'src/popups/UserMentions.cpp') diff --git a/resources/styles/nheko-dark.qss b/resources/styles/nheko-dark.qss index 1e1333b2..1271e39f 100644 --- a/resources/styles/nheko-dark.qss +++ b/resources/styles/nheko-dark.qss @@ -24,6 +24,17 @@ TimelineView > * { border: none; } +UserMentionsWidget, +UserMentionsWidget > * { + background-color: #202228; + border: none; +} + +UserMentionsWidget > TimelineItem { + qproperty-backgroundColor: #202228; + qproperty-hoverColor: rgba(45, 49, 57, 120); +} + #scroll_widget { background-color: #202228; } diff --git a/resources/styles/nheko.qss b/resources/styles/nheko.qss index a70441be..3c7f3b71 100644 --- a/resources/styles/nheko.qss +++ b/resources/styles/nheko.qss @@ -24,6 +24,17 @@ TimelineView > * { border: none; } +UserMentionsWidget, +UserMentionsWidget > * { + background-color: white; + border: none; +} + +UserMentionsWidget > TimelineItem { + qproperty-backgroundColor: white; + qproperty-hoverColor: rgba(192, 193, 195, 120); +} + #scroll_widget { background-color: white; } diff --git a/resources/styles/system.qss b/resources/styles/system.qss index dfb8ce65..0a8c4b21 100644 --- a/resources/styles/system.qss +++ b/resources/styles/system.qss @@ -12,6 +12,16 @@ TimelineView > * { border: none; } +UserMentionsWidget, +UserMentionsWidget > * { + border: none; +} + +UserMentionsWidget > TimelineItem { + qproperty-backgroundColor: palette(window); + qproperty-hoverColor: palette(base); +} + TextInputWidget { border: none; border-top: 1px solid palette(mid); diff --git a/src/popups/UserMentions.cpp b/src/popups/UserMentions.cpp index 152cd82d..3480959a 100644 --- a/src/popups/UserMentions.cpp +++ b/src/popups/UserMentions.cpp @@ -1,3 +1,5 @@ +#include +#include #include #include @@ -140,7 +142,6 @@ UserMentions::pushItem(const QString &event_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]() { @@ -148,4 +149,13 @@ UserMentions::pushItem(const QString &event_id, local_view_item->adjustSize(); }); } +} + +void +UserMentions::paintEvent(QPaintEvent *) +{ + QStyleOption opt; + opt.init(this); + QPainter p(this); + style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); } \ No newline at end of file diff --git a/src/popups/UserMentions.h b/src/popups/UserMentions.h index a74bf2ec..d7dfc575 100644 --- a/src/popups/UserMentions.h +++ b/src/popups/UserMentions.h @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -26,6 +27,9 @@ public: void initializeMentions(const QMap ¬ifs); void showPopup(); +protected: + void paintEvent(QPaintEvent *) override; + private: void pushItem(const QString &event_id, const QString &user_id, -- cgit 1.5.1