Mercurial > trustbridge
comparison ui/mainwindow.cpp @ 1151:22b3daa4e464
Merged
author | Sascha Wilde <wilde@intevation.de> |
---|---|
date | Thu, 18 Sep 2014 13:29:32 +0200 |
parents | 6ec64a30fd5f |
children | 0495f9187c4b |
comparison
equal
deleted
inserted
replaced
1150:a72d59f8c3ea | 1151:22b3daa4e464 |
---|---|
172 * and becoming visible may be delayed on some desktop environments | 172 * and becoming visible may be delayed on some desktop environments |
173 * the message will pop up somehere on the screen and not over | 173 * the message will pop up somehere on the screen and not over |
174 * the trayicon. So we delay here.*/ | 174 * the trayicon. So we delay here.*/ |
175 QTimer::singleShot(2000, this, SLOT(showMessage())); | 175 QTimer::singleShot(2000, this, SLOT(showMessage())); |
176 } else if (mCurState == NewSoftwareAvailable || !isVisible()) { | 176 } else if (mCurState == NewSoftwareAvailable || !isVisible()) { |
177 mTrayIcon->showMessage(QApplication::applicationName(), mCurMessage, | 177 if (mCurState == NewListAvailable) { |
178 QSystemTrayIcon::Information, 10000); | 178 mTrayIcon->showMessage(QApplication::applicationName(), mCurMessage, |
179 QSystemTrayIcon::Information, 10000, | |
180 tr("Show recommendations")); | |
181 } else if (mCurState == NewSoftwareAvailable || !mTrayIcon->isAlternative()) { | |
182 /* Only show new list or new software in alternative as | |
183 * the current tray icon alternative is too invasive for pure | |
184 * informational messages. */ | |
185 mTrayIcon->showMessage(QApplication::applicationName(), mCurMessage, | |
186 QSystemTrayIcon::Information, 10000); | |
187 } | |
179 mMessageTimer->start(); // Restart the timer so that we don't spam | 188 mMessageTimer->start(); // Restart the timer so that we don't spam |
180 } | 189 } |
181 } | 190 } |
182 | 191 |
183 void MainWindow::verifyListData() | 192 void MainWindow::verifyListData() |
537 connect(downloader, SIGNAL(finished()), downloader, SLOT(deleteLater())); | 546 connect(downloader, SIGNAL(finished()), downloader, SLOT(deleteLater())); |
538 connect(downloader, SIGNAL(error(const QString &, SSLConnection::ErrorCode)), | 547 connect(downloader, SIGNAL(error(const QString &, SSLConnection::ErrorCode)), |
539 this, SLOT(downloaderError(const QString &, SSLConnection::ErrorCode))); | 548 this, SLOT(downloaderError(const QString &, SSLConnection::ErrorCode))); |
540 connect(downloader, SIGNAL(lastModifiedDate(const QDateTime&)), | 549 connect(downloader, SIGNAL(lastModifiedDate(const QDateTime&)), |
541 this, SLOT(setLastModifiedSWDate(const QDateTime&))); | 550 this, SLOT(setLastModifiedSWDate(const QDateTime&))); |
551 connect(this, SIGNAL(destroyed(QObject*)), downloader, SLOT(quit)); | |
542 downloader->start(); | 552 downloader->start(); |
543 } | 553 } |
544 | 554 |
545 void MainWindow::setLastModifiedSWDate(const QDateTime &date) | 555 void MainWindow::setLastModifiedSWDate(const QDateTime &date) |
546 { | 556 { |
547 mSettings.beginGroup("Software"); | 557 mSettings.beginGroup("Software"); |
558 #ifdef IS_TAG_BUILD | |
559 /* We accept an invalid date to force installing any avialable update | |
560 * in release mode. Otherwise we default to current datetime when we | |
561 * did not find out version.*/ | |
548 mSettings.setValue("installedDate", date); | 562 mSettings.setValue("installedDate", date); |
563 #else | |
564 mSettings.setValue("installedDate", date.isValid() ? date : QDateTime::currentDateTime()); | |
565 #endif | |
549 mSettings.setValue("installedVersion", QApplication::applicationVersion()); | 566 mSettings.setValue("installedVersion", QApplication::applicationVersion()); |
550 mSettings.endGroup(); | 567 mSettings.endGroup(); |
551 checkUpdates(); | 568 checkUpdates(); |
552 } | 569 } |
553 | 570 |
554 void MainWindow::downloaderError(const QString &message, SSLConnection::ErrorCode error) | 571 void MainWindow::downloaderError(const QString &message, SSLConnection::ErrorCode error) |
555 { | 572 { |
556 /* TODO logging and handle error according to a plan */ | 573 /* TODO logging and handle error according to a plan */ |
557 syslog_error_printf ("Failed to check for updates: %s", message.toUtf8().constData()); | 574 syslog_error_printf ("Failed to check for updates: %s", message.toUtf8().constData()); |
575 #ifdef IS_TAG_BUILD | |
576 /* During tag build it should never happen that an url checked is not available | |
577 * during development this is normal as each revision produces a new url. */ | |
578 setState(TransferError); | |
558 if (!isVisible()) { | 579 if (!isVisible()) { |
559 mCurMessage = message; | 580 mCurMessage = message; |
560 mTrayIcon->show(); | 581 mTrayIcon->show(); |
561 showMessage(); | 582 showMessage(); |
562 } else { | 583 } else { |
563 showErrorMessage(tr("Failed to check for updates:") + "\n" + message); | 584 showErrorMessage(tr("Failed to check for updates:") + "\n" + message); |
564 } | |
565 setState(TransferError); | |
566 | |
567 #ifndef IS_TAG_BUILD | |
568 /* For development versions we default to datetime::now if | |
569 * we can not find our version. */ | |
570 if (!mSettings.contains("Software/installedDate") || | |
571 mSettings.value("Software/installedVersion").toString() != QApplication::applicationVersion()) { | |
572 setLastModifiedSWDate(QDateTime::currentDateTime()); | |
573 } | 585 } |
574 #endif | 586 #endif |
575 } | 587 } |
576 | 588 |
577 void MainWindow::createActions() | 589 void MainWindow::createActions() |
1215 oldInstallCerts.append(cert); | 1227 oldInstallCerts.append(cert); |
1216 QToolButton* actionBtn = new QToolButton(); | 1228 QToolButton* actionBtn = new QToolButton(); |
1217 QIcon btnIcon; | 1229 QIcon btnIcon; |
1218 if (!state) { | 1230 if (!state) { |
1219 btnIcon.addFile(":/img/write-into-48.png", QSize(48, 48), QIcon::Normal, QIcon::Off); | 1231 btnIcon.addFile(":/img/write-into-48.png", QSize(48, 48), QIcon::Normal, QIcon::Off); |
1220 btnIcon.addFile(":/img/security-low.png", QSize(48, 48), QIcon::Normal, QIcon::On); | 1232 btnIcon.addFile(":/img/cert-not-installed-bad-48.png", QSize(48, 48), QIcon::Normal, QIcon::On); |
1221 actionBtn->setProperty("ToolTip_Off", tr("Certificate will be installed.")); | 1233 actionBtn->setProperty("ToolTip_Off", tr("Certificate will be installed.")); |
1222 actionBtn->setProperty("ToolTip_On", tr("Certifcate is not installed.")); | 1234 actionBtn->setProperty("ToolTip_On", tr("Certifcate is not installed.")); |
1223 } else { | 1235 } else { |
1224 actionBtn->setProperty("ToolTip_Off", tr("Certificate is installed.")); | 1236 actionBtn->setProperty("ToolTip_Off", tr("Certificate is installed.")); |
1225 actionBtn->setProperty("ToolTip_On", tr("Certificate will be removed.")); | 1237 actionBtn->setProperty("ToolTip_On", tr("Certificate will be removed.")); |
1226 btnIcon.addFile(":/img/security-high.png", QSize(48, 48), QIcon::Normal, QIcon::Off); | 1238 btnIcon.addFile(":/img/cert-is-installed-good-48.png", QSize(48, 48), QIcon::Normal, QIcon::Off); |
1227 btnIcon.addFile(":/img/write-remove-48.png", QSize(48, 48), QIcon::Normal, QIcon::On); | 1239 btnIcon.addFile(":/img/write-remove-48.png", QSize(48, 48), QIcon::Normal, QIcon::On); |
1228 } | 1240 } |
1229 actionBtn->setIcon(btnIcon); | 1241 actionBtn->setIcon(btnIcon); |
1230 mInstallList->addCertificate(cert, state, actionBtn); | 1242 mInstallList->addCertificate(cert, state, actionBtn); |
1231 } | 1243 } |
1234 QToolButton* actionBtn = new QToolButton(); | 1246 QToolButton* actionBtn = new QToolButton(); |
1235 QIcon btnIcon; | 1247 QIcon btnIcon; |
1236 actionBtn->setProperty("ToolTip_Off", tr("Certificate will be removed.")); | 1248 actionBtn->setProperty("ToolTip_Off", tr("Certificate will be removed.")); |
1237 actionBtn->setProperty("ToolTip_On", tr("Certificate has not been removed.")); | 1249 actionBtn->setProperty("ToolTip_On", tr("Certificate has not been removed.")); |
1238 btnIcon.addFile(":/img/write-remove-48.png", QSize(48, 48), QIcon::Normal, QIcon::Off); | 1250 btnIcon.addFile(":/img/write-remove-48.png", QSize(48, 48), QIcon::Normal, QIcon::Off); |
1239 btnIcon.addFile(":/img/security-medium.png", QSize(48, 48), QIcon::Normal, QIcon::On); | 1251 btnIcon.addFile(":/img/cert-is-installed-bad-48.png", QSize(48, 48), QIcon::Normal, QIcon::On); |
1240 btnIcon.addFile(":/img/trash-empty.png", QSize(48, 48), QIcon::Disabled, QIcon::Off); | 1252 btnIcon.addFile(":/img/cert-not-installed-good-48.png", QSize(48, 48), QIcon::Disabled, QIcon::Off); |
1241 actionBtn->setIcon(btnIcon); | 1253 actionBtn->setIcon(btnIcon); |
1242 if (state) { | 1254 if (state) { |
1243 actionBtn->setEnabled(false); | 1255 actionBtn->setEnabled(false); |
1244 actionBtn->setToolTip(tr("Certificate has been removed.")); | 1256 actionBtn->setToolTip(tr("Certificate has been removed.")); |
1245 } | 1257 } |
1258 oldInstallCerts.append(cert); | 1270 oldInstallCerts.append(cert); |
1259 QToolButton* actionBtn = new QToolButton(); | 1271 QToolButton* actionBtn = new QToolButton(); |
1260 QIcon btnIcon; | 1272 QIcon btnIcon; |
1261 actionBtn->setProperty("ToolTip_Off", tr("Certificate is installed.")); | 1273 actionBtn->setProperty("ToolTip_Off", tr("Certificate is installed.")); |
1262 actionBtn->setProperty("ToolTip_On", tr("Certifcate is not installed.")); | 1274 actionBtn->setProperty("ToolTip_On", tr("Certifcate is not installed.")); |
1263 btnIcon.addFile(":/img/security-high.png", QSize(48, 48), QIcon::Normal, QIcon::Off); | 1275 btnIcon.addFile(":/img/cert-is-installed-good-48.png", QSize(48, 48), QIcon::Normal, QIcon::Off); |
1264 btnIcon.addFile(":/img/security-low.png", QSize(48, 48), QIcon::Normal, QIcon::On); | 1276 btnIcon.addFile(":/img/cert-not-installed-bad-48.png", QSize(48, 48), QIcon::Normal, QIcon::On); |
1265 actionBtn->setIcon(btnIcon); | 1277 actionBtn->setIcon(btnIcon); |
1266 mInstallList->addCertificate(cert, state, actionBtn); | 1278 mInstallList->addCertificate(cert, state, actionBtn); |
1267 } | 1279 } |
1268 else { | 1280 else { |
1269 // Is a brand new certificate | 1281 // Is a brand new certificate |
1271 QToolButton* actionBtn = new QToolButton(); | 1283 QToolButton* actionBtn = new QToolButton(); |
1272 QIcon btnIcon; | 1284 QIcon btnIcon; |
1273 actionBtn->setProperty("ToolTip_Off", tr("Certificate will be installed.")); | 1285 actionBtn->setProperty("ToolTip_Off", tr("Certificate will be installed.")); |
1274 actionBtn->setProperty("ToolTip_On", tr("Certificate will not be installed.")); | 1286 actionBtn->setProperty("ToolTip_On", tr("Certificate will not be installed.")); |
1275 btnIcon.addFile(":/img/write-into-48.png", QSize(48, 48), QIcon::Normal, QIcon::Off); | 1287 btnIcon.addFile(":/img/write-into-48.png", QSize(48, 48), QIcon::Normal, QIcon::Off); |
1276 btnIcon.addFile(":/img/security-low.png", QSize(48, 48), QIcon::Normal, QIcon::On); | 1288 btnIcon.addFile(":/img/cert-not-installed-bad-48.png", QSize(48, 48), QIcon::Normal, QIcon::On); |
1277 actionBtn->setIcon(btnIcon); | 1289 actionBtn->setIcon(btnIcon); |
1278 mUpdatesNew->addCertificate(cert, state, actionBtn); | 1290 mUpdatesNew->addCertificate(cert, state, actionBtn); |
1279 } | 1291 } |
1280 } | 1292 } |
1281 else { | 1293 else { |
1287 QToolButton* actionBtn = new QToolButton(); | 1299 QToolButton* actionBtn = new QToolButton(); |
1288 QIcon btnIcon; | 1300 QIcon btnIcon; |
1289 actionBtn->setProperty("ToolTip_Off", tr("Certificate will be removed.")); | 1301 actionBtn->setProperty("ToolTip_Off", tr("Certificate will be removed.")); |
1290 actionBtn->setProperty("ToolTip_On", tr("Certificate has not been removed.")); | 1302 actionBtn->setProperty("ToolTip_On", tr("Certificate has not been removed.")); |
1291 btnIcon.addFile(":/img/write-remove-48.png", QSize(48, 48), QIcon::Normal, QIcon::Off); | 1303 btnIcon.addFile(":/img/write-remove-48.png", QSize(48, 48), QIcon::Normal, QIcon::Off); |
1292 btnIcon.addFile(":/img/security-medium.png", QSize(48, 48), QIcon::Normal, QIcon::On); | 1304 btnIcon.addFile(":/img/cert-is-installed-bad-48.png", QSize(48, 48), QIcon::Normal, QIcon::On); |
1293 btnIcon.addFile(":/img/trash-empty.png", QSize(48, 48), QIcon::Disabled, QIcon::Off); | 1305 btnIcon.addFile(":/img/cert-not-installed-good-48.png", QSize(48, 48), QIcon::Disabled, QIcon::Off); |
1294 actionBtn->setIcon(btnIcon); | 1306 actionBtn->setIcon(btnIcon); |
1295 if (state) { | 1307 if (state) { |
1296 actionBtn->setEnabled(false); | 1308 actionBtn->setEnabled(false); |
1297 actionBtn->setToolTip(tr("Certificate has been removed.")); | 1309 actionBtn->setToolTip(tr("Certificate has been removed.")); |
1298 } | 1310 } |
1305 QToolButton* actionBtn = new QToolButton(); | 1317 QToolButton* actionBtn = new QToolButton(); |
1306 QIcon btnIcon; | 1318 QIcon btnIcon; |
1307 actionBtn->setProperty("ToolTip_Off", tr("Certificate will be removed.")); | 1319 actionBtn->setProperty("ToolTip_Off", tr("Certificate will be removed.")); |
1308 actionBtn->setProperty("ToolTip_On", tr("Certificate will not be removed.")); | 1320 actionBtn->setProperty("ToolTip_On", tr("Certificate will not be removed.")); |
1309 btnIcon.addFile(":/img/write-remove-48.png", QSize(48, 48), QIcon::Normal, QIcon::Off); | 1321 btnIcon.addFile(":/img/write-remove-48.png", QSize(48, 48), QIcon::Normal, QIcon::Off); |
1310 btnIcon.addFile(":/img/security-medium.png", QSize(48, 48), QIcon::Normal, QIcon::On); | 1322 btnIcon.addFile(":/img/cert-is-installed-bad-48.png", QSize(48, 48), QIcon::Normal, QIcon::On); |
1311 actionBtn->setIcon(btnIcon); | 1323 actionBtn->setIcon(btnIcon); |
1312 mUpdatesRemove->addCertificate(cert, state, actionBtn); | 1324 mUpdatesRemove->addCertificate(cert, state, actionBtn); |
1313 } | 1325 } |
1314 } | 1326 } |
1315 } | 1327 } |