[PATCH] (Issue25) Log update check success, change header labels
Wald Commits
scm-commit at wald.intevation.org
Wed Jul 2 12:49:52 CEST 2014
# HG changeset patch
# User Andre Heinecke <andre.heinecke at intevation.de>
# Date 1404298151 -7200
# Node ID bd48fae793b603348e2e24e51fd1e7b529f16213
# Parent 37899f717fa5bb166ddefa588fced3536e038f17
(Issue25) Log update check success, change header labels.
diff -r 37899f717fa5 -r bd48fae793b6 ui/mainwindow.cpp
--- a/ui/mainwindow.cpp Wed Jul 02 12:39:28 2014 +0200
+++ b/ui/mainwindow.cpp Wed Jul 02 12:49:11 2014 +0200
@@ -345,14 +345,17 @@
connect(downloader, SIGNAL(newListAvailable(const QString&, const QDateTime&)),
this, SLOT(handleNewList(const QString&, const QDateTime&)));
if (!downloadSW) {
+ setState(BeforeDownload);
connect(downloader, SIGNAL(newSoftwareAvailable(const QString&, const QDateTime&)),
this, SLOT(handleNewSW(const QString&, const QDateTime&)));
} else {
+ setState(DownloadingSW);
connect(downloader, SIGNAL(newSoftwareAvailable(const QString&, const QDateTime&)),
this, SLOT(installNewSW(const QString&, const QDateTime&)));
}
connect(downloader, SIGNAL(finished()), downloader, SLOT(deleteLater()));
+ connect(downloader, SIGNAL(finished()), this, SLOT(updateCheckSuccess()));
connect(downloader, SIGNAL(error(const QString &, SSLConnection::ErrorCode)),
this, SLOT(downloaderError(const QString &, SSLConnection::ErrorCode)));
downloader->start();
@@ -393,6 +396,7 @@
void MainWindow::downloaderError(const QString &message, SSLConnection::ErrorCode error)
{
/* TODO logging and handle error according to a plan */
+ syslog_error_printf ("Failed to check for updates: %s", message.toUtf8().constData());
mCurMessage = message;
showMessage();
setState(TransferError);
@@ -535,16 +539,27 @@
mUpdatesHeader =
new QLabel("<h2>" + tr("Certificates unchanged")+ "</h2>");
mLastCertUpdate =
- new QLabel(tr("Last update of certificates: %1").arg(""));
- mLastSWupdate =
- new QLabel(tr("Last update of TrustBridge: %1").arg(""));
+ new QLabel("");
+ mLastCertUpdate->hide();
+ mSoftwareVersionLabel =
+ new QLabel(tr("TrustBridge Version: %1").arg(QApplication::applicationVersion()));
+ const QDateTime lastCheck = mSettings.value("lastUpdateCheck").toDateTime();
+ if (lastCheck.isValid()) {
+ const QString lastUpdateCheck = QLocale::system().toString(lastCheck);
+ mLastUpdateCheck =
+ new QLabel(tr("Last sucessful update check: %1").arg(lastUpdateCheck));
+ } else {
+ mLastUpdateCheck = new QLabel("");
+ mLastUpdateCheck->hide();
+ }
QLabel *updatesTip =
new QLabel(tr("You should apply the following changes to your root certificates:"));
updatesTip->setWordWrap(true);
updatesHeaderTextLayout->addWidget(mUpdatesHeader);
updatesHeaderTextLayout->addWidget(mLastCertUpdate);
- updatesHeaderTextLayout->addWidget(mLastSWupdate);
+ updatesHeaderTextLayout->addWidget(mLastUpdateCheck);
+ updatesHeaderTextLayout->addWidget(mSoftwareVersionLabel);
updatesHeaderTextLayout->addSpacing(10);
updatesHeaderTextLayout->addWidget(updatesTip);
@@ -912,8 +927,11 @@
}
}
- mLastCertUpdate->setText(tr("Last update of certificates: %1")
- .arg(mInstalledList.date().toString()));
+ if (mInstalledList.date().isValid()) {
+ mLastCertUpdate->setText(tr("Installed certificates from: %1")
+ .arg(QLocale::system().toString(mInstalledList.date())));
+ mLastCertUpdate->show();
+ }
mUpdatesManualCertificates->setText("<h3>" +
tr("Manually changed certificates (%1)").arg(0) +
"</h3>");
@@ -1159,3 +1177,15 @@
}
return closeApp();
}
+
+void MainWindow::updateCheckSuccess()
+{
+ if (getState() != TransferError) {
+ const QDateTime now = QDateTime::currentDateTime();
+ mSettings.setValue("lastUpdateCheck", now);
+ mLastUpdateCheck->setText(tr("Last sucessful update check: %1").arg(
+ QLocale::system().toString(now)));
+ mLastUpdateCheck->show();
+ syslog_info_printf(tr("Sucessfully checked for updates.").toUtf8().constData());
+ }
+}
diff -r 37899f717fa5 -r bd48fae793b6 ui/mainwindow.h
--- a/ui/mainwindow.h Wed Jul 02 12:39:28 2014 +0200
+++ b/ui/mainwindow.h Wed Jul 02 12:49:11 2014 +0200
@@ -130,6 +130,13 @@
*/
void loadUnselectedCertificates();
+ /** @brief log / store a successful downloader run
+ *
+ * A downloader run is successful if the finished signal
+ * is emited and the state is not TransferError
+ */
+ void updateCheckSuccess();
+
protected:
virtual void closeEvent(QCloseEvent *event);
@@ -209,7 +216,8 @@
QLabel *mUpdatesHeader;
QLabel *mLastCertUpdate;
- QLabel *mLastSWupdate;
+ QLabel *mSoftwareVersionLabel;
+ QLabel *mLastUpdateCheck;
QLabel *mUpdatesNewCertificates;
QLabel *mUpdatesRemoveCertificates;
QLabel *mUpdatesManualCertificates;
More information about the Trustbridge-commits
mailing list