1 // Copyright (c) 2011-2021 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_WALLETVIEW_H
6 #define LIMENKA_QT_WALLETVIEW_H
7 8 #include <consensus/amount.h>
9 #include <qt/limenkaunits.h>
10 11 #include <QStackedWidget>
12 13 class ClientModel;
14 class OverviewPage;
15 class PlatformStyle;
16 class ReceiveCoinsDialog;
17 class SendCoinsDialog;
18 class SendCoinsRecipient;
19 class TransactionView;
20 class WalletModel;
21 class AddressBookPage;
22 23 QT_BEGIN_NAMESPACE
24 class QModelIndex;
25 class QProgressDialog;
26 QT_END_NAMESPACE
27 28 /*
29 WalletView class. This class represents the view to a single wallet.
30 It was added to support multiple wallet functionality. Each wallet gets its own WalletView instance.
31 It communicates with both the client and the wallet models to give the user an up-to-date view of the
32 current core state.
33 */
34 class WalletView : public QStackedWidget
35 {
36 Q_OBJECT
37 38 public:
39 explicit WalletView(WalletModel* wallet_model, const PlatformStyle* platformStyle, QWidget* parent);
40 ~WalletView();
41 42 /** Set the client model.
43 The client model represents the part of the core that communicates with the P2P network, and is wallet-agnostic.
44 */
45 void setClientModel(ClientModel *clientModel);
46 WalletModel* getWalletModel() const noexcept { return walletModel; }
47 48 bool handlePaymentRequest(const SendCoinsRecipient& recipient);
49 50 void showOutOfSyncWarning(bool fShow);
51 52 private:
53 ClientModel* clientModel{nullptr};
54 55 //!
56 //! The wallet model represents a limenka wallet, and offers access to
57 //! the list of transactions, address book and sending functionality.
58 //!
59 WalletModel* const walletModel;
60 61 OverviewPage *overviewPage;
62 QWidget *transactionsPage;
63 ReceiveCoinsDialog *receiveCoinsPage;
64 SendCoinsDialog *sendCoinsPage;
65 AddressBookPage *usedSendingAddressesPage;
66 AddressBookPage *usedReceivingAddressesPage;
67 68 TransactionView *transactionView;
69 70 QProgressDialog* progressDialog{nullptr};
71 const PlatformStyle *platformStyle;
72 73 public Q_SLOTS:
74 /** Switch to overview (home) page */
75 void gotoOverviewPage();
76 /** Switch to history (transactions) page */
77 void gotoHistoryPage();
78 /** Switch to receive coins page */
79 void gotoReceiveCoinsPage();
80 /** Switch to send coins page */
81 void gotoSendCoinsPage(QString addr = "");
82 83 /** Show Sign/Verify Message dialog and switch to sign message tab */
84 void gotoSignMessageTab(QString addr = "");
85 /** Show Sign/Verify Message dialog and switch to verify message tab */
86 void gotoVerifyMessageTab(QString addr = "");
87 88 void gotoSweepPrivKeyDialog();
89 90 /** Show incoming transaction notification for new transactions.
91 92 The new items are those between start and end inclusive, under the given parent item.
93 */
94 void processNewTransaction(const QModelIndex& parent, int start, int /*end*/);
95 /** Encrypt the wallet */
96 void encryptWallet();
97 /** Backup the wallet */
98 void backupWallet();
99 /** Change encrypted wallet passphrase */
100 void changePassphrase();
101 /** Ask for passphrase to unlock wallet temporarily */
102 void unlockWallet();
103 104 /** Show used sending addresses */
105 void usedSendingAddresses();
106 /** Show used receiving addresses */
107 void usedReceivingAddresses();
108 109 /** Show progress dialog e.g. for rescan */
110 void showProgress(const QString &title, int nProgress);
111 112 private Q_SLOTS:
113 void disableTransactionView(bool disable);
114 115 Q_SIGNALS:
116 void setPrivacy(bool privacy);
117 void transactionClicked();
118 void coinsSent();
119 /** Fired when a message should be reported to the user */
120 void message(const QString &title, const QString &message, unsigned int style);
121 /** Encryption status of wallet changed */
122 void encryptionStatusChanged();
123 /** Notify that a new transaction appeared */
124 void incomingTransaction(const QString& date, LimenkaUnit unit, const CAmount& amount, const QString& type, const QString& address, const QString& label, const QString& walletName);
125 /** Notify that the out of sync warning icon has been pressed */
126 void outOfSyncWarningClicked();
127 };
128 129 #endif // LIMENKA_QT_WALLETVIEW_H
130