Mercurial > trustbridge
diff 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 |
line wrap: on
line diff
--- a/ui/mainwindow.cpp Wed Aug 06 11:55:02 2014 +0200 +++ b/ui/mainwindow.cpp Wed Aug 06 18:03:23 2014 +0200 @@ -11,7 +11,6 @@ #include <QProcess> #include <QProgressDialog> #include <QMessageBox> -#include <QSystemTrayIcon> #include <QAction> #include <QDialog> #include <QDir> @@ -42,6 +41,7 @@ #include "binverify.h" #include "processhelp.h" #include "processwaitdialog.h" +#include "trayicon.h" // The amount of time in minutes stay silent if we have // something to say @@ -233,7 +233,11 @@ /* Retry the download again in 10 - 20 minutes */ QTimer::singleShot(600000 + (qrand() % 60000), this, SLOT(checkUpdates())); } else { - mCurMessage = tr("An updated certificate list is available. Click here to install."); + if (mTrayIcon->isAlternative()) { + mCurMessage = tr("An updated certificate list is available."); + } else { + mCurMessage = tr("An updated certificate list is available.") +" " + tr("Click here to install."); + } setState(NewListAvailable); showMessage(); loadCertificateList(); @@ -241,9 +245,14 @@ } void MainWindow::handleNewSW(const QString& fileName, const QDateTime& modDate) { - mCurMessage = tr("An update for %1 is available.\n" - "Click here to download and install the update.").arg( + if (mTrayIcon->isAlternative()) { + mCurMessage = tr("An update for %1 is available.").arg( QApplication::applicationName()); + } else { + mCurMessage = QString(tr("An update for %1 is available.") + "\n" + + tr("Click here to download and install the update.")).arg( + QApplication::applicationName()); + } setState(NewSoftwareAvailable); mSettings.setValue("Software/available", fileName); mSettings.setValue("Software/availableDate", modDate); @@ -437,7 +446,7 @@ mTrayMenu->addAction(mCheckUpdates); mTrayMenu->addAction(mQuitAction); - mTrayIcon = new QSystemTrayIcon(this); + mTrayIcon = new TrayIcon(this); mTrayIcon->setContextMenu(mTrayMenu); mTrayIcon->setIcon(trayImg);