| 1 | #include "mainapplication.h" |
| 2 | |
| 3 | #include <QDebug> |
| 4 | |
| 5 | MainApplication::MainApplication(QObject *parent) : |
| 6 | QObject(parent) |
| 7 | { |
| 8 | raopService = new RaopService(0); |
| 9 | trayIconMenu = new QMenu(0); |
| 10 | |
| 11 | // Initialize the service |
| 12 | raopService->init(); |
| 13 | |
| 14 | quitAction = new QAction(tr("&Quit"), trayIconMenu); |
| 15 | connect(quitAction, SIGNAL(triggered()), this, SIGNAL(quitRequested())); |
| 16 | trayIconMenu->addAction(quitAction); |
| 17 | |
| 18 | // Construct the actual system tray icon |
| 19 | trayIcon = new QSystemTrayIcon(this); |
| 20 | trayIcon->setContextMenu(trayIconMenu); |
| 21 | trayIcon->setIcon(QIcon(":icons/airtv.svg")); |
| 22 | } |
| 23 | |
| 24 | MainApplication::~MainApplication() |
| 25 | { |
| 26 | trayIcon->setContextMenu(0); |
| 27 | delete trayIconMenu; |
| 28 | delete raopService; |
| 29 | } |
| 30 | |
| 31 | void MainApplication::start() |
| 32 | { |
| 33 | raopService->start(); |
| 34 | trayIcon->show(); |
| 35 | } |
| 36 | |
| 37 | void MainApplication::stop() |
| 38 | { |
| 39 | raopService->stop(); |
| 40 | trayIcon->hide(); |
| 41 | } |
| 42 | |
| 43 | void MainApplication::aboutToQuit() |
| 44 | { |
| 45 | this->stop(); |
| 46 | } |