diff options
-rw-r--r-- | src/ChatPage.cpp | 37 | ||||
-rw-r--r-- | src/ChatPage.h | 2 | ||||
-rw-r--r-- | src/UserMentionsWidget.cpp | 5 | ||||
-rw-r--r-- | src/dialogs/UserMentions.cpp | 37 | ||||
-rw-r--r-- | src/dialogs/UserMentions.h | 12 |
5 files changed, 46 insertions, 47 deletions
diff --git a/src/ChatPage.cpp b/src/ChatPage.cpp index 2f1a22b7..435d50c8 100644 --- a/src/ChatPage.cpp +++ b/src/ChatPage.cpp @@ -90,9 +90,9 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent) connect(sidebarActions_, &SideBarActions::joinRoom, this, &ChatPage::joinRoom); connect(sidebarActions_, &SideBarActions::createRoom, this, &ChatPage::createRoom); - user_info_widget_ = new UserInfoWidget(sideBar_); + user_info_widget_ = new UserInfoWidget(sideBar_); user_mentions_widget_ = new UserMentionsWidget(sideBar_); - room_list_ = new RoomList(sideBar_); + room_list_ = new RoomList(sideBar_); connect(room_list_, &RoomList::joinRoom, this, &ChatPage::joinRoom); sideBarLayout_->addWidget(user_info_widget_); @@ -155,22 +155,20 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent) }); connect(user_mentions_widget_, &UserMentionsWidget::clicked, this, [this]() { - http::client()->notifications( - 1000, - "", - "highlight", - [this](const mtx::responses::Notifications &res, - mtx::http::RequestErr err) { - if (err) { - nhlog::net()->warn( - "failed to retrieve notifications: {} ({})", - err->matrix_error.error, - static_cast<int>(err->status_code)); - return; - } + http::client()->notifications( + 1000, + "", + "highlight", + [this](const mtx::responses::Notifications &res, mtx::http::RequestErr err) { + if (err) { + nhlog::net()->warn("failed to retrieve notifications: {} ({})", + err->matrix_error.error, + static_cast<int>(err->status_code)); + return; + } - emit highlightedNotifsRetrieved(std::move(res)); - }); + emit highlightedNotifsRetrieved(std::move(res)); + }); }); connectivityTimer_.setInterval(CHECK_CONNECTIVITY_INTERVAL); @@ -520,7 +518,8 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent) connect(this, &ChatPage::leftRoom, this, &ChatPage::removeRoom); connect(this, &ChatPage::notificationsRetrieved, this, &ChatPage::sendDesktopNotifications); - connect(this, &ChatPage::highlightedNotifsRetrieved, this, &ChatPage::showNotificationsDialog); + connect( + this, &ChatPage::highlightedNotifsRetrieved, this, &ChatPage::showNotificationsDialog); connect(communitiesList_, &CommunitiesList::communityChanged, @@ -998,7 +997,7 @@ ChatPage::showNotificationsDialog(const mtx::responses::Notifications &res) 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); + const auto body = utils::event_body(item.event); notifDialog->pushItem(event_id, user_id, body, room_id); diff --git a/src/ChatPage.h b/src/ChatPage.h index bb06e0eb..06fae57c 100644 --- a/src/ChatPage.h +++ b/src/ChatPage.h @@ -90,7 +90,6 @@ signals: void notificationsRetrieved(const mtx::responses::Notifications &); void highlightedNotifsRetrieved(const mtx::responses::Notifications &); - void uploadFailed(const QString &msg); void imageUploaded(const QString &roomid, const QString &filename, @@ -209,7 +208,6 @@ private: void showNotificationsDialog(const mtx::responses::Notifications &); - QStringList generateTypingUsers(const QString &room_id, const std::vector<std::string> &typing_users); diff --git a/src/UserMentionsWidget.cpp b/src/UserMentionsWidget.cpp index b7b24ad2..a28db930 100644 --- a/src/UserMentionsWidget.cpp +++ b/src/UserMentionsWidget.cpp @@ -210,7 +210,7 @@ UserMentionsWidget::paintEvent(QPaintEvent *event) const int msgStampWidth = QFontMetrics(tsFont).horizontalAdvance("timestamp") + 4; #endif // We use the full width of the widget if there is no unread msg bubble. - //const int bottomLineWidthLimit = (unreadMsgCount_ > 0) ? msgStampWidth : 0; + // const int bottomLineWidthLimit = (unreadMsgCount_ > 0) ? msgStampWidth : 0; // Name line. QFontMetrics fontNameMetrics(headingFont); @@ -229,7 +229,8 @@ UserMentionsWidget::paintEvent(QPaintEvent *event) // timestamp. int usernameLimit = std::max(0, width() - 3 * wm.padding - msgStampWidth - wm.iconSize - 20); - auto userName = metrics.elidedText("Show Mentioned Messages", Qt::ElideRight, usernameLimit); + auto userName = + metrics.elidedText("Show Mentioned Messages", Qt::ElideRight, usernameLimit); p.setFont(QFont{}); p.drawText(QPoint(2 * wm.padding + wm.iconSize, bottom_y), userName); diff --git a/src/dialogs/UserMentions.cpp b/src/dialogs/UserMentions.cpp index 1a6c17e5..8f56ec93 100644 --- a/src/dialogs/UserMentions.cpp +++ b/src/dialogs/UserMentions.cpp @@ -6,7 +6,7 @@ using namespace dialogs; UserMentions::UserMentions(QWidget *parent) - : QWidget{parent} + : QWidget{parent} { top_layout_ = new QVBoxLayout(this); top_layout_->setSpacing(0); @@ -38,22 +38,21 @@ UserMentions::UserMentions(QWidget *parent) } 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); - }); +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 index ff68d8c8..e995b207 100644 --- a/src/dialogs/UserMentions.h +++ b/src/dialogs/UserMentions.h @@ -1,9 +1,9 @@ #pragma once -#include <QWidget> -#include <QVBoxLayout> #include <QScrollArea> #include <QScrollBar> +#include <QVBoxLayout> +#include <QWidget> namespace dialogs { @@ -12,15 +12,17 @@ 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); + 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 |