comparison ui/mainwindow.cpp @ 871:4efd6378c001

(issue51) Add fallback in case systemtray is unavailable. If no systemtray is available it will now show a message box as notification.
author Andre Heinecke <andre.heinecke@intevation.de>
date Wed, 06 Aug 2014 18:03:23 +0200
parents 9bab4fc3a1fe
children 1cc85fd3daa5
comparison
equal deleted inserted replaced
870:e93ae5233217 871:4efd6378c001
9 9
10 #include <QDebug> 10 #include <QDebug>
11 #include <QProcess> 11 #include <QProcess>
12 #include <QProgressDialog> 12 #include <QProgressDialog>
13 #include <QMessageBox> 13 #include <QMessageBox>
14 #include <QSystemTrayIcon>
15 #include <QAction> 14 #include <QAction>
16 #include <QDialog> 15 #include <QDialog>
17 #include <QDir> 16 #include <QDir>
18 #include <QMenu> 17 #include <QMenu>
19 #include <QApplication> 18 #include <QApplication>
40 #include "util.h" 39 #include "util.h"
41 #include "logging.h" 40 #include "logging.h"
42 #include "binverify.h" 41 #include "binverify.h"
43 #include "processhelp.h" 42 #include "processhelp.h"
44 #include "processwaitdialog.h" 43 #include "processwaitdialog.h"
44 #include "trayicon.h"
45 45
46 // The amount of time in minutes stay silent if we have 46 // The amount of time in minutes stay silent if we have
47 // something to say 47 // something to say
48 #define NAG_INTERVAL_MINUTES 70 48 #define NAG_INTERVAL_MINUTES 70
49 49
231 * we can go into an endless loop here */ 231 * we can go into an endless loop here */
232 232
233 /* Retry the download again in 10 - 20 minutes */ 233 /* Retry the download again in 10 - 20 minutes */
234 QTimer::singleShot(600000 + (qrand() % 60000), this, SLOT(checkUpdates())); 234 QTimer::singleShot(600000 + (qrand() % 60000), this, SLOT(checkUpdates()));
235 } else { 235 } else {
236 mCurMessage = tr("An updated certificate list is available. Click here to install."); 236 if (mTrayIcon->isAlternative()) {
237 mCurMessage = tr("An updated certificate list is available.");
238 } else {
239 mCurMessage = tr("An updated certificate list is available.") +" " + tr("Click here to install.");
240 }
237 setState(NewListAvailable); 241 setState(NewListAvailable);
238 showMessage(); 242 showMessage();
239 loadCertificateList(); 243 loadCertificateList();
240 } 244 }
241 } 245 }
242 246
243 void MainWindow::handleNewSW(const QString& fileName, const QDateTime& modDate) { 247 void MainWindow::handleNewSW(const QString& fileName, const QDateTime& modDate) {
244 mCurMessage = tr("An update for %1 is available.\n" 248 if (mTrayIcon->isAlternative()) {
245 "Click here to download and install the update.").arg( 249 mCurMessage = tr("An update for %1 is available.").arg(
246 QApplication::applicationName()); 250 QApplication::applicationName());
251 } else {
252 mCurMessage = QString(tr("An update for %1 is available.") + "\n" +
253 tr("Click here to download and install the update.")).arg(
254 QApplication::applicationName());
255 }
247 setState(NewSoftwareAvailable); 256 setState(NewSoftwareAvailable);
248 mSettings.setValue("Software/available", fileName); 257 mSettings.setValue("Software/available", fileName);
249 mSettings.setValue("Software/availableDate", modDate); 258 mSettings.setValue("Software/availableDate", modDate);
250 259
251 mSettings.sync(); 260 mSettings.sync();
435 444
436 mTrayMenu = new QMenu(this); 445 mTrayMenu = new QMenu(this);
437 mTrayMenu->addAction(mCheckUpdates); 446 mTrayMenu->addAction(mCheckUpdates);
438 mTrayMenu->addAction(mQuitAction); 447 mTrayMenu->addAction(mQuitAction);
439 448
440 mTrayIcon = new QSystemTrayIcon(this); 449 mTrayIcon = new TrayIcon(this);
441 mTrayIcon->setContextMenu(mTrayMenu); 450 mTrayIcon->setContextMenu(mTrayMenu);
442 451
443 mTrayIcon->setIcon(trayImg); 452 mTrayIcon->setIcon(trayImg);
444 setWindowIcon(trayImg); 453 setWindowIcon(trayImg);
445 mTrayIcon->show(); 454 mTrayIcon->show();

http://wald.intevation.org/projects/trustbridge/