comparison ui/mainwindow.cpp @ 961:423e31ac656e

Delay the tray icon after the download Otherwise it would show up for a very short time if you close the application after download.
author Andre Heinecke <andre.heinecke@intevation.de>
date Thu, 28 Aug 2014 11:25:55 +0200
parents 879a634d0a40
children 0a4f7235e759
comparison
equal deleted inserted replaced
960:64c0e15935c8 961:423e31ac656e
155 void MainWindow::showMessage() 155 void MainWindow::showMessage()
156 { 156 {
157 if (mCurMessage.isEmpty()) { 157 if (mCurMessage.isEmpty()) {
158 return; 158 return;
159 } 159 }
160 if (mCurState == NewSoftwareAvailable || !isVisible()) { 160
161 if (!mTrayIcon->isVisible() && !mTrayIcon->isAlternative()) {
162 mTrayIcon->show();
163 /* When the message is shown before the tray icon is fully visble
164 * and becoming visible may be delayed on some desktop environments
165 * the message will pop up somehere on the screen and not over
166 * the trayicon. So we delay here.*/
167 QTimer::singleShot(2000, this, SLOT(showMessage()));
168 } else if (mCurState == NewSoftwareAvailable || !isVisible()) {
161 mTrayIcon->showMessage(QApplication::applicationName(), mCurMessage, 169 mTrayIcon->showMessage(QApplication::applicationName(), mCurMessage,
162 QSystemTrayIcon::Information, 10000); 170 QSystemTrayIcon::Information, 10000);
163 mMessageTimer->start(); // Restart the timer so that we don't spam 171 mMessageTimer->start(); // Restart the timer so that we don't spam
164 } 172 }
165 } 173 }
444 void MainWindow::downloaderError(const QString &message, SSLConnection::ErrorCode error) 452 void MainWindow::downloaderError(const QString &message, SSLConnection::ErrorCode error)
445 { 453 {
446 /* TODO logging and handle error according to a plan */ 454 /* TODO logging and handle error according to a plan */
447 syslog_error_printf ("Failed to check for updates: %s", message.toUtf8().constData()); 455 syslog_error_printf ("Failed to check for updates: %s", message.toUtf8().constData());
448 mCurMessage = message; 456 mCurMessage = message;
457 mTrayIcon->show();
449 showMessage(); 458 showMessage();
450 setState(TransferError); 459 setState(TransferError);
451 } 460 }
452 461
453 void MainWindow::createActions() 462 void MainWindow::createActions()
469 mTrayIcon = new TrayIcon(this); 478 mTrayIcon = new TrayIcon(this);
470 mTrayIcon->setContextMenu(mTrayMenu); 479 mTrayIcon->setContextMenu(mTrayMenu);
471 480
472 mTrayIcon->setIcon(trayImg); 481 mTrayIcon->setIcon(trayImg);
473 setWindowIcon(trayImg); 482 setWindowIcon(trayImg);
474 mTrayIcon->show();
475 mTrayIcon->setToolTip(tr("TrustBridge")); 483 mTrayIcon->setToolTip(tr("TrustBridge"));
476 484
477 connect(mTrayIcon, SIGNAL(messageClicked()), this, SLOT(messageClicked())); 485 connect(mTrayIcon, SIGNAL(messageClicked()), this, SLOT(messageClicked()));
478 } 486 }
479 487

http://wald.intevation.org/projects/trustbridge/