Mercurial > trustbridge
changeset 1144:a4282bc67a8b
(issue99) Make OK button in message box notification configurable and change it for list updates
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Thu, 18 Sep 2014 11:08:57 +0200 |
parents | 05d4e882fe18 |
children | a41338b18273 |
files | ui/mainwindow.cpp ui/trayicon.cpp ui/trayicon.h |
diffstat | 3 files changed, 20 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/ui/mainwindow.cpp Wed Sep 17 18:56:29 2014 +0200 +++ b/ui/mainwindow.cpp Thu Sep 18 11:08:57 2014 +0200 @@ -174,8 +174,17 @@ * the trayicon. So we delay here.*/ QTimer::singleShot(2000, this, SLOT(showMessage())); } else if (mCurState == NewSoftwareAvailable || !isVisible()) { - mTrayIcon->showMessage(QApplication::applicationName(), mCurMessage, - QSystemTrayIcon::Information, 10000); + if (mCurState == NewListAvailable) { + mTrayIcon->showMessage(QApplication::applicationName(), mCurMessage, + QSystemTrayIcon::Information, 10000, + tr("Show recommendations")); + } else if (mCurState == NewSoftwareAvailable || !mTrayIcon->isAlternative()) { + /* Only show new list or new software in alternative as + * the current tray icon alternative is too invasive for pure + * informational messages. */ + mTrayIcon->showMessage(QApplication::applicationName(), mCurMessage, + QSystemTrayIcon::Information, 10000); + } mMessageTimer->start(); // Restart the timer so that we don't spam } }
--- a/ui/trayicon.cpp Wed Sep 17 18:56:29 2014 +0200 +++ b/ui/trayicon.cpp Thu Sep 18 11:08:57 2014 +0200 @@ -37,7 +37,8 @@ } void TrayIcon::showMessage(const QString &title, const QString &msg, - QSystemTrayIcon::MessageIcon msg_icon, int msecs) { + QSystemTrayIcon::MessageIcon msg_icon, int msecs, + const QString &okBtnText) { if (!useAlt) { QSystemTrayIcon::showMessage(title, msg, msg_icon, msecs); return; @@ -51,7 +52,11 @@ } mMessageBox->setIconPixmap(icon().pixmap(mMessageBox->iconPixmap().size())); mMessageBox->setWindowIcon(icon()); - mMessageBox->button(QMessageBox::Ok)->setText (tr("Install update")); + if (!okBtnText.isEmpty()) { + mMessageBox->button(QMessageBox::Ok)->setText (okBtnText); + } else { + mMessageBox->button(QMessageBox::Ok)->setText (tr("Install update")); + } mMessageBox->button(QMessageBox::No)->setText (tr("Remind me later")); mMessageBox->show(); }
--- a/ui/trayicon.h Wed Sep 17 18:56:29 2014 +0200 +++ b/ui/trayicon.h Thu Sep 18 11:08:57 2014 +0200 @@ -34,7 +34,8 @@ public Q_SLOTS: void showMessage(const QString &title, const QString &msg, - QSystemTrayIcon::MessageIcon icon = QSystemTrayIcon::Information, int msecs = 10000); + QSystemTrayIcon::MessageIcon icon = QSystemTrayIcon::Information, int msecs = 10000, + const QString &okBtnText = QString()); private Q_SLOTS: void messageDestroyed();