diff options
| author | Wladimir J. van der Laan <[email protected]> | 2011-06-05 17:36:52 +0200 |
|---|---|---|
| committer | Wladimir J. van der Laan <[email protected]> | 2011-06-05 17:36:52 +0200 |
| commit | b7726d924ef7082b1f1d532ba6f840bc7b267b47 (patch) | |
| tree | 8d6cdc2428b37ed16a5ec565f07b2594a6ce706b /gui/src | |
| parent | fix (diff) | |
| download | discoin-b7726d924ef7082b1f1d532ba6f840bc7b267b47.tar.xz discoin-b7726d924ef7082b1f1d532ba6f840bc7b267b47.zip | |
ask fee
Diffstat (limited to 'gui/src')
| -rw-r--r-- | gui/src/bitcoin.cpp | 30 | ||||
| -rw-r--r-- | gui/src/bitcoingui.cpp | 12 |
2 files changed, 36 insertions, 6 deletions
diff --git a/gui/src/bitcoin.cpp b/gui/src/bitcoin.cpp index a1b74d879..6dbcb6c29 100644 --- a/gui/src/bitcoin.cpp +++ b/gui/src/bitcoin.cpp @@ -5,10 +5,12 @@ #include "clientmodel.h" #include "util.h" #include "init.h" +#include "main.h" #include "externui.h" #include <QApplication> #include <QMessageBox> +#include <QThread> // Need a global reference for the notifications to find the GUI BitcoinGUI *guiref; @@ -16,7 +18,6 @@ BitcoinGUI *guiref; int MyMessageBox(const std::string& message, const std::string& caption, int style, wxWindow* parent, int x, int y) { // Message from main thread - printf("MyMessageBox\n"); if(guiref) { guiref->error(QString::fromStdString(caption), @@ -50,9 +51,26 @@ int ThreadSafeMessageBox(const std::string& message, const std::string& caption, bool ThreadSafeAskFee(int64 nFeeRequired, const std::string& strCaption, wxWindow* parent) { - // Query from network thread - // TODO - return true; + if(!guiref) + return false; + if(nFeeRequired < MIN_TX_FEE || nFeeRequired <= nTransactionFee || fDaemon) + return true; + bool payFee = false; + + /* Call slot on GUI thread. + If called from another thread, use a blocking QueuedConnection. + */ + Qt::ConnectionType connectionType = Qt::DirectConnection; + if(QThread::currentThread() != QCoreApplication::instance()->thread()) + { + connectionType = Qt::BlockingQueuedConnection; + } + + QMetaObject::invokeMethod(guiref, "askFee", connectionType, + Q_ARG(qint64, nFeeRequired), + Q_ARG(bool*, &payFee)); + + return payFee; } void CalledSetStatusBar(const std::string& strText, int nField) @@ -73,13 +91,13 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); app.setQuitOnLastWindowClosed(false); - BitcoinGUI window; - guiref = &window; try { if(AppInit2(argc, argv)) { + BitcoinGUI window; ClientModel model; + guiref = &window; window.setModel(&model); window.show(); diff --git a/gui/src/bitcoingui.cpp b/gui/src/bitcoingui.cpp index b68720462..70da0b239 100644 --- a/gui/src/bitcoingui.cpp +++ b/gui/src/bitcoingui.cpp @@ -380,3 +380,15 @@ void BitcoinGUI::closeEvent(QCloseEvent *event) } QMainWindow::closeEvent(event); } + +void BitcoinGUI::askFee(qint64 nFeeRequired, bool *payFee) +{ + QString strMessage = + tr("This transaction is over the size limit. You can still send it for a fee of %1, " + "which goes to the nodes that process your transaction and helps to support the network. " + "Do you want to pay the fee?").arg(QString::fromStdString(FormatMoney(nFeeRequired))); + QMessageBox::StandardButton retval = QMessageBox::question( + this, tr("Sending..."), strMessage, + QMessageBox::Yes|QMessageBox::Cancel, QMessageBox::Yes); + *payFee = (retval == QMessageBox::Yes); +} |