summaryrefslogtreecommitdiff
path: root/client/ProxyClientApp.cpp
diff options
context:
space:
mode:
authorAlex <b0ris@b0ris-satellite.localdomain>2011-11-02 14:38:21 +0200
committerAlex <b0ris@b0ris-satellite.localdomain>2011-11-02 14:38:21 +0200
commit19b9a0e1b46399c91872288eba25e1502231df06 (patch)
tree5773d895169fdecf7b56cdb5b40c7d9be66b555d /client/ProxyClientApp.cpp
parent8174d687e6f49b729834fbd2c44d61a045e9cead (diff)
Handle double-click event on system tray icon
Diffstat (limited to 'client/ProxyClientApp.cpp')
-rw-r--r--client/ProxyClientApp.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/client/ProxyClientApp.cpp b/client/ProxyClientApp.cpp
index 030f260..e3a30a9 100644
--- a/client/ProxyClientApp.cpp
+++ b/client/ProxyClientApp.cpp
@@ -1,7 +1,6 @@
-#include <QSystemTrayIcon>
-#include <QMessageBox>
#include <QMenu>
+#include <QMessageBox>
#include "client.h"
#include "Dialog.h"
@@ -13,19 +12,23 @@ ProxyClientApp::ProxyClientApp(int &argc, char *argv[]): QApplication(argc, argv
{
Logger::Fatal("No system tray available! Terminating.\n");
return;
- }
+ }
+
+ /* create system tray menu */
+ QMenu *trayMenu = new QMenu;
QAction *showAction = new QAction(tr("&Show"), this);
showAction->setStatusTip(tr("Open dialog to choose a proxy"));
connect(showAction, SIGNAL(triggered()), this, SLOT(showProxyDialog()));
QAction *quitAction = new QAction(tr("&Quit"), this);
quitAction->setStatusTip(tr("Close this application"));
connect(quitAction, SIGNAL(triggered()), this, SLOT(quitApp()));
- QMenu *trayMenu = new QMenu;
trayMenu->addAction(showAction);
trayMenu->addAction(quitAction);
QIcon *icon = new QIcon("icon.png");
QSystemTrayIcon *trayIcon = new QSystemTrayIcon(*icon);
+ connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
+ this, SLOT(trayActivated(QSystemTrayIcon::ActivationReason)));
trayIcon->setContextMenu(trayMenu);
trayIcon->show();
delete icon;
@@ -33,6 +36,14 @@ ProxyClientApp::ProxyClientApp(int &argc, char *argv[]): QApplication(argc, argv
QApplication::setQuitOnLastWindowClosed(false);
}
+void ProxyClientApp::trayActivated(QSystemTrayIcon::ActivationReason reason)
+{
+ if (reason == QSystemTrayIcon::DoubleClick)
+ {
+ showProxyDialog();
+ }
+}
+
void ProxyClientApp::showProxyDialog()
{
Logger::Trace("Creating proxy dialog.\n");