summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorJoseph Donofry <joedonofry@gmail.com>2019-07-21 21:58:11 -0400
committerJoseph Donofry <joedonofry@gmail.com>2019-07-21 21:58:11 -0400
commit8b2488b7ef9da83374691ab17cc6cb4a7459df23 (patch)
tree4220b6e35729f3d8a9c7308fa21986f9127d576c /src
parentFix linting issues (diff)
downloadnheko-8b2488b7ef9da83374691ab17cc6cb4a7459df23.tar.xz
Update Mentions UI
Mentions are now an '@' icon in the upper right.

UI Popup is now a smaller dialog.

Still lots of work to be done here.
Diffstat (limited to 'src')
-rw-r--r--src/ChatPage.cpp20
-rw-r--r--src/ChatPage.h5
-rw-r--r--src/TopRoomBar.cpp16
-rw-r--r--src/TopRoomBar.h3
4 files changed, 34 insertions, 10 deletions
diff --git a/src/ChatPage.cpp b/src/ChatPage.cpp

index 435d50c8..deefec14 100644 --- a/src/ChatPage.cpp +++ b/src/ChatPage.cpp
@@ -91,12 +91,12 @@ 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(sideBar_); 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(user_mentions_widget_); sideBarLayout_->addWidget(room_list_); sideBarLayout_->addWidget(sidebarActions_); @@ -154,12 +154,12 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent) trySync(); }); - connect(user_mentions_widget_, &UserMentionsWidget::clicked, this, [this]() { + connect(top_bar_, &TopRoomBar::mentionsClicked, this, [this](const QPoint &mentionsPos) { http::client()->notifications( 1000, "", "highlight", - [this](const mtx::responses::Notifications &res, mtx::http::RequestErr err) { + [this, mentionsPos](const mtx::responses::Notifications &res, mtx::http::RequestErr err) { if (err) { nhlog::net()->warn("failed to retrieve notifications: {} ({})", err->matrix_error.error, @@ -167,7 +167,7 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent) return; } - emit highlightedNotifsRetrieved(std::move(res)); + emit highlightedNotifsRetrieved(std::move(res), mentionsPos); }); }); @@ -218,6 +218,8 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent) } }); + + connect(room_list_, &RoomList::roomChanged, this, [this](const QString &roomid) { QStringList users; @@ -986,7 +988,7 @@ ChatPage::sendDesktopNotifications(const mtx::responses::Notifications &res) } void -ChatPage::showNotificationsDialog(const mtx::responses::Notifications &res) +ChatPage::showNotificationsDialog(const mtx::responses::Notifications &res, const QPoint &widgetPos) { // TODO: This should NOT BE A DIALOG. Make the TimelineView support // creating a timeline view from notifications (similarly to how it can show history views) @@ -1005,8 +1007,10 @@ ChatPage::showNotificationsDialog(const mtx::responses::Notifications &res) nhlog::db()->warn("error while sending desktop notification: {}", e.what()); } } - notifDialog->setFixedWidth(width()); - notifDialog->setFixedHeight(height()); + 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(); } diff --git a/src/ChatPage.h b/src/ChatPage.h
index 06fae57c..b2f04b02 100644 --- a/src/ChatPage.h +++ b/src/ChatPage.h
@@ -24,6 +24,7 @@ #include <QHBoxLayout> #include <QMap> #include <QPixmap> +#include <QPoint> #include <QTimer> #include <QWidget> @@ -88,7 +89,7 @@ signals: void messageReply(const RelatedInfo &related); void notificationsRetrieved(const mtx::responses::Notifications &); - void highlightedNotifsRetrieved(const mtx::responses::Notifications &); + void highlightedNotifsRetrieved(const mtx::responses::Notifications &, const QPoint widgetPos); void uploadFailed(const QString &msg); void imageUploaded(const QString &roomid, @@ -206,7 +207,7 @@ private: //! Send desktop notification for the received messages. void sendDesktopNotifications(const mtx::responses::Notifications &); - void showNotificationsDialog(const mtx::responses::Notifications &); + void showNotificationsDialog(const mtx::responses::Notifications &, const QPoint &point); QStringList generateTypingUsers(const QString &room_id, const std::vector<std::string> &typing_users); diff --git a/src/TopRoomBar.cpp b/src/TopRoomBar.cpp
index 5c817dc2..a8049e3a 100644 --- a/src/TopRoomBar.cpp +++ b/src/TopRoomBar.cpp
@@ -80,11 +80,21 @@ TopRoomBar::TopRoomBar(QWidget *parent) settingsBtn_->setFixedSize(buttonSize_, buttonSize_); settingsBtn_->setCornerRadius(buttonSize_ / 2); + mentionsBtn_ = new FlatButton(this); + mentionsBtn_->setToolTip(tr("Mentions")); + mentionsBtn_->setFixedSize(buttonSize_, buttonSize_); + mentionsBtn_->setCornerRadius(buttonSize_ / 2); + QIcon settings_icon; settings_icon.addFile(":/icons/icons/ui/vertical-ellipsis.png"); settingsBtn_->setIcon(settings_icon); settingsBtn_->setIconSize(QSize(buttonSize_ / 2, buttonSize_ / 2)); + QIcon mentions_icon; + mentions_icon.addFile(":/icons/icons/ui/at-solid.svg"); + mentionsBtn_->setIcon(mentions_icon); + mentionsBtn_->setIconSize(QSize(buttonSize_ / 2, buttonSize_ / 2)); + backBtn_ = new FlatButton(this); backBtn_->setFixedSize(buttonSize_, buttonSize_); backBtn_->setCornerRadius(buttonSize_ / 2); @@ -100,6 +110,7 @@ TopRoomBar::TopRoomBar(QWidget *parent) topLayout_->addWidget(avatar_); topLayout_->addWidget(backBtn_); topLayout_->addLayout(textLayout_, 1); + topLayout_->addWidget(mentionsBtn_, 0, Qt::AlignRight); topLayout_->addWidget(settingsBtn_, 0, Qt::AlignRight); menu_ = new Menu(this); @@ -135,6 +146,11 @@ TopRoomBar::TopRoomBar(QWidget *parent) menu_->popup( QPoint(pos.x() + buttonSize_ - menu_->sizeHint().width(), pos.y() + buttonSize_)); }); + + connect(mentionsBtn_, &QPushButton::clicked, this, [this]() { + auto pos = mapToGlobal(mentionsBtn_->pos()); + emit mentionsClicked(pos); + }); } void diff --git a/src/TopRoomBar.h b/src/TopRoomBar.h
index 5b7d3344..5f2c936e 100644 --- a/src/TopRoomBar.h +++ b/src/TopRoomBar.h
@@ -24,6 +24,7 @@ #include <QPaintEvent> #include <QPainter> #include <QPen> +#include <QPoint> #include <QStyle> #include <QStyleOption> #include <QVBoxLayout> @@ -63,6 +64,7 @@ public slots: signals: void inviteUsers(QStringList users); void showRoomList(); + void mentionsClicked(const QPoint &pos); protected: void mousePressEvent(QMouseEvent *) override @@ -93,6 +95,7 @@ private: QAction *inviteUsers_ = nullptr; FlatButton *settingsBtn_; + FlatButton *mentionsBtn_; FlatButton *backBtn_; Avatar *avatar_;