Mercurial > trustbridge
comparison 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 |
comparison
equal
deleted
inserted
replaced
977:9ad1f18799fb | 978:d92b1594e974 |
---|---|
14 #include <QAbstractButton> | 14 #include <QAbstractButton> |
15 #include <QMainWindow> | 15 #include <QMainWindow> |
16 | 16 |
17 TrayIcon::TrayIcon (QObject *parent) : | 17 TrayIcon::TrayIcon (QObject *parent) : |
18 QSystemTrayIcon (parent), | 18 QSystemTrayIcon (parent), |
19 useAlt(false) | 19 useAlt(false), |
20 mMessageBox(NULL) | |
20 { | 21 { |
21 if (QSystemTrayIcon::isSystemTrayAvailable() && | 22 if (QSystemTrayIcon::isSystemTrayAvailable() && |
22 qgetenv("XDG_CURRENT_DESKTOP") != "Unity") { | 23 qgetenv("XDG_CURRENT_DESKTOP") != "Unity") { |
23 return; | 24 return; |
24 } | 25 } |
39 QSystemTrayIcon::MessageIcon msg_icon, int msecs) { | 40 QSystemTrayIcon::MessageIcon msg_icon, int msecs) { |
40 if (!useAlt) { | 41 if (!useAlt) { |
41 QSystemTrayIcon::showMessage(title, msg, msg_icon, msecs); | 42 QSystemTrayIcon::showMessage(title, msg, msg_icon, msecs); |
42 return; | 43 return; |
43 } | 44 } |
44 QMessageBox *theMessage = new QMessageBox (QMessageBox::Information, | 45 if (!mMessageBox) { |
45 title, msg, QMessageBox::Ok | QMessageBox::No, qobject_cast<QWidget*>(parent())); | 46 mMessageBox = new QMessageBox (QMessageBox::Information, |
46 theMessage->setIconPixmap (icon().pixmap(theMessage->iconPixmap().size())); | 47 title, msg, QMessageBox::Ok | QMessageBox::No, |
47 theMessage->button(QMessageBox::Ok)->setText (tr("Install update")); | 48 qobject_cast<QWidget*>(parent())); |
48 theMessage->button(QMessageBox::No)->setText (tr("Remind me later")); | 49 connect(mMessageBox->button(QMessageBox::Ok), SIGNAL(clicked()), this, SIGNAL(messageClicked())); |
49 connect(theMessage->button(QMessageBox::Ok), SIGNAL(clicked()), this, SIGNAL(messageClicked())); | 50 connect(mMessageBox, SIGNAL(destroyed()), this, SLOT(messageDestroyed())); |
50 theMessage->show(); | 51 } |
52 mMessageBox->setIconPixmap(icon().pixmap(mMessageBox->iconPixmap().size())); | |
53 mMessageBox->setWindowIcon(icon()); | |
54 mMessageBox->button(QMessageBox::Ok)->setText (tr("Install update")); | |
55 mMessageBox->button(QMessageBox::No)->setText (tr("Remind me later")); | |
56 mMessageBox->show(); | |
51 } | 57 } |
58 | |
59 void TrayIcon::messageDestroyed() { | |
60 mMessageBox = NULL; | |
61 } |