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