aboutsummaryrefslogtreecommitdiffstats
path: root/wpa_supplicant
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2009-01-17 11:45:05 (GMT)
committerJouni Malinen <j@w1.fi>2009-02-08 09:51:25 (GMT)
commite4d1cc640574fe8778c6f2519c02cd815e1fcf0b (patch)
tree87589285201e7ac62f21863ac568463216646f56 /wpa_supplicant
parent127eea443af893b5b5cf455e4510b9955b0c400c (diff)
downloadhostap-06-e4d1cc640574fe8778c6f2519c02cd815e1fcf0b.zip
hostap-06-e4d1cc640574fe8778c6f2519c02cd815e1fcf0b.tar.gz
hostap-06-e4d1cc640574fe8778c6f2519c02cd815e1fcf0b.tar.bz2
Save and restore wpa_gui state when session manager restarts the app
This makes wpa_gui remember whether it was only in the tray when the session was terminated and starts only in the tray if session manager restarts it automatically. (cherry picked from commit a5da9c64c9072408f6c736dd666052116d0e6779)
Diffstat (limited to 'wpa_supplicant')
-rw-r--r--wpa_supplicant/wpa_gui-qt4/main.cpp28
-rw-r--r--wpa_supplicant/wpa_gui-qt4/wpagui.cpp32
-rw-r--r--wpa_supplicant/wpa_gui-qt4/wpagui.h6
3 files changed, 59 insertions, 7 deletions
diff --git a/wpa_supplicant/wpa_gui-qt4/main.cpp b/wpa_supplicant/wpa_gui-qt4/main.cpp
index 3ea8cdb..9585e1e 100644
--- a/wpa_supplicant/wpa_gui-qt4/main.cpp
+++ b/wpa_supplicant/wpa_gui-qt4/main.cpp
@@ -18,10 +18,32 @@
#include <QApplication>
#include "wpagui.h"
+
+class WpaGuiApp : public QApplication
+{
+public:
+ WpaGuiApp(int &argc, char **argv);
+
+ virtual void saveState(QSessionManager &manager);
+
+ WpaGui *w;
+};
+
+WpaGuiApp::WpaGuiApp(int &argc, char **argv) : QApplication(argc, argv)
+{
+}
+
+void WpaGuiApp::saveState(QSessionManager &manager)
+{
+ QApplication::saveState(manager);
+ w->saveState();
+}
+
+
int main(int argc, char *argv[])
{
- QApplication app(argc, argv);
- WpaGui w;
+ WpaGuiApp app(argc, argv);
+ WpaGui w(&app);
int ret;
#ifdef CONFIG_NATIVE_WINDOWS
@@ -32,6 +54,8 @@ int main(int argc, char *argv[])
}
#endif /* CONFIG_NATIVE_WINDOWS */
+ app.w = &w;
+
ret = app.exec();
#ifdef CONFIG_NATIVE_WINDOWS
diff --git a/wpa_supplicant/wpa_gui-qt4/wpagui.cpp b/wpa_supplicant/wpa_gui-qt4/wpagui.cpp
index 3efdccb..082166f 100644
--- a/wpa_supplicant/wpa_gui-qt4/wpagui.cpp
+++ b/wpa_supplicant/wpa_gui-qt4/wpagui.cpp
@@ -25,6 +25,7 @@
#include <QMessageBox>
#include <QCloseEvent>
#include <QImageReader>
+#include <QSettings>
#include "wpagui.h"
#include "dirent.h"
@@ -41,8 +42,8 @@ static int wpagui_printf(const char *, ...)
}
#endif
-WpaGui::WpaGui(QWidget *parent, const char *, Qt::WFlags)
- : QMainWindow(parent)
+WpaGui::WpaGui(QApplication *_app, QWidget *parent, const char *, Qt::WFlags)
+ : QMainWindow(parent), app(_app)
{
setupUi(this);
@@ -137,6 +138,15 @@ WpaGui::WpaGui(QWidget *parent, const char *, Qt::WFlags)
parse_argv();
+ if (app->isSessionRestored()) {
+ QSettings settings("wpa_supplicant", "wpa_gui");
+ settings.beginGroup("state");
+ if (app->sessionId().compare(settings.value("session_id").
+ toString()) == 0)
+ startInTray = settings.value("in_tray").toBool();
+ settings.endGroup();
+ }
+
if (QSystemTrayIcon::isSystemTrayAvailable())
createTrayIcon(startInTray);
else
@@ -1294,6 +1304,7 @@ void WpaGui::createTrayIcon(bool trayOnly)
if (!trayOnly)
show();
+ inTray = trayOnly;
}
@@ -1317,10 +1328,13 @@ void WpaGui::trayActivated(QSystemTrayIcon::ActivationReason how)
* custom closeEvent handler take care of children */
case QSystemTrayIcon::Trigger:
ackTrayIcon = true;
- if (isVisible())
+ if (isVisible()) {
close();
- else
+ inTray = true;
+ } else {
show();
+ inTray = false;
+ }
break;
case QSystemTrayIcon::MiddleClick:
showTrayStatus();
@@ -1664,3 +1678,13 @@ void WpaGui::addInterface()
add_iface->show();
add_iface->exec();
}
+
+
+void WpaGui::saveState()
+{
+ QSettings settings("wpa_supplicant", "wpa_gui");
+ settings.beginGroup("state");
+ settings.setValue("session_id", app->sessionId());
+ settings.setValue("in_tray", inTray);
+ settings.endGroup();
+}
diff --git a/wpa_supplicant/wpa_gui-qt4/wpagui.h b/wpa_supplicant/wpa_gui-qt4/wpagui.h
index 1067e42..a533965 100644
--- a/wpa_supplicant/wpa_gui-qt4/wpagui.h
+++ b/wpa_supplicant/wpa_gui-qt4/wpagui.h
@@ -28,7 +28,7 @@ class WpaGui : public QMainWindow, public Ui::WpaGui
Q_OBJECT
public:
- WpaGui(QWidget *parent = 0, const char *name = 0,
+ WpaGui(QApplication *app, QWidget *parent = 0, const char *name = 0,
Qt::WFlags fl = 0);
~WpaGui();
@@ -40,6 +40,7 @@ public:
virtual void disableNetwork(const QString &sel);
virtual int getNetworkDisabled(const QString &sel);
void setBssFromScan(const QString &bssid);
+ void saveState();
public slots:
virtual void parse_argv();
@@ -136,6 +137,9 @@ private:
AddInterface *add_iface;
bool connectedToService;
+
+ QApplication *app;
+ bool inTray;
};
#endif /* WPAGUI_H */