Skip to content

Commit 24004e0

Browse files
UI: Add notification to status bar for transactions in pending map
NOTE: this is for the pending map, so currently outbound transactions
1 parent bfd78d6 commit 24004e0

File tree

6 files changed

+42
-2
lines changed

6 files changed

+42
-2
lines changed

src/omnicore/pending.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ void PendingAdd(const uint256& txid, const std::string& sendingAddress, const st
9191

9292
// after adding a transaction to pending the available balance may now be reduced, refresh wallet totals
9393
set_wallet_totals();
94+
uiInterface.OmniPendingChanged(true); // after adding it is a safe assumption that pending map now contains txn(s)
9495
uiInterface.OmniStateChanged();
9596
}
9697

@@ -108,10 +109,12 @@ void PendingDelete(const uint256& txid)
108109
if (msc_debug_pending) PrintToLog("%s(%s): amount=%d\n", __FUNCTION__, txid.GetHex(), src_amount);
109110
if (src_amount) update_tally_map(pending.src, pending.prop, pending.amount, PENDING);
110111
my_pending.erase(it);
112+
113+
// if pending map is now empty following deletion, trigger a status change
114+
if (my_pending.empty()) uiInterface.OmniPendingChanged(false);
111115
}
112116
}
113117

114-
115118
} // namespace mastercore
116119

117120
/**

src/qt/bitcoingui.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ BitcoinGUI::BitcoinGUI(const NetworkStyle *networkStyle, QWidget *parent) :
7070
labelEncryptionIcon(0),
7171
labelConnectionsIcon(0),
7272
labelBlocksIcon(0),
73+
labelOmniPendingIcon(0),
7374
progressBarLabel(0),
7475
progressBar(0),
7576
progressDialog(0),
@@ -176,6 +177,7 @@ BitcoinGUI::BitcoinGUI(const NetworkStyle *networkStyle, QWidget *parent) :
176177
labelEncryptionIcon = new QLabel();
177178
labelConnectionsIcon = new QLabel();
178179
labelBlocksIcon = new QLabel();
180+
labelOmniPendingIcon = new QLabel();
179181
if(enableWallet)
180182
{
181183
frameBlocksLayout->addStretch();
@@ -188,6 +190,8 @@ BitcoinGUI::BitcoinGUI(const NetworkStyle *networkStyle, QWidget *parent) :
188190
frameBlocksLayout->addStretch();
189191
frameBlocksLayout->addWidget(labelBlocksIcon);
190192
frameBlocksLayout->addStretch();
193+
frameBlocksLayout->addWidget(labelOmniPendingIcon);
194+
frameBlocksLayout->addStretch();
191195

192196
// Progress bar and label for blocks download
193197
progressBarLabel = new QLabel();
@@ -461,6 +465,9 @@ void BitcoinGUI::setClientModel(ClientModel *clientModel)
461465
// Show progress dialog
462466
connect(clientModel, SIGNAL(showProgress(QString,int)), this, SLOT(showProgress(QString,int)));
463467

468+
// Update Omni pending status
469+
connect(clientModel, SIGNAL(refreshOmniPending(bool)), this, SLOT(setOmniPendingStatus(bool)));
470+
464471
rpcConsole->setClientModel(clientModel);
465472
#ifdef ENABLE_WALLET
466473
if(walletFrame)
@@ -957,6 +964,17 @@ bool BitcoinGUI::handlePaymentRequest(const SendCoinsRecipient& recipient)
957964
return false;
958965
}
959966

967+
void BitcoinGUI::setOmniPendingStatus(bool pending)
968+
{
969+
if (!pending) {
970+
labelOmniPendingIcon->hide();
971+
} else {
972+
labelOmniPendingIcon->show();
973+
labelOmniPendingIcon->setPixmap(QIcon(":/icons/hourglass").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
974+
labelOmniPendingIcon->setToolTip(tr("You have Omni transactions awaiting confirmation."));
975+
}
976+
}
977+
960978
void BitcoinGUI::setEncryptionStatus(int status)
961979
{
962980
switch(status)

src/qt/bitcoingui.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ class BitcoinGUI : public QMainWindow
8181
QLabel *labelEncryptionIcon;
8282
QLabel *labelConnectionsIcon;
8383
QLabel *labelBlocksIcon;
84+
QLabel *labelOmniPendingIcon;
8485
QLabel *progressBarLabel;
8586
QProgressBar *progressBar;
8687
QProgressDialog *progressDialog;
@@ -162,7 +163,7 @@ public slots:
162163
@see WalletModel::EncryptionStatus
163164
*/
164165
void setEncryptionStatus(int status);
165-
166+
void setOmniPendingStatus(bool pending);
166167
bool handlePaymentRequest(const SendCoinsRecipient& recipient);
167168

