diff options
author | Kevin Smith <git@kismith.co.uk> | 2009-06-18 16:31:27 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2009-06-18 16:33:11 (GMT) |
commit | ab5fcc8ad6447a4b3578eb84c1ec3a975ec62d4c (patch) | |
tree | aa01ac335817540bb3473d03953bd41a42b5f127 /Swift/QtUI | |
parent | f2e3bfbe2ed1b8f35aa958041ee766f9d8ddf31e (diff) | |
download | swift-ab5fcc8ad6447a4b3578eb84c1ec3a975ec62d4c.zip swift-ab5fcc8ad6447a4b3578eb84c1ec3a975ec62d4c.tar.bz2 |
Support closing and reopening chats in tabs.
Diffstat (limited to 'Swift/QtUI')
-rw-r--r-- | Swift/QtUI/QtChatTabs.cpp | 14 | ||||
-rw-r--r-- | Swift/QtUI/QtChatTabs.h | 3 | ||||
-rw-r--r-- | Swift/QtUI/QtChatWindow.cpp | 5 | ||||
-rw-r--r-- | Swift/QtUI/QtChatWindow.h | 2 | ||||
-rw-r--r-- | Swift/QtUI/QtTabbable.h | 1 |
5 files changed, 23 insertions, 2 deletions
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<QtTabbable*>(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(); }; } |