From 8e517721c88f22774224766dba4105fcb723fa91 Mon Sep 17 00:00:00 2001
From: Kevin Smith <git@kismith.co.uk>
Date: Thu, 18 Jun 2009 17:56:21 +0100
Subject: It should be impossible to lose tabs now.

You can still have an empty tabset, though.

diff --git a/Swift/QtUI/QtChatTabs.cpp b/Swift/QtUI/QtChatTabs.cpp
index 24828fc..e1f4e86 100644
--- a/Swift/QtUI/QtChatTabs.cpp
+++ b/Swift/QtUI/QtChatTabs.cpp
@@ -1,5 +1,6 @@
 #include "QtChatTabs.h"
 
+#include <QCloseEvent>
 #include <QTabWidget>
 #include <QLayout>
 
@@ -21,6 +22,15 @@ QtChatTabs::QtChatTabs() : QWidget() {
 	resize(400, 300);
 }
 
+void QtChatTabs::closeEvent(QCloseEvent* event) {
+	//Hide first to prevent flickering as each tab is removed.
+	hide();
+	for (int i = tabs_->count() - 1; i >= 0; i--) {
+		tabs_->removeTab(i);
+	}
+	event->accept();
+}
+
 void QtChatTabs::addTab(QtTabbable* tab) {
 	tabs_->addTab(tab, tab->windowTitle());
 	connect(tab, SIGNAL(titleUpdated()), this, SLOT(handleTabTitleUpdated()));
@@ -37,6 +47,7 @@ void QtChatTabs::handleWidgetShown() {
 		return;
 	}
 	addTab(widget);
+	show();
 }
 
 void QtChatTabs::handleTabClosing() {
diff --git a/Swift/QtUI/QtChatTabs.h b/Swift/QtUI/QtChatTabs.h
index 7534c5a..97967c9 100644
--- a/Swift/QtUI/QtChatTabs.h
+++ b/Swift/QtUI/QtChatTabs.h
@@ -11,6 +11,9 @@ namespace Swift {
 			QtChatTabs();
 			void addTab(QtTabbable* tab);
 
+		protected slots:
+			void closeEvent(QCloseEvent* event);
+
 		private slots:
 			void handleTabClosing();
 			void handleTabTitleUpdated();
diff --git a/Swift/QtUI/QtChatWindow.cpp b/Swift/QtUI/QtChatWindow.cpp
index 6442f8e..5b63e55 100644
--- a/Swift/QtUI/QtChatWindow.cpp
+++ b/Swift/QtUI/QtChatWindow.cpp
@@ -182,6 +182,7 @@ void QtChatWindow::returnPressed() {
 
 void QtChatWindow::show() {
 	QWidget::show();
+	emit windowOpening();
 }
 
 }
-- 
cgit v0.10.2-6-g49f6