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