#include #include #include "client.h" #include "Dialog.h" #include "ProxyClientApp.h" #include "UpdatedConfig.h" ProxyClientApp::ProxyClientApp(int &argc, char *argv[]): QApplication(argc, argv) { /* initiates UpdatedConfig singleton that start sending configuration requests */ UpdatedConfig *cfg = UpdatedConfig::CurrentConfig(); if (!QSystemTrayIcon::isSystemTrayAvailable()) { 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())); trayMenu->addAction(showAction); trayMenu->addAction(quitAction); QIcon *icon = new QIcon(":/icon.png"); trayIcon = new QSystemTrayIcon(*icon); connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(trayActivated(QSystemTrayIcon::ActivationReason))); trayIcon->setContextMenu(trayMenu); trayIcon->show(); delete icon; QApplication::setQuitOnLastWindowClosed(false); } void ProxyClientApp::trayActivated(QSystemTrayIcon::ActivationReason reason) { if (reason == QSystemTrayIcon::DoubleClick) { showProxyDialog(); } } void ProxyClientApp::showProxyDialog() { Logger::Trace("Creating proxy dialog.\n"); ProxyDialog *dialog = new ProxyDialog(); dialog->show(); } void ProxyClientApp::quitApp() { Logger::Info("Terminating\n"); trayIcon->hide(); QApplication::exit(0); }