From 776c7f67e845e9193993cec42fa60b2e418e9c75 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Remko=20Tron=C3=A7on?= <git@el-tramo.be>
Date: Tue, 1 Sep 2009 20:36:02 +0200
Subject: Fix show/hide behavior of SystemTray.

Show now brings the window to front and activates it.
Clicking on the tray hides the application if it is visible.

diff --git a/Swift/QtUI/QtLoginWindow.cpp b/Swift/QtUI/QtLoginWindow.cpp
index 2a25420..9694364 100644
--- a/Swift/QtUI/QtLoginWindow.cpp
+++ b/Swift/QtUI/QtLoginWindow.cpp
@@ -169,4 +169,15 @@ void QtLoginWindow::setMessage(const String& message) {
 	}
 }
 
+void QtLoginWindow::bringToFront() {
+	if (isHidden()) {
+		showNormal();
+		raise();
+		activateWindow();
+	}
+	else {
+		hide();
+	}
+}
+
 }
diff --git a/Swift/QtUI/QtLoginWindow.h b/Swift/QtUI/QtLoginWindow.h
index 1c156db..144f212 100644
--- a/Swift/QtUI/QtLoginWindow.h
+++ b/Swift/QtUI/QtLoginWindow.h
@@ -29,6 +29,7 @@ namespace Swift {
 			void handleCertficateChecked(bool);
 			void handleQuit();
 			void handleAbout();
+			void bringToFront();
 
 		private:
 			void setInitialMenus();
diff --git a/Swift/QtUI/QtLoginWindowFactory.cpp b/Swift/QtUI/QtLoginWindowFactory.cpp
index c150892..2405dd6 100644
--- a/Swift/QtUI/QtLoginWindowFactory.cpp
+++ b/Swift/QtUI/QtLoginWindowFactory.cpp
@@ -13,7 +13,7 @@ LoginWindow* QtLoginWindowFactory::createLoginWindow(const String& defaultJID, c
 	if (splitter_) {
 		splitter_->insertWidget(0, window);
 	}
-	connect(systemTray_, SIGNAL(clicked()), window, SLOT(show()));
+	connect(systemTray_, SIGNAL(clicked()), window, SLOT(bringToFront()));
 	return window;
 }
 }
-- 
cgit v0.10.2-6-g49f6