Mercurial > trustbridge
comparison ui/mainwindow.cpp @ 708:bd48fae793b6
(Issue25) Log update check success, change header labels.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Wed, 02 Jul 2014 12:49:11 +0200 |
parents | 2c63bb63de76 |
children | 8f110e6b8295 |
comparison
equal
deleted
inserted
replaced
707:37899f717fa5 | 708:bd48fae793b6 |
---|---|
343 downloadSW); | 343 downloadSW); |
344 | 344 |
345 connect(downloader, SIGNAL(newListAvailable(const QString&, const QDateTime&)), | 345 connect(downloader, SIGNAL(newListAvailable(const QString&, const QDateTime&)), |
346 this, SLOT(handleNewList(const QString&, const QDateTime&))); | 346 this, SLOT(handleNewList(const QString&, const QDateTime&))); |
347 if (!downloadSW) { | 347 if (!downloadSW) { |
348 setState(BeforeDownload); | |
348 connect(downloader, SIGNAL(newSoftwareAvailable(const QString&, const QDateTime&)), | 349 connect(downloader, SIGNAL(newSoftwareAvailable(const QString&, const QDateTime&)), |
349 this, SLOT(handleNewSW(const QString&, const QDateTime&))); | 350 this, SLOT(handleNewSW(const QString&, const QDateTime&))); |
350 } else { | 351 } else { |
352 setState(DownloadingSW); | |
351 connect(downloader, SIGNAL(newSoftwareAvailable(const QString&, const QDateTime&)), | 353 connect(downloader, SIGNAL(newSoftwareAvailable(const QString&, const QDateTime&)), |
352 this, SLOT(installNewSW(const QString&, const QDateTime&))); | 354 this, SLOT(installNewSW(const QString&, const QDateTime&))); |
353 } | 355 } |
354 | 356 |
355 connect(downloader, SIGNAL(finished()), downloader, SLOT(deleteLater())); | 357 connect(downloader, SIGNAL(finished()), downloader, SLOT(deleteLater())); |
358 connect(downloader, SIGNAL(finished()), this, SLOT(updateCheckSuccess())); | |
356 connect(downloader, SIGNAL(error(const QString &, SSLConnection::ErrorCode)), | 359 connect(downloader, SIGNAL(error(const QString &, SSLConnection::ErrorCode)), |
357 this, SLOT(downloaderError(const QString &, SSLConnection::ErrorCode))); | 360 this, SLOT(downloaderError(const QString &, SSLConnection::ErrorCode))); |
358 downloader->start(); | 361 downloader->start(); |
359 } | 362 } |
360 | 363 |
391 } | 394 } |
392 | 395 |
393 void MainWindow::downloaderError(const QString &message, SSLConnection::ErrorCode error) | 396 void MainWindow::downloaderError(const QString &message, SSLConnection::ErrorCode error) |
394 { | 397 { |
395 /* TODO logging and handle error according to a plan */ | 398 /* TODO logging and handle error according to a plan */ |
399 syslog_error_printf ("Failed to check for updates: %s", message.toUtf8().constData()); | |
396 mCurMessage = message; | 400 mCurMessage = message; |
397 showMessage(); | 401 showMessage(); |
398 setState(TransferError); | 402 setState(TransferError); |
399 } | 403 } |
400 | 404 |
533 QHBoxLayout *updatesHeaderSearchLayout = new QHBoxLayout; | 537 QHBoxLayout *updatesHeaderSearchLayout = new QHBoxLayout; |
534 | 538 |
535 mUpdatesHeader = | 539 mUpdatesHeader = |
536 new QLabel("<h2>" + tr("Certificates unchanged")+ "</h2>"); | 540 new QLabel("<h2>" + tr("Certificates unchanged")+ "</h2>"); |
537 mLastCertUpdate = | 541 mLastCertUpdate = |
538 new QLabel(tr("Last update of certificates: %1").arg("")); | 542 new QLabel(""); |
539 mLastSWupdate = | 543 mLastCertUpdate->hide(); |
540 new QLabel(tr("Last update of TrustBridge: %1").arg("")); | 544 mSoftwareVersionLabel = |
545 new QLabel(tr("TrustBridge Version: %1").arg(QApplication::applicationVersion())); | |
546 const QDateTime lastCheck = mSettings.value("lastUpdateCheck").toDateTime(); | |
547 if (lastCheck.isValid()) { | |
548 const QString lastUpdateCheck = QLocale::system().toString(lastCheck); | |
549 mLastUpdateCheck = | |
550 new QLabel(tr("Last sucessful update check: %1").arg(lastUpdateCheck)); | |
551 } else { | |
552 mLastUpdateCheck = new QLabel(""); | |
553 mLastUpdateCheck->hide(); | |
554 } | |
541 QLabel *updatesTip = | 555 QLabel *updatesTip = |
542 new QLabel(tr("You should apply the following changes to your root certificates:")); | 556 new QLabel(tr("You should apply the following changes to your root certificates:")); |
543 updatesTip->setWordWrap(true); | 557 updatesTip->setWordWrap(true); |
544 | 558 |
545 updatesHeaderTextLayout->addWidget(mUpdatesHeader); | 559 updatesHeaderTextLayout->addWidget(mUpdatesHeader); |
546 updatesHeaderTextLayout->addWidget(mLastCertUpdate); | 560 updatesHeaderTextLayout->addWidget(mLastCertUpdate); |
547 updatesHeaderTextLayout->addWidget(mLastSWupdate); | 561 updatesHeaderTextLayout->addWidget(mLastUpdateCheck); |
562 updatesHeaderTextLayout->addWidget(mSoftwareVersionLabel); | |
548 updatesHeaderTextLayout->addSpacing(10); | 563 updatesHeaderTextLayout->addSpacing(10); |
549 updatesHeaderTextLayout->addWidget(updatesTip); | 564 updatesHeaderTextLayout->addWidget(updatesTip); |
550 | 565 |
551 QPushButton *searchUpdates = new QPushButton(" " + tr("Check for updates")); | 566 QPushButton *searchUpdates = new QPushButton(" " + tr("Check for updates")); |
552 searchUpdates->setIcon(QIcon(":/img/edit-find.png")); | 567 searchUpdates->setIcon(QIcon(":/img/edit-find.png")); |
910 } | 925 } |
911 } | 926 } |
912 } | 927 } |
913 } | 928 } |
914 | 929 |
915 mLastCertUpdate->setText(tr("Last update of certificates: %1") | 930 if (mInstalledList.date().isValid()) { |
916 .arg(mInstalledList.date().toString())); | 931 mLastCertUpdate->setText(tr("Installed certificates from: %1") |
932 .arg(QLocale::system().toString(mInstalledList.date()))); | |
933 mLastCertUpdate->show(); | |
934 } | |
917 mUpdatesManualCertificates->setText("<h3>" + | 935 mUpdatesManualCertificates->setText("<h3>" + |
918 tr("Manually changed certificates (%1)").arg(0) + | 936 tr("Manually changed certificates (%1)").arg(0) + |
919 "</h3>"); | 937 "</h3>"); |
920 listChanged(0); | 938 listChanged(0); |
921 } | 939 } |
1157 QMainWindow::closeEvent(event); | 1175 QMainWindow::closeEvent(event); |
1158 return; | 1176 return; |
1159 } | 1177 } |
1160 return closeApp(); | 1178 return closeApp(); |
1161 } | 1179 } |
1180 | |
1181 void MainWindow::updateCheckSuccess() | |
1182 { | |
1183 if (getState() != TransferError) { | |
1184 const QDateTime now = QDateTime::currentDateTime(); | |
1185 mSettings.setValue("lastUpdateCheck", now); | |
1186 mLastUpdateCheck->setText(tr("Last sucessful update check: %1").arg( | |
1187 QLocale::system().toString(now))); | |
1188 mLastUpdateCheck->show(); | |
1189 syslog_info_printf(tr("Sucessfully checked for updates.").toUtf8().constData()); | |
1190 } | |
1191 } |