From e8b2e33a6fc569af116a32ebb5e441728e390c8f Mon Sep 17 00:00:00 2001
From: Kevin Smith <git@kismith.co.uk>
Date: Sun, 19 Dec 2010 11:46:44 +0000
Subject: Calling with --start-minimized will not show login/roster at launch.

Release-Notes: Launching Swift with the --start-minimized command-line parameter will cause the initial login/roster window to not be displayed (it starts minimized to tray).

diff --git a/Swift/QtUI/QtSwift.cpp b/Swift/QtUI/QtSwift.cpp
index 9a1788f..7717b77 100644
--- a/Swift/QtUI/QtSwift.cpp
+++ b/Swift/QtUI/QtSwift.cpp
@@ -61,10 +61,11 @@ po::options_description QtSwift::getOptionsDescription() {
 	result.add_options()
 		("debug", "Turn on debug logging")
 		("help", "produce help message")
-		("netbook-mode", "use netbook mode display")
-		("no-tabs", "don't manage chat windows in tabs")
-		("latency-debug", "use latency debugging")
-		("multi-account", po::value<int>()->default_value(1), "number of accounts to open windows for")
+		("netbook-mode", "use netbook mode display (unsupported)")
+		("no-tabs", "don't manage chat windows in tabs (unsupported)")
+		("latency-debug", "use latency debugging (unsupported)")
+		("multi-account", po::value<int>()->default_value(1), "number of accounts to open windows for (unsupported)")
+		("start-minimized", "don't show the login/roster window at startup")
 		;
 	return result;
 }
@@ -94,6 +95,7 @@ QtSwift::QtSwift(po::variables_map options) : networkFactories_(&clientMainThrea
 	}
 
 	tabs_ = options.count("no-tabs") && !(splitter_ > 0) ? NULL : new QtChatTabs();
+	bool startMinimized = options.count("start-minimized") > 0;
 	settings_ = new QtSettingsProvider();
 	applicationPathProvider_ = new PlatformApplicationPathProvider(SWIFT_APPLICATION_NAME);
 	storagesFactory_ = new FileStoragesFactory(applicationPathProvider_->getDataDir());
@@ -123,7 +125,7 @@ QtSwift::QtSwift(po::variables_map options) : networkFactories_(&clientMainThrea
 	for (int i = 0; i < numberOfAccounts; i++) {
 		QtSystemTray* systemTray = new QtSystemTray();
 		systemTrays_.push_back(systemTray);
-		QtUIFactory* uiFactory = new QtUIFactory(settings_, tabs_, splitter_, systemTray, chatWindowFactory_);
+		QtUIFactory* uiFactory = new QtUIFactory(settings_, tabs_, splitter_, systemTray, chatWindowFactory_, startMinimized);
 		uiFactories_.push_back(uiFactory);
 		MainController* mainController = new MainController(
 				&clientMainThreadCaller_,
diff --git a/Swift/QtUI/QtUIFactory.cpp b/Swift/QtUI/QtUIFactory.cpp
index 60a7a6a..55ed370 100644
--- a/Swift/QtUI/QtUIFactory.cpp
+++ b/Swift/QtUI/QtUIFactory.cpp
@@ -22,7 +22,7 @@
 
 namespace Swift {
 
-QtUIFactory::QtUIFactory(QtSettingsProvider* settings, QtChatTabs* tabs, QSplitter* netbookSplitter, QtSystemTray* systemTray, QtChatWindowFactory* chatWindowFactory) : settings(settings), tabs(tabs), netbookSplitter(netbookSplitter), systemTray(systemTray), chatWindowFactory(chatWindowFactory), lastMainWindow(NULL), loginWindow(NULL)  {
+QtUIFactory::QtUIFactory(QtSettingsProvider* settings, QtChatTabs* tabs, QSplitter* netbookSplitter, QtSystemTray* systemTray, QtChatWindowFactory* chatWindowFactory, bool startMinimized) : settings(settings), tabs(tabs), netbookSplitter(netbookSplitter), systemTray(systemTray), chatWindowFactory(chatWindowFactory), lastMainWindow(NULL), loginWindow(NULL), startMinimized(startMinimized)  {
 }
 
 XMLConsoleWidget* QtUIFactory::createXMLConsoleWidget() {
@@ -53,6 +53,7 @@ LoginWindow* QtUIFactory::createLoginWindow(UIEventStream* eventStream) {
 		loginWindow->restoreGeometry(loginWindowGeometryVariant.toByteArray());
 	}
 	connect(loginWindow, SIGNAL(geometryChanged()), this, SLOT(handleLoginWindowGeometryChanged()));
+	if (startMinimized) loginWindow->hide();
 	return loginWindow;
 }
 
diff --git a/Swift/QtUI/QtUIFactory.h b/Swift/QtUI/QtUIFactory.h
index e06b411..7f610a2 100644
--- a/Swift/QtUI/QtUIFactory.h
+++ b/Swift/QtUI/QtUIFactory.h
@@ -24,7 +24,7 @@ namespace Swift {
 	class QtUIFactory : public QObject, public UIFactory {
 			Q_OBJECT
 		public:
-			QtUIFactory(QtSettingsProvider* settings, QtChatTabs* tabs, QSplitter* netbookSplitter, QtSystemTray* systemTray, QtChatWindowFactory* chatWindowFactory);
+			QtUIFactory(QtSettingsProvider* settings, QtChatTabs* tabs, QSplitter* netbookSplitter, QtSystemTray* systemTray, QtChatWindowFactory* chatWindowFactory, bool startMinimized);
 
 			virtual XMLConsoleWidget* createXMLConsoleWidget();
 			virtual MainWindow* createMainWindow(UIEventStream* eventStream);
@@ -45,5 +45,6 @@ namespace Swift {
 			QtChatWindowFactory* chatWindowFactory;
 			QtMainWindow* lastMainWindow;
 			QtLoginWindow* loginWindow;
+			bool startMinimized;
 	};
 }
-- 
cgit v0.10.2-6-g49f6