blob: 030f26009408c706b6d236c05d759be648dd0ea2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
#include <QSystemTrayIcon>
#include <QMessageBox>
#include <QMenu>
#include "client.h"
#include "Dialog.h"
#include "ProxyClientApp.h"
ProxyClientApp::ProxyClientApp(int &argc, char *argv[]): QApplication(argc, argv)
{
if (!QSystemTrayIcon::isSystemTrayAvailable())
{
Logger::Fatal("No system tray available! Terminating.\n");
return;
}
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);
trayIcon->setContextMenu(trayMenu);
trayIcon->show();
delete icon;
QApplication::setQuitOnLastWindowClosed(false);
}
void ProxyClientApp::showProxyDialog()
{
Logger::Trace("Creating proxy dialog.\n");
ProxyDialog *dialog = new ProxyDialog();
dialog->show();
}
void ProxyClientApp::quitApp()
{
Logger::Info("Terminating\n");
QApplication::exit(0);
}
|