Skip to content

Commit 2384a28

Browse files
author
Philip Kaufmann
committed
allow emit message() in sendcoinsdialog and walletview
- this allows us to use emit message() over MessageBox:: or gui->message() calls in sendcoinsdialog and walletview - move main handlePaymentRequest() functionality back to BitcoinGUI - move a showNormalIfMinimized() before gotoSendCoinsPage()
1 parent 081c0cd commit 2384a28

File tree

5 files changed

+30
-17
lines changed

5 files changed

+30
-17
lines changed

src/qt/bitcoingui.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -752,9 +752,17 @@ bool BitcoinGUI::eventFilter(QObject *object, QEvent *event)
752752
return QMainWindow::eventFilter(object, event);
753753
}
754754

755-
void BitcoinGUI::handlePaymentRequest(const SendCoinsRecipient& recipient)
755+
bool BitcoinGUI::handlePaymentRequest(const SendCoinsRecipient& recipient)
756756
{
757-
walletFrame->handlePaymentRequest(recipient);
757+
// URI has to be valid
758+
if (walletFrame->handlePaymentRequest(recipient))
759+
{
760+
showNormalIfMinimized();
761+
gotoSendCoinsPage();
762+
return true;
763+
}
764+
else
765+
return false;
758766
}
759767

760768
void BitcoinGUI::setEncryptionStatus(int status)

src/qt/bitcoingui.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public slots:
146146
*/
147147
void askFee(qint64 nFeeRequired, bool *payFee);
148148

149-
void handlePaymentRequest(const SendCoinsRecipient& recipient);
149+
bool handlePaymentRequest(const SendCoinsRecipient& recipient);
150150

151151
/** Show incoming transaction notification for new transactions. */
152152
void incomingTransaction(const QString& date, int unit, qint64 amount, const QString& type, const QString& address);

src/qt/sendcoinsdialog.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ private slots:
5252
void on_sendButton_clicked();
5353
void removeEntry(SendCoinsEntry* entry);
5454
void updateDisplayUnit();
55+
56+
signals:
57+
// Fired when a message should be reported to the user
58+
void message(const QString &title, const QString &message, unsigned int style);
5559
};
5660

5761
#endif // SENDCOINSDIALOG_H

src/qt/walletview.cpp

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,15 @@ WalletView::~WalletView()
8181
void WalletView::setBitcoinGUI(BitcoinGUI *gui)
8282
{
8383
this->gui = gui;
84-
if(gui)
84+
85+
if (gui)
8586
{
87+
// Clicking on a transaction on the overview page sends you to the transactions tab
8688
connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), gui, SLOT(gotoHistoryPage()));
89+
90+
// Receive and report messages
91+
connect(this, SIGNAL(message(QString,QString,unsigned int)), gui, SLOT(message(QString,QString,unsigned int)));
92+
connect(sendCoinsPage, SIGNAL(message(QString,QString,unsigned int)), gui, SLOT(message(QString,QString,unsigned int)));
8793
}
8894
}
8995

@@ -187,15 +193,7 @@ void WalletView::gotoVerifyMessageTab(QString addr)
187193

188194
bool WalletView::handlePaymentRequest(const SendCoinsRecipient& recipient)
189195
{
190-
// URI has to be valid
191-
if (sendCoinsPage->handlePaymentRequest(recipient))
192-
{
193-
gotoSendCoinsPage();
194-
emit showNormalIfMinimized();
195-
return true;
196-
}
197-
else
198-
return false;
196+
return sendCoinsPage->handlePaymentRequest(recipient);
199197
}
200198

201199
void WalletView::showOutOfSyncWarning(bool fShow)
@@ -229,12 +227,12 @@ void WalletView::backupWallet()
229227
QString filename = QFileDialog::getSaveFileName(this, tr("Backup Wallet"), saveDir, tr("Wallet Data (*.dat)"));
230228
if (!filename.isEmpty()) {
231229
if (!walletModel->backupWallet(filename)) {
232-
gui->message(tr("Backup Failed"), tr("There was an error trying to save the wallet data to the new location."),
233-
CClientUIInterface::MSG_ERROR);
230+
emit message(tr("Backup Failed"), tr("There was an error trying to save the wallet data to the new location."),
231+
CClientUIInterface::MSG_ERROR);
234232
}
235233
else
236-
gui->message(tr("Backup Successful"), tr("The wallet data was successfully saved to the new location."),
237-
CClientUIInterface::MSG_INFORMATION);
234+
emit message(tr("Backup Successful"), tr("The wallet data was successfully saved to the new location."),
235+
CClientUIInterface::MSG_INFORMATION);
238236
}
239237
}
240238

src/qt/walletview.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ public slots:
105105
signals:
106106
/** Signal that we want to show the main window */
107107
void showNormalIfMinimized();
108+
109+
/** Fired when a message should be reported to the user */
110+
void message(const QString &title, const QString &message, unsigned int style);
108111
};
109112

110113
#endif // WALLETVIEW_H

0 commit comments

Comments
 (0)