Updater: Do a tray notification if a new update is available.

This commit is contained in:
Klaas Freitag 2015-06-03 20:43:31 +02:00
parent 5b65bbf8e5
commit c8cb604c18
4 changed files with 23 additions and 5 deletions

View file

@ -34,6 +34,8 @@
#include "sharedialog.h"
#include "updater/updater.h"
#include "updater/ocupdater.h"
#include "creds/abstractcredentials.h"
#include "config.h"
@ -253,8 +255,24 @@ void Application::slotStartUpdateDetector()
if( cfg.skipUpdateCheck() ) {
qDebug() << Q_FUNC_INFO << "Skipping update check because of config file";
} else {
Updater *updater = Updater::instance();
updater->backgroundCheckForUpdate();
if (OCUpdater *updater = dynamic_cast<OCUpdater*>(Updater::instance())) {
connect(updater, SIGNAL(downloadStateChanged()), this,
SLOT(slotNotifyAboutAvailableUpdate()), Qt::UniqueConnection);
updater->backgroundCheckForUpdate();
}
}
}
void Application::slotNotifyAboutAvailableUpdate()
{
if( _gui ) {
if (OCUpdater *updater = dynamic_cast<OCUpdater*>(Updater::instance())) {
// Show a tray message if an Update is ready...
if( updater->downloadState() == OCUpdater::DownloadComplete ) {
_gui->slotShowTrayMessage( tr("Update Check"), updater->statusString() );
}
}
}
}

View file

@ -84,6 +84,7 @@ protected slots:
void slotAccountStateRemoved(AccountState *accountState);
void slotAccountStateChanged(int state);
void slotCrash();
void slotNotifyAboutAvailableUpdate();
private:
void setHelp();

View file

@ -85,8 +85,7 @@ void GeneralSettings::loadMiscSettings()
void GeneralSettings::slotUpdateInfo()
{
if (OCUpdater *updater = dynamic_cast<OCUpdater*>(Updater::instance()))
{
if (OCUpdater *updater = dynamic_cast<OCUpdater*>(Updater::instance())) {
connect(updater, SIGNAL(downloadStateChanged()), SLOT(slotUpdateInfo()), Qt::UniqueConnection);
connect(_ui->restartButton, SIGNAL(clicked()), updater, SLOT(slotStartInstaller()), Qt::UniqueConnection);
connect(_ui->restartButton, SIGNAL(clicked()), qApp, SLOT(quit()), Qt::UniqueConnection);

View file

@ -69,7 +69,7 @@ void OCUpdater::backgroundCheckForUpdate()
if( dlState == Unknown ||
dlState == UpToDate ||
dlState == DownloadComplete ||
/* dlState == DownloadComplete || <- are we checking if a previous download was successful already? */
dlState == DownloadFailed ||
dlState == DownloadTimedOut ) {
// how about UpdateOnlyAvailableThroughSystem?