From d7a052720a29b649ac37d5a64699cad67631406c Mon Sep 17 00:00:00 2001 From: defnax Date: Tue, 24 Nov 2009 20:17:13 +0000 Subject: [PATCH] moved trayicon to own void function git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1846 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/gui/MainWindow.cpp | 50 ++++++++++++--------------- retroshare-gui/src/gui/MainWindow.h | 2 ++ 2 files changed, 25 insertions(+), 27 deletions(-) diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index 9185b131c..e6a30a0bc 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -266,17 +266,31 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags) /* Create the actions that will go in the tray menu */ createActions(); + /* Creates a tray icon with a context menu and adds it to the system's * notification area. */ + createTrayIcon(); -/****** - * This is an annoying warning I get all the time... - * (no help!) - * - * - if (!QSystemTrayIcon::isSystemTrayAvailable()) - QMessageBox::warning(0, tr("System tray is unavailable"), - tr("System tray unavailable")); -******/ + QTimer *timer = new QTimer(this); + timer->connect(timer, SIGNAL(timeout()), this, SLOT(updateStatus())); + timer->start(1000); +} +/** Destructor. */ +MainWindow::~MainWindow() +{ + delete _bandwidthGraph; + delete _messengerwindowAct; + delete peerstatus; + delete dhtstatus; + delete natstatus; + delete ratesstatus; + delete _settings; + delete applicationWindow; +} + +/** Creates a tray icon with a context menu and adds it to the system + * notification area. */ +void MainWindow::createTrayIcon() +{ /** Tray icon Menu **/ menu = new QMenu(this); QObject::connect(menu, SIGNAL(aboutToShow()), this, SLOT(updateMenu())); @@ -309,26 +323,8 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags) connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(toggleVisibility(QSystemTrayIcon::ActivationReason))); trayIcon->show(); - - QTimer *timer = new QTimer(this); - timer->connect(timer, SIGNAL(timeout()), this, SLOT(updateStatus())); - timer->start(1000); } -/** Destructor. */ -MainWindow::~MainWindow() -{ - delete _bandwidthGraph; - delete _messengerwindowAct; - delete peerstatus; - delete dhtstatus; - delete natstatus; - delete ratesstatus; - delete _settings; - delete applicationWindow; -} - - void MainWindow::displaySystrayMsg(const QString& title,const QString& msg) { trayIcon->showMessage(title, msg, QSystemTrayIcon::Information, 3000); diff --git a/retroshare-gui/src/gui/MainWindow.h b/retroshare-gui/src/gui/MainWindow.h index 168b2a944..100b88f35 100644 --- a/retroshare-gui/src/gui/MainWindow.h +++ b/retroshare-gui/src/gui/MainWindow.h @@ -141,6 +141,8 @@ private: /** Create the actions on the tray menu or menubar */ void createActions(); + + void createTrayIcon(); /** Defines the actions for the tray menu */ QAction* _settingsAct;