Mercurial > trustbridge
diff ui/trayicon.cpp @ 978:d92b1594e974
Merged.
author | Emanuel Schuetze <emanuel@intevation.de> |
---|---|
date | Fri, 29 Aug 2014 13:10:11 +0200 |
parents | c80777457133 |
children | a4282bc67a8b |
line wrap: on
line diff
--- a/ui/trayicon.cpp Fri Aug 29 13:09:40 2014 +0200 +++ b/ui/trayicon.cpp Fri Aug 29 13:10:11 2014 +0200 @@ -16,7 +16,8 @@ TrayIcon::TrayIcon (QObject *parent) : QSystemTrayIcon (parent), - useAlt(false) + useAlt(false), + mMessageBox(NULL) { if (QSystemTrayIcon::isSystemTrayAvailable() && qgetenv("XDG_CURRENT_DESKTOP") != "Unity") { @@ -41,11 +42,20 @@ QSystemTrayIcon::showMessage(title, msg, msg_icon, msecs); return; } - QMessageBox *theMessage = new QMessageBox (QMessageBox::Information, - title, msg, QMessageBox::Ok | QMessageBox::No, qobject_cast<QWidget*>(parent())); - theMessage->setIconPixmap (icon().pixmap(theMessage->iconPixmap().size())); - theMessage->button(QMessageBox::Ok)->setText (tr("Install update")); - theMessage->button(QMessageBox::No)->setText (tr("Remind me later")); - connect(theMessage->button(QMessageBox::Ok), SIGNAL(clicked()), this, SIGNAL(messageClicked())); - theMessage->show(); + if (!mMessageBox) { + mMessageBox = new QMessageBox (QMessageBox::Information, + title, msg, QMessageBox::Ok | QMessageBox::No, + qobject_cast<QWidget*>(parent())); + connect(mMessageBox->button(QMessageBox::Ok), SIGNAL(clicked()), this, SIGNAL(messageClicked())); + connect(mMessageBox, SIGNAL(destroyed()), this, SLOT(messageDestroyed())); + } + mMessageBox->setIconPixmap(icon().pixmap(mMessageBox->iconPixmap().size())); + mMessageBox->setWindowIcon(icon()); + mMessageBox->button(QMessageBox::Ok)->setText (tr("Install update")); + mMessageBox->button(QMessageBox::No)->setText (tr("Remind me later")); + mMessageBox->show(); } + +void TrayIcon::messageDestroyed() { + mMessageBox = NULL; +}