]> Git Repo - VerusCoin.git/blob - src/qt/bitcoingui.h
Merge pull request #2539 from gavinandresen/paymentrequest
[VerusCoin.git] / src / qt / bitcoingui.h
1 #ifndef BITCOINGUI_H
2 #define BITCOINGUI_H
3
4 #include <QMainWindow>
5 #include <QSystemTrayIcon>
6 #include <QMap>
7
8 class TransactionTableModel;
9 class WalletFrame;
10 class WalletView;
11 class ClientModel;
12 class WalletModel;
13 class WalletStack;
14 class TransactionView;
15 class OverviewPage;
16 class AddressBookPage;
17 class SendCoinsDialog;
18 class SendCoinsRecipient;
19 class SignVerifyMessageDialog;
20 class Notificator;
21 class RPCConsole;
22
23 class CWallet;
24
25 QT_BEGIN_NAMESPACE
26 class QLabel;
27 class QModelIndex;
28 class QProgressBar;
29 class QStackedWidget;
30 class QUrl;
31 class QListWidget;
32 class QPushButton;
33 class QAction;
34 QT_END_NAMESPACE
35
36 /**
37   Bitcoin GUI main class. This class represents the main window of the Bitcoin UI. It communicates with both the client and
38   wallet models to give the user an up-to-date view of the current core state.
39 */
40 class BitcoinGUI : public QMainWindow
41 {
42     Q_OBJECT
43
44 public:
45     static const QString DEFAULT_WALLET;
46
47     explicit BitcoinGUI(bool fIsTestnet = false, QWidget *parent = 0);
48     ~BitcoinGUI();
49
50     /** Set the client model.
51         The client model represents the part of the core that communicates with the P2P network, and is wallet-agnostic.
52     */
53     void setClientModel(ClientModel *clientModel);
54     /** Set the wallet model.
55         The wallet model represents a bitcoin wallet, and offers access to the list of transactions, address book and sending
56         functionality.
57     */
58
59     bool addWallet(const QString& name, WalletModel *walletModel);
60     bool setCurrentWallet(const QString& name);
61
62     void removeAllWallets();
63
64     /** Used by WalletView to allow access to needed QActions */
65     // Todo: Use Qt signals for these
66     QAction * getOverviewAction() { return overviewAction; }
67     QAction * getHistoryAction() { return historyAction; }
68     QAction * getAddressBookAction() { return addressBookAction; }
69     QAction * getReceiveCoinsAction() { return receiveCoinsAction; }
70     QAction * getSendCoinsAction() { return sendCoinsAction; }
71
72 protected:
73     void changeEvent(QEvent *e);
74     void closeEvent(QCloseEvent *event);
75     void dragEnterEvent(QDragEnterEvent *event);
76     void dropEvent(QDropEvent *event);
77     bool eventFilter(QObject *object, QEvent *event);
78
79 private:
80     ClientModel *clientModel;
81     WalletFrame *walletFrame;
82
83     QLabel *labelEncryptionIcon;
84     QLabel *labelConnectionsIcon;
85     QLabel *labelBlocksIcon;
86     QLabel *progressBarLabel;
87     QProgressBar *progressBar;
88
89     QMenuBar *appMenuBar;
90     QAction *overviewAction;
91     QAction *historyAction;
92     QAction *quitAction;
93     QAction *sendCoinsAction;
94     QAction *addressBookAction;
95     QAction *signMessageAction;
96     QAction *verifyMessageAction;
97     QAction *aboutAction;
98     QAction *receiveCoinsAction;
99     QAction *optionsAction;
100     QAction *toggleHideAction;
101     QAction *encryptWalletAction;
102     QAction *backupWalletAction;
103     QAction *changePassphraseAction;
104     QAction *aboutQtAction;
105     QAction *openRPCConsoleAction;
106
107     QSystemTrayIcon *trayIcon;
108     Notificator *notificator;
109     TransactionView *transactionView;
110     RPCConsole *rpcConsole;
111
112     QMovie *syncIconMovie;
113     /** Keep track of previous number of blocks, to detect progress */
114     int prevBlocks;
115
116     /** Create the main UI actions. */
117     void createActions(bool fIsTestnet);
118     /** Create the menu bar and sub-menus. */
119     void createMenuBar();
120     /** Create the toolbars */
121     void createToolBars();
122     /** Create system tray icon and notification */
123     void createTrayIcon(bool fIsTestnet);
124     /** Create system tray menu (or setup the dock menu) */
125     void createTrayIconMenu();
126
127 public slots:
128     /** Set number of connections shown in the UI */
129     void setNumConnections(int count);
130     /** Set number of blocks shown in the UI */
131     void setNumBlocks(int count, int nTotalBlocks);
132     /** Set the encryption status as shown in the UI.
133        @param[in] status            current encryption status
134        @see WalletModel::EncryptionStatus
135     */
136     void setEncryptionStatus(int status);
137
138     /** Notify the user of an event from the core network or transaction handling code.
139        @param[in] title     the message box / notification title
140        @param[in] message   the displayed text
141        @param[in] style     modality and style definitions (icon and used buttons - buttons only for message boxes)
142                             @see CClientUIInterface::MessageBoxFlags
143        @param[in] ret       pointer to a bool that will be modified to whether Ok was clicked (modal only)
144     */
145     void message(const QString &title, const QString &message, unsigned int style, bool *ret = NULL);
146     /** Asks the user whether to pay the transaction fee or to cancel the transaction.
147        It is currently not possible to pass a return value to another thread through
148        BlockingQueuedConnection, so an indirected pointer is used.
149        https://bugreports.qt-project.org/browse/QTBUG-10440
150
151       @param[in] nFeeRequired       the required fee
152       @param[out] payFee            true to pay the fee, false to not pay the fee
153     */
154     void askFee(qint64 nFeeRequired, bool *payFee);
155
156     void handlePaymentRequest(const SendCoinsRecipient& recipient);
157     void showPaymentACK(QString msg);
158
159     /** Show incoming transaction notification for new transactions. */
160     void incomingTransaction(const QString& date, int unit, qint64 amount, const QString& type, const QString& address);
161
162 private slots:
163     /** Switch to overview (home) page */
164     void gotoOverviewPage();
165     /** Switch to history (transactions) page */
166     void gotoHistoryPage();
167     /** Switch to address book page */
168     void gotoAddressBookPage();
169     /** Switch to receive coins page */
170     void gotoReceiveCoinsPage();
171     /** Switch to send coins page */
172     void gotoSendCoinsPage(QString addr = "");
173
174     /** Show Sign/Verify Message dialog and switch to sign message tab */
175     void gotoSignMessageTab(QString addr = "");
176     /** Show Sign/Verify Message dialog and switch to verify message tab */
177     void gotoVerifyMessageTab(QString addr = "");
178
179     /** Show configuration dialog */
180     void optionsClicked();
181     /** Show about dialog */
182     void aboutClicked();
183 #ifndef Q_OS_MAC
184     /** Handle tray icon clicked */
185     void trayIconActivated(QSystemTrayIcon::ActivationReason reason);
186 #endif
187
188     /** Show window if hidden, unminimize when minimized, rise when obscured or show if hidden and fToggleHidden is true */
189     void showNormalIfMinimized(bool fToggleHidden = false);
190     /** Simply calls showNormalIfMinimized(true) for use in SLOT() macro */
191     void toggleHidden();
192
193     /** called by a timer to check if fRequestShutdown has been set **/
194     void detectShutdown();
195 };
196
197 #endif // BITCOINGUI_H
This page took 0.033143 seconds and 4 git commands to generate.