From ab5fcc8ad6447a4b3578eb84c1ec3a975ec62d4c Mon Sep 17 00:00:00 2001 From: Kevin Smith Date: Thu, 18 Jun 2009 18:31:27 +0200 Subject: Support closing and reopening chats in tabs. diff --git a/Swift/QtUI/QtChatTabs.cpp b/Swift/QtUI/QtChatTabs.cpp index c7cd7ba..24828fc 100644 --- a/Swift/QtUI/QtChatTabs.cpp +++ b/Swift/QtUI/QtChatTabs.cpp @@ -25,6 +25,18 @@ void QtChatTabs::addTab(QtTabbable* tab) { tabs_->addTab(tab, tab->windowTitle()); connect(tab, SIGNAL(titleUpdated()), this, SLOT(handleTabTitleUpdated())); connect(tab, SIGNAL(windowClosing()), this, SLOT(handleTabClosing())); + connect(tab, SIGNAL(windowOpening()), this, SLOT(handleWidgetShown())); +} + +void QtChatTabs::handleWidgetShown() { + QtTabbable* widget = qobject_cast(sender()); + if (!widget) { + return; + } + if (tabs_->indexOf(widget) >= 0) { + return; + } + addTab(widget); } void QtChatTabs::handleTabClosing() { @@ -56,4 +68,4 @@ void QtChatTabs::handleTabTitleUpdated() { tabs_->setTabText(index, widget->windowTitle()); } -} \ No newline at end of file +} diff --git a/Swift/QtUI/QtChatTabs.h b/Swift/QtUI/QtChatTabs.h index 37acc91..7534c5a 100644 --- a/Swift/QtUI/QtChatTabs.h +++ b/Swift/QtUI/QtChatTabs.h @@ -15,8 +15,9 @@ namespace Swift { void handleTabClosing(); void handleTabTitleUpdated(); void handleTabCloseRequested(int index); + void handleWidgetShown(); private: - QTabWidget* tabs_; + QTabWidget* tabs_; }; } diff --git a/Swift/QtUI/QtChatWindow.cpp b/Swift/QtUI/QtChatWindow.cpp index 9f1f445..6442f8e 100644 --- a/Swift/QtUI/QtChatWindow.cpp +++ b/Swift/QtUI/QtChatWindow.cpp @@ -111,6 +111,11 @@ void QtChatWindow::qAppFocusChanged(QWidget *old, QWidget *now) { } +void QtChatWindow::showEvent(QShowEvent* event) { + emit windowOpening(); + QWidget::showEvent(event); +} + void QtChatWindow::setUnreadMessageCount(int count) { unreadCount_ = count; updateTitleWithUnreadCount(); diff --git a/Swift/QtUI/QtChatWindow.h b/Swift/QtUI/QtChatWindow.h index e0c7f5d..bbb1a7e 100644 --- a/Swift/QtUI/QtChatWindow.h +++ b/Swift/QtUI/QtChatWindow.h @@ -34,6 +34,8 @@ namespace Swift { void qAppFocusChanged(QWidget* old, QWidget* now); void closeEvent(QCloseEvent* event); + protected: + void showEvent(QShowEvent* event); private slots: void returnPressed(); diff --git a/Swift/QtUI/QtTabbable.h b/Swift/QtUI/QtTabbable.h index 9894bfe..96348b3 100644 --- a/Swift/QtUI/QtTabbable.h +++ b/Swift/QtUI/QtTabbable.h @@ -12,5 +12,6 @@ namespace Swift { signals: void titleUpdated(); void windowClosing(); + void windowOpening(); }; } -- cgit v0.10.2-6-g49f6