comparison ui/trayicon.cpp @ 969:c096881e8ed0

(issue50) Make message box a member variable This only shows the message box again if no old message box still exists.
author Andre Heinecke <andre.heinecke@intevation.de>
date Thu, 28 Aug 2014 14:43:47 +0200
parents 4efd6378c001
children c80777457133
comparison
equal deleted inserted replaced
968:5e43b9a4e926 969:c096881e8ed0
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->button(QMessageBox::Ok)->setText (tr("Install update"));
54 mMessageBox->button(QMessageBox::No)->setText (tr("Remind me later"));
55 mMessageBox->show();
51 } 56 }
57
58 void TrayIcon::messageDestroyed() {
59 mMessageBox = NULL;
60 }

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