diff options
author | Kevin Smith <git@kismith.co.uk> | 2010-06-20 22:08:20 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2010-06-20 22:08:20 (GMT) |
commit | 9695b3f8343a04e71fea697fc8c280cdafe85465 (patch) | |
tree | ac76b5de06621c8733e629cd6874eac376fd81ce /Swift/QtUI/QtChatTabs.cpp | |
parent | dfea757fd085ca9386b96db58c5d2bcd6173a917 (diff) | |
download | swift-contrib-48c42652b22dc23112da35fcd00a8de767aef553.zip swift-contrib-48c42652b22dc23112da35fcd00a8de767aef553.tar.bz2 |
Show total unread count in tab title.swift-1.0beta4
Resolves: #448
Diffstat (limited to 'Swift/QtUI/QtChatTabs.cpp')
-rw-r--r-- | Swift/QtUI/QtChatTabs.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/Swift/QtUI/QtChatTabs.cpp b/Swift/QtUI/QtChatTabs.cpp index dd63c8d..5473823 100644 --- a/Swift/QtUI/QtChatTabs.cpp +++ b/Swift/QtUI/QtChatTabs.cpp @@ -55,6 +55,7 @@ void QtChatTabs::addTab(QtTabbable* tab) { setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); tabs_->addTab(tab, tab->windowTitle()); connect(tab, SIGNAL(titleUpdated()), this, SLOT(handleTabTitleUpdated())); + connect(tab, SIGNAL(countUpdated()), this, SLOT(handleTabTitleUpdated())); connect(tab, SIGNAL(windowClosing()), this, SLOT(handleTabClosing())); connect(tab, SIGNAL(windowOpening()), this, SLOT(handleWidgetShown())); connect(tab, SIGNAL(wantsToActivate()), this, SLOT(handleWantsToActivate())); @@ -136,7 +137,7 @@ void QtChatTabs::handleTabTitleUpdated(QWidget* widget) { if (index < 0) { return; } - tabs_->setTabText(index, widget->windowTitle()); + tabs_->setTabText(index, tabbable->getCount() > 0 ? QString("(%1) %2").arg(tabbable->getCount()).arg(tabbable->windowTitle()) : tabbable->windowTitle()); QColor tabTextColor; bool flash = false; switch (tabbable->getWidgetAlertState()) { @@ -145,9 +146,13 @@ void QtChatTabs::handleTabTitleUpdated(QWidget* widget) { default : tabTextColor = QColor(); } tabs_->tabBar()->setTabTextColor(index, tabTextColor); - if (widget == tabs_->currentWidget()) { - setWindowTitle(widget->windowTitle()); + int unread = 0; + for (int i = 0; i < tabs_->count(); i++) { + unread += qobject_cast<QtTabbable*>(tabs_->widget(i))->getCount(); } + + QtTabbable* current = qobject_cast<QtTabbable*>(tabs_->currentWidget()); + setWindowTitle(unread > 0 ? QString("(%1) %2").arg(unread).arg(current->windowTitle()) : current->windowTitle()); if (flash) { #ifndef SWIFTEN_PLATFORM_MACOSX |