From e1d48367f8ccb83fc1fcdaee899e5bf4f8ac2669 Mon Sep 17 00:00:00 2001 From: Konstantinos Sideris Date: Sat, 15 Apr 2017 19:04:02 +0300 Subject: Show the unread message count on the window title --- src/ChatPage.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/ChatPage.cc') diff --git a/src/ChatPage.cc b/src/ChatPage.cc index 33cacb3e..3bae177b 100644 --- a/src/ChatPage.cc +++ b/src/ChatPage.cc @@ -64,11 +64,17 @@ ChatPage::ChatPage(QSharedPointer client, QWidget *parent) view_manager_, SLOT(setHistoryView(const RoomInfo &))); + // TODO: Better pass the whole RoomInfo struct instead of the roomid. connect(view_manager_, SIGNAL(unreadMessages(const QString &, int)), room_list_, SLOT(updateUnreadMessageCount(const QString &, int))); + connect(room_list_, + SIGNAL(totalUnreadMessageCountUpdated(int)), + this, + SLOT(showUnreadMessageNotification(int))); + connect(text_input_, SIGNAL(sendTextMessage(const QString &)), view_manager_, @@ -206,6 +212,15 @@ void ChatPage::changeTopRoomInfo(const RoomInfo &info) current_room_ = info; } +void ChatPage::showUnreadMessageNotification(int count) +{ + // TODO: Make the default title a const. + if (count == 0) + emit changeWindowTitle("nheko"); + else + emit changeWindowTitle(QString("nheko (%1)").arg(count)); +} + ChatPage::~ChatPage() { sync_timer_->stop(); -- cgit 1.4.1