wpa_gui-qt4: add support for starting in system tray only
Allow application to be started in the system tray only when started with the `-t' command line argument. Signed-off-by: Kel Modderman <kel@otaku42.de>
This commit is contained in:
parent
66897ae779
commit
fc0db5c916
4 changed files with 27 additions and 10 deletions
|
@ -16,6 +16,7 @@
|
||||||
<command>wpa_gui</command>
|
<command>wpa_gui</command>
|
||||||
<arg>-p <replaceable>path to ctrl sockets</replaceable></arg>
|
<arg>-p <replaceable>path to ctrl sockets</replaceable></arg>
|
||||||
<arg>-i <replaceable>ifname</replaceable></arg>
|
<arg>-i <replaceable>ifname</replaceable></arg>
|
||||||
|
<arg>-t</arg>
|
||||||
</cmdsynopsis>
|
</cmdsynopsis>
|
||||||
</refsynopsisdiv>
|
</refsynopsisdiv>
|
||||||
|
|
||||||
|
@ -48,6 +49,14 @@
|
||||||
configured. By default, choose the first interface found with
|
configured. By default, choose the first interface found with
|
||||||
a control socket in the socket path.</para></listitem>
|
a control socket in the socket path.</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term>-t</term>
|
||||||
|
|
||||||
|
<listitem><para>Start program in the system tray only (if the window
|
||||||
|
manager supports it). By default the main status window is
|
||||||
|
shown.</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
</variablelist>
|
</variablelist>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
<refsect1>
|
<refsect1>
|
||||||
|
|
|
@ -32,7 +32,6 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_NATIVE_WINDOWS */
|
#endif /* CONFIG_NATIVE_WINDOWS */
|
||||||
|
|
||||||
w.show();
|
|
||||||
ret = app.exec();
|
ret = app.exec();
|
||||||
|
|
||||||
#ifdef CONFIG_NATIVE_WINDOWS
|
#ifdef CONFIG_NATIVE_WINDOWS
|
||||||
|
|
|
@ -80,17 +80,20 @@ WpaGui::WpaGui(QWidget *parent, const char *, Qt::WFlags)
|
||||||
scanres = NULL;
|
scanres = NULL;
|
||||||
udr = NULL;
|
udr = NULL;
|
||||||
tray_icon = NULL;
|
tray_icon = NULL;
|
||||||
|
startInTray = false;
|
||||||
ctrl_iface = NULL;
|
ctrl_iface = NULL;
|
||||||
ctrl_conn = NULL;
|
ctrl_conn = NULL;
|
||||||
monitor_conn = NULL;
|
monitor_conn = NULL;
|
||||||
msgNotifier = NULL;
|
msgNotifier = NULL;
|
||||||
ctrl_iface_dir = strdup("/var/run/wpa_supplicant");
|
ctrl_iface_dir = strdup("/var/run/wpa_supplicant");
|
||||||
|
|
||||||
if (QSystemTrayIcon::isSystemTrayAvailable())
|
|
||||||
createTrayIcon();
|
|
||||||
|
|
||||||
parse_argv();
|
parse_argv();
|
||||||
|
|
||||||
|
if (QSystemTrayIcon::isSystemTrayAvailable())
|
||||||
|
createTrayIcon(startInTray);
|
||||||
|
else
|
||||||
|
show();
|
||||||
|
|
||||||
textStatus->setText("connecting to wpa_supplicant");
|
textStatus->setText("connecting to wpa_supplicant");
|
||||||
timer = new QTimer(this);
|
timer = new QTimer(this);
|
||||||
connect(timer, SIGNAL(timeout()), SLOT(ping()));
|
connect(timer, SIGNAL(timeout()), SLOT(ping()));
|
||||||
|
@ -105,9 +108,6 @@ WpaGui::WpaGui(QWidget *parent, const char *, Qt::WFlags)
|
||||||
updateStatus();
|
updateStatus();
|
||||||
networkMayHaveChanged = true;
|
networkMayHaveChanged = true;
|
||||||
updateNetworks();
|
updateNetworks();
|
||||||
|
|
||||||
if (tray_icon)
|
|
||||||
tray_icon->show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -161,7 +161,7 @@ void WpaGui::parse_argv()
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
c = getopt(qApp->argc(), qApp->argv(), "i:p:");
|
c = getopt(qApp->argc(), qApp->argv(), "i:p:t");
|
||||||
if (c < 0)
|
if (c < 0)
|
||||||
break;
|
break;
|
||||||
switch (c) {
|
switch (c) {
|
||||||
|
@ -173,6 +173,9 @@ void WpaGui::parse_argv()
|
||||||
free(ctrl_iface_dir);
|
free(ctrl_iface_dir);
|
||||||
ctrl_iface_dir = strdup(optarg);
|
ctrl_iface_dir = strdup(optarg);
|
||||||
break;
|
break;
|
||||||
|
case 't':
|
||||||
|
startInTray = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1085,7 +1088,7 @@ void WpaGui::selectAdapter( const QString & sel )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void WpaGui::createTrayIcon()
|
void WpaGui::createTrayIcon(bool trayOnly)
|
||||||
{
|
{
|
||||||
QApplication::setQuitOnLastWindowClosed(false);
|
QApplication::setQuitOnLastWindowClosed(false);
|
||||||
|
|
||||||
|
@ -1134,6 +1137,11 @@ void WpaGui::createTrayIcon()
|
||||||
tray_menu->addAction(quitAction);
|
tray_menu->addAction(quitAction);
|
||||||
|
|
||||||
tray_icon->setContextMenu(tray_menu);
|
tray_icon->setContextMenu(tray_menu);
|
||||||
|
|
||||||
|
tray_icon->show();
|
||||||
|
|
||||||
|
if (!trayOnly)
|
||||||
|
show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -100,8 +100,9 @@ private:
|
||||||
QAction *quitAction;
|
QAction *quitAction;
|
||||||
QMenu *tray_menu;
|
QMenu *tray_menu;
|
||||||
QSystemTrayIcon *tray_icon;
|
QSystemTrayIcon *tray_icon;
|
||||||
void createTrayIcon();
|
void createTrayIcon(bool);
|
||||||
bool ackTrayIcon;
|
bool ackTrayIcon;
|
||||||
|
bool startInTray;
|
||||||
|
|
||||||
int openCtrlConnection(const char *ifname);
|
int openCtrlConnection(const char *ifname);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue