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.
5 #ifndef BITCOIN_QT_BITCOINGUI_H
6 #define BITCOIN_QT_BITCOINGUI_H
8 #if defined(HAVE_CONFIG_H)
9 #include "config/bitcoin-config.h"
15 #include <QMainWindow>
19 #include <QSystemTrayIcon>
26 class SendCoinsRecipient;
27 class UnitDisplayStatusBarControl;
36 class QProgressDialog;
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.
43 class BitcoinGUI : public QMainWindow
48 static const QString DEFAULT_WALLET;
50 explicit BitcoinGUI(const NetworkStyle *networkStyle, QWidget *parent = 0);
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.
56 void setClientModel(ClientModel *clientModel);
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
63 bool addWallet(const QString& name, WalletModel *walletModel);
64 bool setCurrentWallet(const QString& name);
65 void removeAllWallets();
66 #endif // ENABLE_WALLET
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);
77 ClientModel *clientModel;
78 WalletFrame *walletFrame;
80 UnitDisplayStatusBarControl *unitDisplayControl;
81 QLabel *labelEncryptionIcon;
82 QLabel *labelConnectionsIcon;
83 QLabel *labelBlocksIcon;
84 QLabel *progressBarLabel;
85 QProgressBar *progressBar;
86 QProgressDialog *progressDialog;
89 QAction *overviewAction;
90 QAction *historyAction;
92 QAction *sendCoinsAction;
93 QAction *usedSendingAddressesAction;
94 QAction *usedReceivingAddressesAction;
95 QAction *signMessageAction;
96 QAction *verifyMessageAction;
98 QAction *receiveCoinsAction;
99 QAction *optionsAction;
100 QAction *toggleHideAction;
101 QAction *encryptWalletAction;
102 QAction *backupWalletAction;
103 QAction *changePassphraseAction;
104 QAction *aboutQtAction;
105 QAction *openRPCConsoleAction;
107 QAction *showHelpMessageAction;
109 QSystemTrayIcon *trayIcon;
111 Notificator *notificator;
112 RPCConsole *rpcConsole;
114 /** Keep track of previous number of blocks, to detect progress */
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();
129 /** Enable or disable all wallet-related actions */
130 void setWalletActionsEnabled(bool enabled);
132 /** Connect core signals to GUI client */
133 void subscribeToCoreSignals();
134 /** Disconnect core signals from GUI client */
135 void unsubscribeFromCoreSignals();
138 /** Signal raised when a URI was entered or dragged to the GUI */
139 void receivedURI(const QString &uri);
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);
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)
154 void message(const QString &title, const QString &message, unsigned int style, bool *ret = NULL);
157 /** Set the encryption status as shown in the UI.
158 @param[in] status current encryption status
159 @see WalletModel::EncryptionStatus
161 void setEncryptionStatus(int status);
163 bool handlePaymentRequest(const SendCoinsRecipient& recipient);
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
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 = "");
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 = "");
185 /** Show open dialog */
187 #endif // ENABLE_WALLET
188 /** Show configuration dialog */
189 void optionsClicked();
190 /** Show about dialog */
192 /** Show help message dialog */
193 void showHelpMessageClicked();
195 /** Handle tray icon clicked */
196 void trayIconActivated(QSystemTrayIcon::ActivationReason reason);
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 */
204 /** called by a timer to check if fRequestShutdown has been set **/
205 void detectShutdown();
207 /** Show progress dialog e.g. for verifychain */
208 void showProgress(const QString &title, int nProgress);
211 class UnitDisplayStatusBarControl : public QLabel
216 explicit UnitDisplayStatusBarControl();
217 /** Lets the control know about the Options Model (and its signals) */
218 void setOptionsModel(OptionsModel *optionsModel);
221 /** So that it responds to left-button clicks */
222 void mousePressEvent(QMouseEvent *event);
225 OptionsModel *optionsModel;
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();
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);
240 #endif // BITCOIN_QT_BITCOINGUI_H