PIVX Core  5.6.99
P2P Digital Currency
send.h
Go to the documentation of this file.
1 // Copyright (c) 2019-2021 The PIVX 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 PIVX_QT_SEND_H
6 #define PIVX_QT_SEND_H
7 
8 #include <QWidget>
9 #include <QPushButton>
10 
11 #include "coincontroldialog.h"
12 #include "contactsdropdown.h"
13 #include "pwidget.h"
14 #include "sendcustomfeedialog.h"
15 #include "sendmultirow.h"
16 #include "tooltipmenu.h"
17 #include "walletmodel.h"
18 
19 #include <atomic>
20 
21 static const int MAX_SEND_POPUP_ENTRIES = 8;
22 
23 class PIVXGUI;
24 class ClientModel;
25 class OperationResult;
26 class WalletModel;
28 
29 namespace Ui {
30 class send;
31 class QPushButton;
32 }
33 
34 class SendWidget : public PWidget
35 {
36  Q_OBJECT
37 
38 public:
39  explicit SendWidget(PIVXGUI* parent);
40  ~SendWidget();
41 
42  void addEntry();
43 
44  void loadClientModel() override;
45  void loadWalletModel() override;
46 
47 Q_SIGNALS:
49  void receivedURI(const QString& uri);
50 
51 public Q_SLOTS:
54  void onCoinControlClicked();
55  void onOpenUriClicked();
56  void onShieldCoinsClicked();
57  void onValueChanged();
58  void refreshAmounts();
59  void changeTheme(bool isLightTheme, QString &theme) override;
60  void updateAmounts(const QString& titleTotalRemaining,
61  const QString& labelAmountSend,
62  const QString& labelAmountRemaining,
63  CAmount _delegationBalance);
64 
65 protected:
66  void resizeEvent(QResizeEvent *event) override;
67  void showEvent(QShowEvent *event) override;
68 
69  void run(int type) override;
70  void onError(QString error, int type) override;
71 
72 private Q_SLOTS:
73  void onPIVSelected(bool _isTransparent);
74  void onSendClicked();
75  void onContactsClicked(SendMultiRow* entry);
76  void onMenuClicked(SendMultiRow* entry);
77  void onAddEntryClicked();
78  void clearEntries();
79  void clearAll(bool fClearSettings = true);
80  void onCheckBoxChanged();
81  void onContactMultiClicked();
82  void onDeleteClicked();
83  void onEntryMemoClicked();
85  void onResetCustomOptions(bool fRefreshAmounts);
86  void onResetSettings();
87 
88 private:
89  Ui::send *ui;
90  QPushButton *coinIcon;
91 
93  bool isCustomFeeSelected = false;
94  bool fDelegationsChecked = false;
95 
97  QList<SendMultiRow*> entries;
99 
100  // Cached tx
102  std::atomic<bool> isProcessing{false};
104  std::atomic<bool> processingResult{false};
105 
106  // Balance update
107  std::atomic<bool> isUpdatingBalance{false};
108 
110  TooltipMenu *menu = nullptr;
111  // Current focus entry
113 
114  bool isTransparent = true;
115  void resizeMenu();
117  void ProcessSend(QList<SendCoinsRecipient>& recipients, bool hasShieldedOutput,
118  const std::function<bool(QList<SendCoinsRecipient>&)>& func = nullptr);
119  OperationResult prepareShielded(WalletModelTransaction* tx, bool fromTransparent);
121  bool sendFinalStep();
122  void setFocusOnLastEntry();
123  void showHideCheckBoxDelegations(CAmount delegationBalance);
124  void updateEntryLabels(const QList<SendCoinsRecipient>& recipients);
125  void setCustomFeeSelected(bool isSelected, const CAmount& customFee = DEFAULT_TRANSACTION_FEE);
127  void resetCoinControl();
128  void resetChangeAddress();
129  void hideContactsMenu();
130  void tryRefreshAmounts();
131 };
132 
133 #endif // PIVX_QT_SEND_H
int64_t CAmount
Amount in PIV (Can be negative)
Definition: amount.h:13
Model for PIVX network client.
Definition: clientmodel.h:50
PIVX GUI main class.
Definition: pivxgui.h:46
void onSubtractFeeFromAmountChecked()
Definition: send.cpp:958
void refreshAmounts()
Definition: send.cpp:140
bool sendFinalStep()
Definition: send.cpp:513
void onChangeAddressClicked()
Definition: send.cpp:611
void onCoinControlClicked()
Definition: send.cpp:700
std::atomic< bool > processingResult
Definition: send.h:104
WalletModelTransaction * ptrModelTx
Definition: send.h:101
void updateAmounts(const QString &titleTotalRemaining, const QString &labelAmountSend, const QString &labelAmountRemaining, CAmount _delegationBalance)
Definition: send.cpp:190
void onResetCustomOptions(bool fRefreshAmounts)
Definition: send.cpp:263
void onContactsClicked(SendMultiRow *entry)
Definition: send.cpp:814
void onDeleteClicked()
Definition: send.cpp:965
bool fDelegationsChecked
Definition: send.h:94
bool isCustomFeeSelected
Definition: send.h:93
Optional< QString > processingResultError
Definition: send.h:103
void setCoinControlPayAmounts()
Definition: send.cpp:778
ContactsDropdown * menuContacts
Definition: send.h:109
void resizeMenu()
Definition: send.cpp:997
void hideContactsMenu()
Definition: send.cpp:240
void onSendClicked()
Definition: send.cpp:378
void showHideCheckBoxDelegations(CAmount delegationBalance)
Definition: send.cpp:362
QPushButton * coinIcon
Definition: send.h:90
void clearAll(bool fClearSettings=true)
Definition: send.cpp:247
CoinControlDialog * coinControlDialog
Definition: send.h:98
SendMultiRow * focusedEntry
Definition: send.h:112
std::atomic< bool > isUpdatingBalance
Definition: send.h:107
void onMenuClicked(SendMultiRow *entry)
Definition: send.cpp:870
void onPIVSelected(bool _isTransparent)
Definition: send.cpp:803
OperationResult prepareShielded(WalletModelTransaction *tx, bool fromTransparent)
Definition: send.cpp:475
void resetCoinControl()
Definition: send.cpp:273
void onShieldCoinsClicked()
Definition: send.cpp:716
OperationResult prepareTransparent(WalletModelTransaction *tx)
Definition: send.cpp:483
void clearEntries()
Definition: send.cpp:288
void resetChangeAddress()
Definition: send.cpp:279
void addEntry()
Definition: send.cpp:299
SendMultiRow * createEntry()
Definition: send.cpp:320
void setFocusOnLastEntry()
Definition: send.cpp:357
SendWidget(PIVXGUI *parent)
Definition: send.cpp:31
TooltipMenu * menu
Definition: send.h:110
void onValueChanged()
Definition: send.cpp:789
void loadClientModel() override
Definition: send.cpp:202
void onChangeCustomFeeClicked()
Definition: send.cpp:688
SendCustomFeeDialog * customFeeDialog
Definition: send.h:92
void showEvent(QShowEvent *event) override
Definition: send.cpp:350
void onError(QString error, int type) override
Definition: send.cpp:576
void resizeEvent(QResizeEvent *event) override
Definition: send.cpp:344
void onAddEntryClicked()
Definition: send.cpp:332
void run(int type) override
Definition: send.cpp:549
void ProcessSend(QList< SendCoinsRecipient > &recipients, bool hasShieldedOutput, const std::function< bool(QList< SendCoinsRecipient > &)> &func=nullptr)
Definition: send.cpp:420
void tryRefreshAmounts()
Definition: send.cpp:582
void onCheckBoxChanged()
Definition: send.cpp:794
void onContactMultiClicked()
Definition: send.cpp:901
void setCustomFeeSelected(bool isSelected, const CAmount &customFee=DEFAULT_TRANSACTION_FEE)
Definition: send.cpp:1010
void updateEntryLabels(const QList< SendCoinsRecipient > &recipients)
Definition: send.cpp:589
void receivedURI(const QString &uri)
Signal raised when a URI was entered or dragged to the GUI.
QList< SendMultiRow * > entries
Definition: send.h:97
void onOpenUriClicked()
Definition: send.cpp:652
void onEntryMemoClicked()
Definition: send.cpp:950
std::atomic< bool > isProcessing
Definition: send.h:102
~SendWidget()
Definition: send.cpp:1025
void changeTheme(bool isLightTheme, QString &theme) override
Definition: send.cpp:1020
Ui::send * ui
Definition: send.h:89
bool isTransparent
Definition: send.h:114
void onResetSettings()
Definition: send.cpp:256
void loadWalletModel() override
Definition: send.cpp:211
int nDisplayUnit
Definition: send.h:96
Interface to PIVX wallet from Qt view code.
Definition: walletmodel.h:109
Data model for a walletmodel transaction.
boost::optional< T > Optional
Substitute for C++17 std::optional.
Definition: optional.h:12
bool isLightTheme()
Definition: qtutils.cpp:210
bool error(const char *fmt, const Args &... args)
Definition: system.h:77