andre@871: /* Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik andre@871: * Software engineering by Intevation GmbH andre@871: * andre@871: * This file is Free Software under the GNU GPL (v>=2) andre@871: * and comes with ABSOLUTELY NO WARRANTY! andre@871: * See LICENSE.txt for details. andre@871: */ andre@871: andre@871: #include "trayicon.h" andre@871: andre@871: #include andre@871: #include andre@871: #include andre@871: #include andre@871: #include andre@871: andre@871: TrayIcon::TrayIcon (QObject *parent) : andre@871: QSystemTrayIcon (parent), andre@871: useAlt(false) andre@871: { andre@871: if (QSystemTrayIcon::isSystemTrayAvailable() && andre@871: qgetenv("XDG_CURRENT_DESKTOP") != "Unity") { andre@871: return; andre@871: } andre@871: qDebug() << "Platform is without systray. Using Alternative notifications"; andre@871: useAlt = true; andre@871: andre@871: } andre@871: andre@871: void TrayIcon::show() { andre@871: if (useAlt) { andre@871: qDebug() << "Would show"; andre@871: return; andre@871: } andre@871: QSystemTrayIcon::show(); andre@871: } andre@871: andre@871: void TrayIcon::showMessage(const QString &title, const QString &msg, andre@871: QSystemTrayIcon::MessageIcon msg_icon, int msecs) { andre@871: if (!useAlt) { andre@871: QSystemTrayIcon::showMessage(title, msg, msg_icon, msecs); andre@871: return; andre@871: } andre@871: QMessageBox *theMessage = new QMessageBox (QMessageBox::Information, andre@871: title, msg, QMessageBox::Ok | QMessageBox::No, qobject_cast(parent())); andre@871: theMessage->setIconPixmap (icon().pixmap(theMessage->iconPixmap().size())); andre@871: theMessage->button(QMessageBox::Ok)->setText (tr("Install update")); andre@871: theMessage->button(QMessageBox::No)->setText (tr("Remind me later")); andre@871: connect(theMessage->button(QMessageBox::Ok), SIGNAL(clicked()), this, SIGNAL(messageClicked())); andre@871: theMessage->show(); andre@871: }