From 72cd949dd179f0781c156544b87cb6d1d5c34862 Mon Sep 17 00:00:00 2001 From: Kevin Smith Date: Sun, 10 Jul 2011 13:09:26 +0100 Subject: Update the Chats tab for unread messages diff --git a/Swift/QtUI/ChatList/QtChatListWindow.cpp b/Swift/QtUI/ChatList/QtChatListWindow.cpp index fab6374..9beb9dc 100644 --- a/Swift/QtUI/ChatList/QtChatListWindow.cpp +++ b/Swift/QtUI/ChatList/QtChatListWindow.cpp @@ -99,8 +99,8 @@ void QtChatListWindow::setRecents(const std::list& recents model_->setRecents(recents); } -void QtChatListWindow::setUnreadCount(int /*unread*/) { - +void QtChatListWindow::setUnreadCount(int unread) { + emit onCountUpdated(unread); } void QtChatListWindow::handleRemoveBookmark() { diff --git a/Swift/QtUI/ChatList/QtChatListWindow.h b/Swift/QtUI/ChatList/QtChatListWindow.h index 67f2c41..8775c3e 100644 --- a/Swift/QtUI/ChatList/QtChatListWindow.h +++ b/Swift/QtUI/ChatList/QtChatListWindow.h @@ -26,6 +26,9 @@ namespace Swift { void setRecents(const std::list& recents); void setUnreadCount(int unread); void clearBookmarks(); + + signals: + void onCountUpdated(int count); private slots: void handleItemActivated(const QModelIndex&); void handleAddBookmark(); diff --git a/Swift/QtUI/QtMainWindow.cpp b/Swift/QtUI/QtMainWindow.cpp index 0c959d6..51aaf3e 100644 --- a/Swift/QtUI/QtMainWindow.cpp +++ b/Swift/QtUI/QtMainWindow.cpp @@ -72,6 +72,7 @@ QtMainWindow::QtMainWindow(QtSettingsProvider* settings, UIEventStream* uiEventS connect(eventWindow_, SIGNAL(onNewEventCountUpdated(int)), this, SLOT(handleEventCountUpdated(int))); chatListWindow_ = new QtChatListWindow(uiEventStream_); + connect(chatListWindow_, SIGNAL(onCountUpdated(int)), this, SLOT(handleChatCountUpdated(int))); tabs_->addTab(chatListWindow_, tr("C&hats")); tabs_->addTab(eventWindow_, tr("&Notices")); @@ -162,6 +163,17 @@ void QtMainWindow::handleEventCountUpdated(int count) { tabs_->setTabText(eventIndex, text); } +void QtMainWindow::handleChatCountUpdated(int count) { + QColor chatTabColor = (count == 0) ? QColor() : QColor(255, 0, 0); // invalid resets to default + int chatIndex = 1; + tabs_->tabBar()->setTabTextColor(chatIndex, chatTabColor); + QString text = tr("&Chats"); + if (count > 0) { + text += QString(" (%1)").arg(count); + } + tabs_->setTabText(chatIndex, text); +} + void QtMainWindow::handleAddUserActionTriggered(bool /*checked*/) { boost::shared_ptr event(new RequestAddUserDialogUIEvent()); uiEventStream_->send(event); diff --git a/Swift/QtUI/QtMainWindow.h b/Swift/QtUI/QtMainWindow.h index 5c29f6d..bb3e9df 100644 --- a/Swift/QtUI/QtMainWindow.h +++ b/Swift/QtUI/QtMainWindow.h @@ -59,6 +59,7 @@ namespace Swift { void handleChatUserActionTriggered(bool checked); void handleAdHocActionTriggered(bool checked); void handleEventCountUpdated(int count); + void handleChatCountUpdated(int count); void handleEditProfileRequest(); void handleTabChanged(int index); -- cgit v0.10.2-6-g49f6