168169
/** Show incoming transaction notification for new transactions. */

src/qt/clientmodel.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@ void ClientModel::updateOmniState()
132132
emit refreshOmniState();
133133
}
134134

135+
void ClientModel::updateOmniPending(bool pending)
136+
{
137+
emit refreshOmniPending(pending);
138+
}
139+
135140
void ClientModel::updateAlert(const QString &hash, int status)
136141
{
137142
// Show error message notification for new alert
@@ -213,6 +218,12 @@ static void OmniStateChanged(ClientModel *clientmodel)
213218
QMetaObject::invokeMethod(clientmodel, "updateOmniState", Qt::QueuedConnection);
214219
}
215220

221+
static void OmniPendingChanged(ClientModel *clientmodel, bool pending)
222+
{
223+
// Triggered when Omni pending map adds/removes transactions
224+
QMetaObject::invokeMethod(clientmodel, "updateOmniPending", Qt::QueuedConnection, Q_ARG(bool, pending));
225+
}
226+
216227
static void ShowProgress(ClientModel *clientmodel, const std::string &title, int nProgress)
217228
{
218229
// emits signal "showProgress"
@@ -243,6 +254,7 @@ void ClientModel::subscribeToCoreSignals()
243254
uiInterface.NotifyNumConnectionsChanged.connect(boost::bind(NotifyNumConnectionsChanged, this, _1));
244255
uiInterface.NotifyAlertChanged.connect(boost::bind(NotifyAlertChanged, this, _1, _2));
245256
uiInterface.OmniStateChanged.connect(boost::bind(OmniStateChanged, this));
257+
uiInterface.OmniPendingChanged.connect(boost::bind(OmniPendingChanged, this, _1));
246258
}
247259

248260
void ClientModel::unsubscribeFromCoreSignals()
@@ -252,4 +264,5 @@ void ClientModel::unsubscribeFromCoreSignals()
252264
uiInterface.NotifyNumConnectionsChanged.disconnect(boost::bind(NotifyNumConnectionsChanged, this, _1));
253265
uiInterface.NotifyAlertChanged.disconnect(boost::bind(NotifyAlertChanged, this, _1, _2));
254266
uiInterface.OmniStateChanged.disconnect(boost::bind(OmniStateChanged, this));
267+
uiInterface.OmniPendingChanged.disconnect(boost::bind(OmniPendingChanged, this, _1));
255268
}

src/qt/clientmodel.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ class ClientModel : public QObject
9090
void alertsChanged(const QString &warnings);
9191
void bytesChanged(quint64 totalBytesIn, quint64 totalBytesOut);
9292
void refreshOmniState();
93+
void refreshOmniPending(bool pending);
9394

9495
//! Fired when a message should be reported to the user
9596
void message(const QString &title, const QString &message, unsigned int style);
@@ -102,6 +103,7 @@ public slots:
102103
void updateNumConnections(int numConnections);
103104
void updateAlert(const QString &hash, int status);
104105
void updateOmniState();
106+
void updateOmniPending(bool pending);
105107
};
106108

107109
#endif // BITCOIN_QT_CLIENTMODEL_H

src/ui_interface.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ class CClientUIInterface
101101

102102
/** Omni balances have been updated. */
103103
boost::signals2::signal<void ()> OmniStateChanged;
104+
105+
/** Omni pending status has been changed */
106+
boost::signals2::signal<void (bool pending)> OmniPendingChanged;
104107
};
105108

106109
extern CClientUIInterface uiInterface;

0 commit comments

Comments
 (0)