diff options
author | Alex Borisov <borisov.alexandr@rambler.ru> | 2011-10-23 04:10:55 +0300 |
---|---|---|
committer | Alex Borisov <borisov.alexandr@rambler.ru> | 2011-10-23 04:10:55 +0300 |
commit | 21ad7eac963bc329395fa893300fb5c8f721fd77 (patch) | |
tree | 10dda6e6170071332aab490faeeb599f10ff6e03 /client/ProxyClientApp.cpp | |
parent | 3eef0376635624c354a5e1b8a2680b74eb23a423 (diff) |
Logging facility, Config class, tray icon, custom QApplication subclass
Diffstat (limited to 'client/ProxyClientApp.cpp')
-rw-r--r-- | client/ProxyClientApp.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/client/ProxyClientApp.cpp b/client/ProxyClientApp.cpp new file mode 100644 index 0000000..030f260 --- /dev/null +++ b/client/ProxyClientApp.cpp @@ -0,0 +1,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); +} |