]> Git Repo - VerusCoin.git/blob - src/qt/bitcoingui.h
Merge pull request #4926
[VerusCoin.git] / src / qt / bitcoingui.h
1 // Copyright (c) 2011-2014 The Bitcoin developers
2 // Distributed under the MIT/X11 software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5 #ifndef BITCOINGUI_H
6 #define BITCOINGUI_H
7
8 #if defined(HAVE_CONFIG_H)
9 #include "config/bitcoin-config.h"
10 #endif
11
12 #include "amount.h"
13
14 #include <QLabel>
15 #include <QMainWindow>
16 #include <QMap>
17 #include <QMenu>
18 #include <QPoint>
19 #include <QSystemTrayIcon>
20
21 class ClientModel;
22 class Notificator;
23 class OptionsModel;
24 class RPCConsole;
25 class SendCoinsRecipient;
26 class UnitDisplayStatusBarControl;
27 class WalletFrame;
28 class WalletModel;
29
30 class CWallet;
31
32 QT_BEGIN_NAMESPACE
33 class QAction;
34 class QProgressBar;
35 class QProgressDialog;
36 QT_END_NAMESPACE
37
38 /**
39   Bitcoin GUI main class. This class represents the main window of the Bitcoin UI. It communicates with both the client and
40   wallet models to give the user an up-to-date view of the current core state.
41 */
42 class BitcoinGUI : public QMainWindow
43 {
44     Q_OBJECT
45
46 public:
47     static const QString DEFAULT_WALLET;
48
49     explicit BitcoinGUI(bool fIsTestnet = false, QWidget *parent = 0);
50     ~BitcoinGUI();
51
52     /** Set the client model.
53         The client model represents the part of the core that communicates with the P2P network, and is wallet-agnostic.
54     */
55     void setClientModel(ClientModel *clientModel);
56
57 #ifdef ENABLE_WALLET
58     /** Set the wallet model.
59         The wallet model represents a bitcoin wallet, and offers access to the list of transactions, address book and sending
60         functionality.
61     */
62     bool addWallet(const QString& name, WalletModel *walletModel);
63     bool setCurrentWallet(const QString& name);
64     void removeAllWallets();
65 #endif
66
67 protected:
68     void changeEvent(QEvent *e);
69     void closeEvent(QCloseEvent *event);
70     void dragEnterEvent(QDragEnterEvent *event);
71     void dropEvent(QDropEvent *event);
72     bool eventFilter(QObject *object, QEvent *event);
73
74 private:
75     ClientModel *clientModel;
76     WalletFrame *walletFrame;
77
78     UnitDisplayStatusBarControl *unitDisplayControl;
79     QLabel *labelEncryptionIcon;
80     QLabel *labelConnectionsIcon;
81     QLabel *labelBlocksIcon;
82     QLabel *progressBarLabel;
83     QProgressBar *progressBar;
84     QProgressDialog *progressDialog;
85
86     QMenuBar *appMenuBar;
87     QAction *overviewAction;
88     QAction *historyAction;
89     QAction *quitAction;
90     QAction *sendCoinsAction;
91     QAction *usedSendingAddressesAction;
92     QAction *usedReceivingAddressesAction;
93     QAction *signMessageAction;
94     QAction *verifyMessageAction;
95     QAction *aboutAction;
96     QAction *receiveCoinsAction;
97     QAction *optionsAction;
98     QAction *toggleHideAction;
99     QAction *encryptWalletAction;
100     QAction *backupWalletAction;
101     QAction *changePassphraseAction;
102     QAction *aboutQtAction;
103     QAction *openRPCConsoleAction;
104     QAction *openAction;
105     QAction *showHelpMessageAction;
106
107     QSystemTrayIcon *trayIcon;
108     QMenu *trayIconMenu;
109     Notificator *notificator;
110     RPCConsole *rpcConsole;
111
112     /** Keep track of previous number of blocks, to detect progress */
113     int prevBlocks;
114     int spinnerFrame;
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     /** Enable or disable all wallet-related actions */
128     void setWalletActionsEnabled(bool enabled);
129
130     /** Connect core signals to GUI client */
131     void subscribeToCoreSignals();
132     /** Disconnect core signals from GUI client */
133     void unsubscribeFromCoreSignals();
134
135 signals:
136     /** Signal raised when a URI was entered or dragged to the GUI */
137     void receivedURI(const QString &uri);
138
139 public slots:
140     /** Set number of connections shown in the UI */
141     void setNumConnections(int count);
142     /** Set number of blocks shown in the UI */
143     void setNumBlocks(int count);
144
145     /** Notify the user of an event from the core network or transaction handling code.
146        @param[in] title     the message box / notification title
147        @param[in] message   the displayed text
148        @param[in] style     modality and style definitions (icon and used buttons - buttons only for message boxes)
149                             @see CClientUIInterface::MessageBoxFlags
150        @param[in] ret       pointer to a bool that will be modified to whether Ok was clicked (modal only)
151     */
152     void message(const QString &title, const QString &message, unsigned int style, bool *ret = NULL);
153
154 #ifdef ENABLE_WALLET
155     /** Set the encryption status as shown in the UI.
156        @param[in] status            current encryption status
157        @see WalletModel::EncryptionStatus
158     */
159     void setEncryptionStatus(int status);
160
161     bool handlePaymentRequest(const SendCoinsRecipient& recipient);
162
163     /** Show incoming transaction notification for new transactions. */
164     void incomingTransaction(const QString& date, int unit, const CAmount& amount, const QString& type, const QString& address);
165 #endif
166
167 private slots:
168 #ifdef ENABLE_WALLET
169     /** Switch to overview (home) page */
170     void gotoOverviewPage();
171     /** Switch to history (transactions) page */
172     void gotoHistoryPage();
173     /** Switch to receive coins page */
174     void gotoReceiveCoinsPage();
175     /** Switch to send coins page */
176     void gotoSendCoinsPage(QString addr = "");
177
178     /** Show Sign/Verify Message dialog and switch to sign message tab */
179     void gotoSignMessageTab(QString addr = "");
180     /** Show Sign/Verify Message dialog and switch to verify message tab */
181     void gotoVerifyMessageTab(QString addr = "");
182
183     /** Show open dialog */
184     void openClicked();
185 #endif
186     /** Show configuration dialog */
187     void optionsClicked();
188     /** Show about dialog */
189     void aboutClicked();
190     /** Show help message dialog */
191     void showHelpMessageClicked();
192 #ifndef Q_OS_MAC
193     /** Handle tray icon clicked */
194     void trayIconActivated(QSystemTrayIcon::ActivationReason reason);
195 #endif
196
197     /** Show window if hidden, unminimize when minimized, rise when obscured or show if hidden and fToggleHidden is true */
198     void showNormalIfMinimized(bool fToggleHidden = false);
199     /** Simply calls showNormalIfMinimized(true) for use in SLOT() macro */
200     void toggleHidden();
201
202     /** called by a timer to check if fRequestShutdown has been set **/
203     void detectShutdown();
204
205     /** Show progress dialog e.g. for verifychain */
206     void showProgress(const QString &title, int nProgress);
207 };
208
209 class UnitDisplayStatusBarControl : public QLabel
210 {
211     Q_OBJECT
212
213 public:
214     explicit UnitDisplayStatusBarControl();
215     /** Lets the control know about the Options Model (and its signals) */
216     void setOptionsModel(OptionsModel *optionsModel);
217
218 protected:
219     /** So that it responds to left-button clicks */
220     void mousePressEvent(QMouseEvent *event);
221
222 private:
223     OptionsModel *optionsModel;
224     QMenu* menu;
225
226     /** Shows context menu with Display Unit options by the mouse coordinates */
227     void onDisplayUnitsClicked(const QPoint& point);
228     /** Creates context menu, its actions, and wires up all the relevant signals for mouse events. */
229     void createContextMenu();
230
231 private slots:
232     /** When Display Units are changed on OptionsModel it will refresh the display text of the control on the status bar */
233     void updateDisplayUnit(int newUnits);
234     /** Tells underlying optionsModel to update its current display unit. */
235     void onMenuSelection(QAction* action);
236 };
237
238 #endif // BITCOINGUI_H
This page took 0.037591 seconds and 4 git commands to generate.