1 // Copyright (c) 2011-2018 The Bitcoin Core developers 2 // Distributed under the MIT software license, see the accompanying 3 // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 5 #ifndef BITCOIN_QT_SENDCOINSDIALOG_H 6 #define BITCOIN_QT_SENDCOINSDIALOG_H 7 8 #include <qt/walletmodel.h> 9 10 #include <QDialog> 11 #include <QMessageBox> 12 #include <QString> 13 #include <QTimer> 14 15 class ClientModel; 16 class PlatformStyle; 17 class SendCoinsEntry; 18 class SendCoinsRecipient; 19 20 namespace Ui { 21 class SendCoinsDialog; 22 } 23 24 QT_BEGIN_NAMESPACE 25 class QUrl; 26 QT_END_NAMESPACE 27 28 /** Dialog for sending bitcoins */ 29 class SendCoinsDialog : public QDialog 30 { 31 Q_OBJECT 32 33 public: 34 explicit SendCoinsDialog(const PlatformStyle *platformStyle, QWidget *parent = nullptr); 35 ~SendCoinsDialog(); 36 37 void setClientModel(ClientModel *clientModel); 38 void setModel(WalletModel *model); 39 40 /** Set up the tab chain manually, as Qt messes up the tab chain by default in some cases (issue https://bugreports.qt-project.org/browse/QTBUG-10907). 41 */ 42 QWidget *setupTabChain(QWidget *prev); 43 44 void setAddress(const QString &address); 45 void pasteEntry(const SendCoinsRecipient &rv); 46 bool handlePaymentRequest(const SendCoinsRecipient &recipient); 47 48 public Q_SLOTS: 49 void clear(); 50 void reject(); 51 void accept(); 52 SendCoinsEntry *addEntry(); 53 void updateTabsAndLabels(); 54 void setBalance(const interfaces::WalletBalances& balances); 55 56 Q_SIGNALS: 57 void coinsSent(const uint256& txid); 58 59 private: 60 Ui::SendCoinsDialog *ui; 61 ClientModel *clientModel; 62 WalletModel *model; 63 bool fNewRecipientAllowed; 64 bool fFeeMinimized; 65 const PlatformStyle *platformStyle; 66 67 // Process WalletModel::SendCoinsReturn and generate a pair consisting 68 // of a message and message flags for use in Q_EMIT message(). 69 // Additional parameter msgArg can be used via .arg(msgArg). 70 void processSendCoinsReturn(const WalletModel::SendCoinsReturn &sendCoinsReturn, const QString &msgArg = QString()); 71 void minimizeFeeSection(bool fMinimize); 72 void updateFeeMinimizedLabel(); 73 // Update the passed in CCoinControl with state from the GUI 74 void updateCoinControlState(CCoinControl& ctrl); 75 76 private Q_SLOTS: 77 void on_sendButton_clicked(); 78 void on_buttonChooseFee_clicked(); 79 void on_buttonMinimizeFee_clicked(); 80 void removeEntry(SendCoinsEntry* entry); 81 void useAvailableBalance(SendCoinsEntry* entry); 82 void updateDisplayUnit(); 83 void coinControlFeatureChanged(bool); 84 void coinControlButtonClicked(); 85 void coinControlChangeChecked(int); 86 void coinControlChangeEdited(const QString &); 87 void coinControlUpdateLabels(); 88 void coinControlClipboardQuantity(); 89 void coinControlClipboardAmount(); 90 void coinControlClipboardFee(); 91 void coinControlClipboardAfterFee(); 92 void coinControlClipboardBytes(); 93 void coinControlClipboardLowOutput(); 94 void coinControlClipboardChange(); 95 void updateFeeSectionControls(); 96 void updateSmartFeeLabel(); 97 98 Q_SIGNALS: 99 // Fired when a message should be reported to the user 100 void message(const QString &title, const QString &message, unsigned int style); 101 }; 102 103 104 #define SEND_CONFIRM_DELAY 3 105 106 class SendConfirmationDialog : public QMessageBox 107 { 108 Q_OBJECT 109 110 public: 111 SendConfirmationDialog(const QString &title, const QString &text, int secDelay = SEND_CONFIRM_DELAY, QWidget *parent = nullptr); 112 int exec(); 113 114 private Q_SLOTS: 115 void countDown(); 116 void updateYesButton(); 117 118 private: 119 QAbstractButton *yesButton; 120 QTimer countDownTimer; 121 int secDelay; 122 }; 123 124 #endif // BITCOIN_QT_SENDCOINSDIALOG_H 125