#include #include #include #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); }