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_SENDCOINSENTRY_H
6 #define BITCOIN_QT_SENDCOINSENTRY_H
7 
8 #include <qt/walletmodel.h>
9 
10 #include <QStackedWidget>
11 
12 class WalletModel;
13 class PlatformStyle;
14 
15 namespace Ui {
16     class SendCoinsEntry;
17 }
18 
19 /**
20  * A single entry in the dialog for sending bitcoins.
21  * Stacked widget, with different UIs for payment requests
22  * with a strong payee identity.
23  */
24 class SendCoinsEntry : public QStackedWidget
25 {
26     Q_OBJECT
27 
28 public:
29     explicit SendCoinsEntry(const PlatformStyle *platformStyle, QWidget *parent = nullptr);
30     ~SendCoinsEntry();
31 
32     void setModel(WalletModel *model);
33     bool validate(interfaces::Node& node);
34     SendCoinsRecipient getValue();
35 
36     /** Return whether the entry is still empty and unedited */
37     bool isClear();
38 
39     void setValue(const SendCoinsRecipient &value);
40     void setAddress(const QString &address);
41     void setAmount(const CAmount &amount);
42 
43     /** Set up the tab chain manually, as Qt messes up the tab chain by default in some cases
44      *  (issue https://bugreports.qt-project.org/browse/QTBUG-10907).
45      */
46     QWidget *setupTabChain(QWidget *prev);
47 
48     void setFocus();
49 
50 public Q_SLOTS:
51     void clear();
52     void checkSubtractFeeFromAmount();
53 
54 Q_SIGNALS:
55     void removeEntry(SendCoinsEntry *entry);
56     void useAvailableBalance(SendCoinsEntry* entry);
57     void payAmountChanged();
58     void subtractFeeFromAmountChanged();
59 
60 private Q_SLOTS:
61     void deleteClicked();
62     void useAvailableBalanceClicked();
63     void on_payTo_textChanged(const QString &address);
64     void on_addressBookButton_clicked();
65     void on_pasteButton_clicked();
66     void updateDisplayUnit();
67 
68 private:
69     SendCoinsRecipient recipient;
70     Ui::SendCoinsEntry *ui;
71     WalletModel *model;
72     const PlatformStyle *platformStyle;
73 
74     bool updateLabel(const QString &address);
75 };
76 
77 #endif // BITCOIN_QT_SENDCOINSENTRY_H
78