sendcoinsentry.h raw
1 // Copyright (c) 2011-2022 The Limenka 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 LIMENKA_QT_SENDCOINSENTRY_H
6 #define LIMENKA_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 limenkas.
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 bool hasPaytoWarning() const;
37 SendCoinsRecipient getValue();
38
39 /** Return whether the entry is still empty and unedited */
40 bool isClear();
41
42 void setValue(const SendCoinsRecipient &value);
43 void setAddress(const QString &address);
44 void setAmount(const CAmount &amount);
45
46 /** Set up the tab chain manually, as Qt messes up the tab chain by default in some cases
47 * (issue https://bugreports.qt-project.org/browse/QTBUG-10907).
48 */
49 QWidget *setupTabChain(QWidget *prev);
50
51 void setFocus();
52
53 public Q_SLOTS:
54 void clear();
55 void checkSubtractFeeFromAmount();
56
57 Q_SIGNALS:
58 void removeEntry(SendCoinsEntry *entry);
59 void useAvailableBalance(SendCoinsEntry* entry);
60 void payAmountChanged();
61 void subtractFeeFromAmountChanged();
62
63 private Q_SLOTS:
64 void deleteClicked();
65 void useAvailableBalanceClicked();
66 void on_payTo_textChanged(const QString &address);
67 void on_addressBookButton_clicked();
68 void on_pasteButton_clicked();
69 void updateDisplayUnit();
70
71 protected:
72 void changeEvent(QEvent* e) override;
73
74 private:
75 SendCoinsRecipient recipient;
76 Ui::SendCoinsEntry *ui;
77 WalletModel* model{nullptr};
78 const PlatformStyle *platformStyle;
79
80 bool updateLabel(const QString &address);
81 };
82
83 #endif // LIMENKA_QT_SENDCOINSENTRY_H
84