diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2011-09-03 20:52:54 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2011-09-03 21:05:12 +0200 |
commit | cf9195c8085bade8076e064c043756024fcafa5a (patch) | |
tree | 3c04669d98b77c443ada24369bba735f44ac342d /src/qt/bitcoingui.cpp | |
parent | 69e87633bca0e43f3a58dad921a6fb1bdecd307b (diff) |
(k)ubuntu 10.04+ notification support (based on @zwierzak his code)
Diffstat (limited to 'src/qt/bitcoingui.cpp')
-rw-r--r-- | src/qt/bitcoingui.cpp | 44 |
1 files changed, 21 insertions, 23 deletions
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index e15941e7dd..95646b1df1 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -20,6 +20,7 @@ #include "bitcoinunits.h" #include "guiconstants.h" #include "askpassphrasedialog.h" +#include "notificator.h" #include <QApplication> #include <QMainWindow> @@ -51,7 +52,8 @@ BitcoinGUI::BitcoinGUI(QWidget *parent): walletModel(0), encryptWalletAction(0), changePassphraseAction(0), - trayIcon(0) + trayIcon(0), + notificator(0) { resize(850, 550); setWindowTitle(tr("Bitcoin Wallet")); @@ -287,6 +289,8 @@ void BitcoinGUI::createTrayIcon() connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason))); trayIcon->show(); + + notificator = new Notificator(tr("bitcoin-qt"), trayIcon); } void BitcoinGUI::trayIconActivated(QSystemTrayIcon::ActivationReason reason) @@ -394,18 +398,7 @@ void BitcoinGUI::setNumBlocks(int count) void BitcoinGUI::error(const QString &title, const QString &message) { // Report errors from network/worker thread - if(trayIcon->supportsMessages()) - { - // Show as "balloon" message if possible - trayIcon->showMessage(title, message, QSystemTrayIcon::Critical); - } - else - { - // Fall back to old fashioned popup dialog if not - QMessageBox::critical(this, title, - message, - QMessageBox::Ok, QMessageBox::Ok); - } + notificator->notify(Notificator::Critical, title, message); } void BitcoinGUI::changeEvent(QEvent *e) @@ -453,8 +446,6 @@ void BitcoinGUI::askFee(qint64 nFeeRequired, bool *payFee) void BitcoinGUI::incomingTransaction(const QModelIndex & parent, int start, int end) { - if(start == end) - return; TransactionTableModel *ttm = walletModel->getTransactionTableModel(); qint64 amount = ttm->index(start, TransactionTableModel::Amount, parent) .data(Qt::EditRole).toULongLong(); @@ -468,14 +459,21 @@ void BitcoinGUI::incomingTransaction(const QModelIndex & parent, int start, int .data().toString(); QString address = ttm->index(start, TransactionTableModel::ToAddress, parent) .data().toString(); - - trayIcon->showMessage((amount)<0 ? tr("Sent transaction") : - tr("Incoming transaction"), - tr("Date: ") + date + "\n" + - tr("Amount: ") + BitcoinUnits::formatWithUnit(walletModel->getOptionsModel()->getDisplayUnit(), amount, true) + "\n" + - tr("Type: ") + type + "\n" + - tr("Address: ") + address + "\n", - QSystemTrayIcon::Information); + QIcon icon = qvariant_cast<QIcon>(ttm->index(start, + TransactionTableModel::ToAddress, parent) + .data(Qt::DecorationRole)); + + notificator->notify(Notificator::Information, + (amount)<0 ? tr("Sent transaction") : + tr("Incoming transaction"), + tr("Date: %1\n" + "Amount: %2\n" + "Type: %3\n" + "Address: %4\n") + .arg(date) + .arg(BitcoinUnits::formatWithUnit(walletModel->getOptionsModel()->getDisplayUnit(), amount, true)) + .arg(type) + .arg(address), icon); } } |