1 // Copyright (c) 2011-2019 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_WALLETFRAME_H
6 #define BITCOIN_QT_WALLETFRAME_H
7 
8 #include <QFrame>
9 #include <QMap>
10 
11 class BitcoinGUI;
12 class ClientModel;
13 class PlatformStyle;
14 class SendCoinsRecipient;
15 class WalletModel;
16 class WalletView;
17 
18 QT_BEGIN_NAMESPACE
19 class QStackedWidget;
20 QT_END_NAMESPACE
21 
22 /**
23  * A container for embedding all wallet-related
24  * controls into BitcoinGUI. The purpose of this class is to allow future
25  * refinements of the wallet controls with minimal need for further
26  * modifications to BitcoinGUI, thus greatly simplifying merges while
27  * reducing the risk of breaking top-level stuff.
28  */
29 class WalletFrame : public QFrame
30 {
31     Q_OBJECT
32 
33 public:
34     explicit WalletFrame(const PlatformStyle *platformStyle, BitcoinGUI *_gui = nullptr);
35     ~WalletFrame();
36 
37     void setClientModel(ClientModel *clientModel);
38 
39     bool addWallet(WalletModel *walletModel);
40     void setCurrentWallet(WalletModel* wallet_model);
41     void removeWallet(WalletModel* wallet_model);
42     void removeAllWallets();
43 
44     bool handlePaymentRequest(const SendCoinsRecipient& recipient);
45 
46     void showOutOfSyncWarning(bool fShow);
47 
sizeHint()48     QSize sizeHint() const override { return m_size_hint; }
49 
50 Q_SIGNALS:
51     /** Notify that the user has requested more information about the out-of-sync warning */
52     void requestedSyncWarningInfo();
53 
54 private:
55     QStackedWidget *walletStack;
56     BitcoinGUI *gui;
57     ClientModel *clientModel;
58     QMap<WalletModel*, WalletView*> mapWalletViews;
59 
60     bool bOutOfSync;
61 
62     const PlatformStyle *platformStyle;
63 
64     const QSize m_size_hint;
65 
66 public:
67     WalletView* currentWalletView() const;
68     WalletModel* currentWalletModel() const;
69 
70 public Q_SLOTS:
71     /** Switch to overview (home) page */
72     void gotoOverviewPage();
73     /** Switch to history (transactions) page */
74     void gotoHistoryPage();
75     /** Switch to receive coins page */
76     void gotoReceiveCoinsPage();
77     /** Switch to send coins page */
78     void gotoSendCoinsPage(QString addr = "");
79 
80     /** Show Sign/Verify Message dialog and switch to sign message tab */
81     void gotoSignMessageTab(QString addr = "");
82     /** Show Sign/Verify Message dialog and switch to verify message tab */
83     void gotoVerifyMessageTab(QString addr = "");
84 
85     /** Load Partially Signed Bitcoin Transaction */
86     void gotoLoadPSBT(bool from_clipboard = false);
87 
88     /** Encrypt the wallet */
89     void encryptWallet(bool status);
90     /** Backup the wallet */
91     void backupWallet();
92     /** Change encrypted wallet passphrase */
93     void changePassphrase();
94     /** Ask for passphrase to unlock wallet temporarily */
95     void unlockWallet();
96 
97     /** Show used sending addresses */
98     void usedSendingAddresses();
99     /** Show used receiving addresses */
100     void usedReceivingAddresses();
101     /** Pass on signal over requested out-of-sync-warning information */
102     void outOfSyncWarningClicked();
103 };
104 
105 #endif // BITCOIN_QT_WALLETFRAME_H
106