summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
Diffstat (limited to 'Swift')
-rw-r--r--Swift/QtUI/QtChatTabs.cpp11
-rw-r--r--Swift/QtUI/QtChatWindow.cpp7
-rw-r--r--Swift/QtUI/QtChatWindow.h1
-rw-r--r--Swift/QtUI/QtTabbable.h2
4 files changed, 17 insertions, 4 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
diff --git a/Swift/QtUI/QtChatWindow.cpp b/Swift/QtUI/QtChatWindow.cpp
index 0c297b2..fcc1308 100644
--- a/Swift/QtUI/QtChatWindow.cpp
+++ b/Swift/QtUI/QtChatWindow.cpp
@@ -198,6 +198,7 @@ void QtChatWindow::showEvent(QShowEvent* event) {
void QtChatWindow::setUnreadMessageCount(int count) {
unreadCount_ = count;
updateTitleWithUnreadCount();
+ emit countUpdated();
}
void QtChatWindow::setContactChatState(ChatState::ChatStateType state) {
@@ -221,7 +222,7 @@ void QtChatWindow::setName(const String& name) {
}
void QtChatWindow::updateTitleWithUnreadCount() {
- setWindowTitle(unreadCount_ > 0 ? QString("(%1) %2").arg(unreadCount_).arg(contact_) : contact_);
+ setWindowTitle(contact_);
emit titleUpdated();
}
@@ -255,6 +256,10 @@ void QtChatWindow::addMessage(const String &message, const String &senderName, b
previousMessageWasSystem_ = false;
}
+int QtChatWindow::getCount() {
+ return unreadCount_;
+}
+
void QtChatWindow::addAction(const String &message, const String &senderName, bool senderIsSelf, const boost::optional<SecurityLabel>& label, const String& avatarPath, const boost::posix_time::ptime& time) {
addMessage(" *" + message + "*", senderName, senderIsSelf, label, avatarPath, "font-style:italic ", time);
}
diff --git a/Swift/QtUI/QtChatWindow.h b/Swift/QtUI/QtChatWindow.h
index 44d79a1..00d7f25 100644
--- a/Swift/QtUI/QtChatWindow.h
+++ b/Swift/QtUI/QtChatWindow.h
@@ -46,6 +46,7 @@ namespace Swift {
void setContactChatState(ChatState::ChatStateType state);
void setRosterModel(Roster* roster);
void setTabComplete(TabComplete* completer);
+ int getCount();
protected slots:
void qAppFocusChanged(QWidget* old, QWidget* now);
diff --git a/Swift/QtUI/QtTabbable.h b/Swift/QtUI/QtTabbable.h
index dd87142..9309841 100644
--- a/Swift/QtUI/QtTabbable.h
+++ b/Swift/QtUI/QtTabbable.h
@@ -17,11 +17,13 @@ namespace Swift {
~QtTabbable();
bool isWidgetSelected();
virtual AlertType getWidgetAlertState() {return NoActivity;};
+ virtual int getCount() {return 0;}
protected:
QtTabbable() : QWidget() {};
signals:
void titleUpdated();
+ void countUpdated();
void windowClosing();
void windowOpening();
void wantsToActivate();