[PATCH 1/2] wpa_gui-qt4: clean up closeEvent handler

Kel Modderman kel at otaku42.de
Tue Sep 30 21:42:43 EDT 2008


When the system tray icon is created, qApp's setQuitOnLastWindowClosed
property is set to false, therefore do _not_ ignore widget close events, or
else wpa_gui will refuse to exit when the window manager is logging out.

While at it, remove WpaGui::fileExit() and connect fileExitAction to close().

Signed-off-by: Kel Modderman <kel at otaku42.de>
---
--- a/wpa_supplicant/wpa_gui-qt4/wpagui.cpp
+++ b/wpa_supplicant/wpa_gui-qt4/wpagui.cpp
@@ -37,7 +37,7 @@
 		SLOT(eventHistory()));
 	connect(fileSaveConfigAction, SIGNAL(triggered()), this,
 		SLOT(saveConfig()));
-	connect(fileExitAction, SIGNAL(triggered()), this, SLOT(fileExit()));
+	connect(fileExitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
 	connect(networkAddAction, SIGNAL(triggered()), this,
 		SLOT(addNetwork()));
 	connect(networkEditAction, SIGNAL(triggered()), this,
@@ -1214,11 +1222,6 @@
 		showTrayMessage(QSystemTrayIcon::Information, 10, msg);
 }
 
-void WpaGui::fileExit()
-{
-	qApp->quit();
-}
-
 
 void WpaGui::closeEvent(QCloseEvent *event)
 {
@@ -1240,29 +1243,21 @@
 		udr = NULL;
 	}
 
-	if (tray_icon && tray_icon->isVisible()) {
+	if (tray_icon && !ackTrayIcon) {
 		/* give user a visual hint that the tray icon exists */
-		if (!ackTrayIcon && QSystemTrayIcon::supportsMessages()) {
+		if (QSystemTrayIcon::supportsMessages()) {
 			hide();
 			showTrayMessage(QSystemTrayIcon::Information, 3,
 					qAppName() + " will keep running in "
 					"the system tray.");
-		} else if (!ackTrayIcon) {
+		} else {
 			QMessageBox::information(this, qAppName() + " systray",
 						 "The program will keep "
 						 "running in the system "
 						 "tray.");
-			hide();
 		}
-
-		if (ackTrayIcon)
-			hide();
-		else
-			ackTrayIcon = true;
-
-		event->ignore();
-		return;
+		ackTrayIcon = true;
 	}
 
-	qApp->quit();
+	event->accept();
 }
--- a/wpa_supplicant/wpa_gui-qt4/wpagui.h
+++ b/wpa_supplicant/wpa_gui-qt4/wpagui.h
@@ -43,7 +43,6 @@
 	virtual void parse_argv();
 	virtual void updateStatus();
 	virtual void updateNetworks();
-	virtual void fileExit();
 	virtual void helpIndex();
 	virtual void helpContents();
 	virtual void helpAbout();
---


More information about the HostAP mailing list