From b04ff6d3f9c4496d5667e4681e6820e708ba409a Mon Sep 17 00:00:00 2001
From: Kevin Smith <git@kismith.co.uk>
Date: Sat, 23 Mar 2013 20:44:57 +0000
Subject: Show window titles in netbook mode

Change-Id: Idb51c066c5b0030646eecf641d729966b9e14d06

diff --git a/Swift/QtUI/QtChatTabs.cpp b/Swift/QtUI/QtChatTabs.cpp
index e37803e..6d12d80 100644
--- a/Swift/QtUI/QtChatTabs.cpp
+++ b/Swift/QtUI/QtChatTabs.cpp
@@ -251,7 +251,9 @@ void QtChatTabs::handleTabTitleUpdated(QWidget* widget) {
 
 	std::string current(Q2PSTRING(qobject_cast<QtTabbable*>(tabs_->currentWidget())->windowTitle()));
 	ChatMessageSummarizer summary;
-	setWindowTitle(summary.getSummary(current, unreads).c_str());
+	QString title = summary.getSummary(current, unreads).c_str();
+	setWindowTitle(title);
+	emit onTitleChanged(title);
 }
 
 void QtChatTabs::flash() {
diff --git a/Swift/QtUI/QtChatTabs.h b/Swift/QtUI/QtChatTabs.h
index 233c574..35f426b 100644
--- a/Swift/QtUI/QtChatTabs.h
+++ b/Swift/QtUI/QtChatTabs.h
@@ -23,6 +23,7 @@ namespace Swift {
 			QtTabbable* getCurrentTab();
 		signals:
 			void geometryChanged();
+			void onTitleChanged(const QString& title);
 
 		protected slots:
 			void closeEvent(QCloseEvent* event);
diff --git a/Swift/QtUI/QtChatWindowFactory.cpp b/Swift/QtUI/QtChatWindowFactory.cpp
index 5f91ff8..bc5d7f4 100644
--- a/Swift/QtUI/QtChatWindowFactory.cpp
+++ b/Swift/QtUI/QtChatWindowFactory.cpp
@@ -4,23 +4,24 @@
  * See Documentation/Licenses/GPLv3.txt for more information.
  */
 
-#include "QtChatWindowFactory.h"
+#include <Swift/QtUI/QtChatWindowFactory.h>
 
 #include <QDesktopWidget>
-
-#include "QtChatTabs.h"
-#include "QtChatWindow.h"
-#include "QtSwiftUtil.h"
-#include "QtChatTheme.h"
 #include <qdebug.h>
 
+#include <Swift/QtUI/QtChatTabs.h>
+#include <Swift/QtUI/QtChatWindow.h>
+#include <Swift/QtUI/QtSwiftUtil.h>
+#include <Swift/QtUI/QtChatTheme.h>
+#include <Swift/QtUI/QtSingleWindow.h>
+
 
 namespace Swift {
 
 static const QString SPLITTER_STATE = "mucSplitterState";
 static const QString CHAT_TABS_GEOMETRY = "chatTabsGeometry";
 
-QtChatWindowFactory::QtChatWindowFactory(QSplitter* splitter, SettingsProvider* settings, QtSettingsProvider* qtSettings, QtChatTabs* tabs, const QString& themePath, QMap<QString, QString> emoticons) : themePath_(themePath), emoticons_(emoticons) {
+QtChatWindowFactory::QtChatWindowFactory(QtSingleWindow* splitter, SettingsProvider* settings, QtSettingsProvider* qtSettings, QtChatTabs* tabs, const QString& themePath, QMap<QString, QString> emoticons) : themePath_(themePath), emoticons_(emoticons) {
 	qtOnlySettings_ = qtSettings;
 	settings_ = settings;
 	tabs_ = tabs;
diff --git a/Swift/QtUI/QtChatWindowFactory.h b/Swift/QtUI/QtChatWindowFactory.h
index 4f59961..89a322f 100644
--- a/Swift/QtUI/QtChatWindowFactory.h
+++ b/Swift/QtUI/QtChatWindowFactory.h
@@ -6,21 +6,24 @@
 
 #pragma once
 
-#include "Swift/Controllers/UIInterfaces/ChatWindowFactory.h"
-#include "Swiften/JID/JID.h"
-#include "QtSettingsProvider.h"
+#include <Swift/Controllers/UIInterfaces/ChatWindowFactory.h>
 
 #include <QObject>
 #include <QSplitter>
+
+#include <Swiften/JID/JID.h>
+#include <Swift/QtUI/QtSettingsProvider.h>
+
 namespace Swift {
 	class QtChatTabs;
 	class QtChatTheme;
 	class UIEventStream;
 	class QtUIPreferences;
+	class QtSingleWindow;
 	class QtChatWindowFactory : public QObject, public ChatWindowFactory {
 		Q_OBJECT
 		public:
-			QtChatWindowFactory(QSplitter* splitter, SettingsProvider* settings, QtSettingsProvider* qtSettings, QtChatTabs* tabs, const QString& themePath, QMap<QString, QString> emoticons);
+			QtChatWindowFactory(QtSingleWindow* splitter, SettingsProvider* settings, QtSettingsProvider* qtSettings, QtChatTabs* tabs, const QString& themePath, QMap<QString, QString> emoticons);
 			~QtChatWindowFactory();
 			ChatWindow* createChatWindow(const JID &contact, UIEventStream* eventStream);
 		signals:
diff --git a/Swift/QtUI/QtSingleWindow.cpp b/Swift/QtUI/QtSingleWindow.cpp
index 733571f..c970296 100644
--- a/Swift/QtUI/QtSingleWindow.cpp
+++ b/Swift/QtUI/QtSingleWindow.cpp
@@ -6,8 +6,10 @@
 
 #include <Swift/QtUI/QtSingleWindow.h>
 
-#include <Swift/QtUI/QtSettingsProvider.h>
+
 #include <Swiften/Base/foreach.h>
+#include <Swift/QtUI/QtSettingsProvider.h>
+#include <Swift/QtUI/QtChatTabs.h>
 
 namespace Swift {
 
@@ -28,6 +30,18 @@ QtSingleWindow::~QtSingleWindow() {
 
 }
 
+void QtSingleWindow::addWidget(QWidget* widget) {
+	QtChatTabs* tabs = dynamic_cast<QtChatTabs*>(widget);
+	if (tabs) {
+		connect(tabs, SIGNAL(onTitleChanged(const QString&)), this, SLOT(handleTabsTitleChanged(const QString&)));
+	}
+	QSplitter::addWidget(widget);
+}
+
+void QtSingleWindow::handleTabsTitleChanged(const QString& title) {
+	setWindowTitle(title);
+}
+
 void QtSingleWindow::handleSplitterMoved(int, int) {
 	QList<QVariant> variantValues;
 	QList<int> intValues = sizes();
diff --git a/Swift/QtUI/QtSingleWindow.h b/Swift/QtUI/QtSingleWindow.h
index 6cbc3e4..b55b3c9 100644
--- a/Swift/QtUI/QtSingleWindow.h
+++ b/Swift/QtUI/QtSingleWindow.h
@@ -17,11 +17,13 @@ namespace Swift {
 			QtSingleWindow(QtSettingsProvider* settings);
 			virtual ~QtSingleWindow();
 			void insertAtFront(QWidget* widget);
+			void addWidget(QWidget* widget);
 		protected:
 			void resizeEvent(QResizeEvent*);
 			void moveEvent(QMoveEvent*);
 		private slots:
 			void handleSplitterMoved(int, int);
+			void handleTabsTitleChanged(const QString& title);
 		private:
 			void handleGeometryChanged();
 			void restoreSplitters();
-- 
cgit v0.10.2-6-g49f6