Dogecoin Core  1.14.2
P2P Digital Currency
bitcoingui.h
Go to the documentation of this file.
1 // Copyright (c) 2011-2016 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_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 PlatformStyle;
26 class RPCConsole;
27 class SendCoinsRecipient;
29 class WalletFrame;
30 class WalletModel;
31 class HelpMessageDialog;
32 class ModalOverlay;
33 
34 class CWallet;
35 
36 QT_BEGIN_NAMESPACE
37 class QAction;
38 class QProgressBar;
39 class QProgressDialog;
40 QT_END_NAMESPACE
41 
46 class BitcoinGUI : public QMainWindow
47 {
48  Q_OBJECT
49 
50 public:
51  static const QString DEFAULT_WALLET;
52  static const std::string DEFAULT_UIPLATFORM;
53 
54  explicit BitcoinGUI(const PlatformStyle *platformStyle, const NetworkStyle *networkStyle, QWidget *parent = 0);
55  ~BitcoinGUI();
56 
61 
62 #ifdef ENABLE_WALLET
67  bool addWallet(const QString& name, WalletModel *walletModel);
68  bool setCurrentWallet(const QString& name);
69  void removeAllWallets();
70 #endif // ENABLE_WALLET
72 
73 protected:
74  void changeEvent(QEvent *e);
75  void closeEvent(QCloseEvent *event);
76  void showEvent(QShowEvent *event);
77  void dragEnterEvent(QDragEnterEvent *event);
78  void dropEvent(QDropEvent *event);
79  bool eventFilter(QObject *object, QEvent *event);
80 
81 private:
84 
89  QLabel *labelBlocksIcon;
91  QProgressBar *progressBar;
92  QProgressDialog *progressDialog;
93 
94  QMenuBar *appMenuBar;
95  QAction *overviewAction;
96  QAction *historyAction;
97  QAction *quitAction;
98  QAction *sendCoinsAction;
105  QAction *aboutAction;
108  QAction *optionsAction;
113  QAction *aboutQtAction;
115  QAction *openAction;
117 
118  QSystemTrayIcon *trayIcon;
119  QMenu *trayIconMenu;
124 
128 
130 
132  void createActions();
134  void createMenuBar();
136  void createToolBars();
138  void createTrayIcon(const NetworkStyle *networkStyle);
140  void createTrayIconMenu();
141 
143  void setWalletActionsEnabled(bool enabled);
144 
146  void subscribeToCoreSignals();
149 
151  void updateNetworkState();
152 
154 
155 Q_SIGNALS:
157  void receivedURI(const QString &uri);
158 
159 public Q_SLOTS:
161  void setNumConnections(int count);
163  void setNetworkActive(bool networkActive);
165  void setNumBlocks(int count, const QDateTime& blockDate, double nVerificationProgress, bool headers);
166 
174  void message(const QString &title, const QString &message, unsigned int style, bool *ret = NULL);
175 
176 #ifdef ENABLE_WALLET
181  void setEncryptionStatus(int status);
182 
187  void setHDStatus(int hdEnabled);
188 
189  bool handlePaymentRequest(const SendCoinsRecipient& recipient);
190 
192  void incomingTransaction(const QString& date, int unit, const CAmount& amount, const QString& type, const QString& address, const QString& label);
193 #endif // ENABLE_WALLET
194 
195 private Q_SLOTS:
196 #ifdef ENABLE_WALLET
198  void gotoOverviewPage();
200  void gotoHistoryPage();
202  void gotoReceiveCoinsPage();
204  void gotoSendCoinsPage(QString addr = "");
205 
207  void gotoSignMessageTab(QString addr = "");
209  void gotoVerifyMessageTab(QString addr = "");
210 
212  void openClicked();
213 #endif // ENABLE_WALLET
215  void optionsClicked();
217  void aboutClicked();
219  void showDebugWindow();
223  void showHelpMessageClicked();
224 #ifndef Q_OS_MAC
226  void trayIconActivated(QSystemTrayIcon::ActivationReason reason);
227 #endif
228 
230  void showNormalIfMinimized(bool fToggleHidden = false);
232  void toggleHidden();
233 
235  void detectShutdown();
236 
238  void showProgress(const QString &title, int nProgress);
239 
241  void setTrayIconVisible(bool);
242 
244  void toggleNetworkActive();
245 
246  void showModalOverlay();
247 };
248 
249 class UnitDisplayStatusBarControl : public QLabel
250 {
251  Q_OBJECT
252 
253 public:
254  explicit UnitDisplayStatusBarControl(const PlatformStyle *platformStyle);
257 
258 protected:
260  void mousePressEvent(QMouseEvent *event);
261 
262 private:
264  QMenu* menu;
265 
267  void onDisplayUnitsClicked(const QPoint& point);
269  void createContextMenu();
270 
271 private Q_SLOTS:
273  void updateDisplayUnit(int newUnits);
275  void onMenuSelection(QAction* action);
276 };
277 
278 #endif // BITCOIN_QT_BITCOINGUI_H
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:15
Bitcoin GUI main class.
Definition: bitcoingui.h:47
QLabel * progressBarLabel
Definition: bitcoingui.h:90
void showNormalIfMinimized(bool fToggleHidden=false)
Show window if hidden, unminimize when minimized, rise when obscured or show if hidden and fToggleHid...
static const std::string DEFAULT_UIPLATFORM
Definition: bitcoingui.h:52
QAction * openAction
Definition: bitcoingui.h:115
void createTrayIcon(const NetworkStyle *networkStyle)
Create system tray icon and notification.
Definition: bitcoingui.cpp:595
void changeEvent(QEvent *e)
Definition: bitcoingui.cpp:955
void receivedURI(const QString &uri)
Signal raised when a URI was entered or dragged to the GUI.
ModalOverlay * modalOverlay
Definition: bitcoingui.h:123
QAction * paperWalletAction
Definition: bitcoingui.h:104
QAction * changePassphraseAction
Definition: bitcoingui.h:112
void dropEvent(QDropEvent *event)
QAction * receiveCoinsMenuAction
Definition: bitcoingui.h:107
int prevBlocks
Keep track of previous number of blocks, to detect progress.
Definition: bitcoingui.h:126
QAction * openRPCConsoleAction
Definition: bitcoingui.h:114
QMenu * trayIconMenu
Definition: bitcoingui.h:119
QAction * historyAction
Definition: bitcoingui.h:96
QAction * toggleHideAction
Definition: bitcoingui.h:109
QAction * quitAction
Definition: bitcoingui.h:97
void toggleNetworkActive()
Toggle networking.
QProgressBar * progressBar
Definition: bitcoingui.h:91
QProgressDialog * progressDialog
Definition: bitcoingui.h:92
WalletFrame * walletFrame
Definition: bitcoingui.h:83
QAction * receiveCoinsAction
Definition: bitcoingui.h:106
QAction * usedSendingAddressesAction
Definition: bitcoingui.h:100
void unsubscribeFromCoreSignals()
Disconnect core signals from GUI client.
QAction * verifyMessageAction
Definition: bitcoingui.h:103
void createTrayIconMenu()
Create system tray menu (or setup the dock menu)
Definition: bitcoingui.cpp:608
HelpMessageDialog * helpMessageDialog
Definition: bitcoingui.h:122
BitcoinGUI(const PlatformStyle *platformStyle, const NetworkStyle *networkStyle, QWidget *parent=0)
Definition: bitcoingui.cpp:84
void aboutClicked()
Show about dialog.
Definition: bitcoingui.cpp:665
void toggleHidden()
Simply calls showNormalIfMinimized(true) for use in SLOT() macro.
void setNumBlocks(int count, const QDateTime &blockDate, double nVerificationProgress, bool headers)
Set number of blocks and last block date shown in the UI.
Definition: bitcoingui.cpp:786
QAction * encryptWalletAction
Definition: bitcoingui.h:110
void updateNetworkState()
Update UI with latest network info from model.
Definition: bitcoingui.cpp:738
void createActions()
Create the main UI actions.
Definition: bitcoingui.cpp:293
void showDebugWindow()
Show debug window.
Definition: bitcoingui.cpp:674
QLabel * labelBlocksIcon
Definition: bitcoingui.h:89
int spinnerFrame
Definition: bitcoingui.h:127
QAction * aboutAction
Definition: bitcoingui.h:105
void showDebugWindowActivateConsole()
Show debug window and set focus to the console.
Definition: bitcoingui.cpp:682
void showProgress(const QString &title, int nProgress)
Show progress dialog e.g.
void dragEnterEvent(QDragEnterEvent *event)
QAction * usedReceivingAddressesAction
Definition: bitcoingui.h:101
void subscribeToCoreSignals()
Connect core signals to GUI client.
void createToolBars()
Create the toolbars.
Definition: bitcoingui.cpp:474
QLabel * connectionsControl
Definition: bitcoingui.h:88
void showEvent(QShowEvent *event)
Definition: bitcoingui.cpp:997
UnitDisplayStatusBarControl * unitDisplayControl
Definition: bitcoingui.h:85
void setClientModel(ClientModel *clientModel)
Set the client model.
Definition: bitcoingui.cpp:489
QAction * optionsAction
Definition: bitcoingui.h:108
void setWalletActionsEnabled(bool enabled)
Enable or disable all wallet-related actions.
Definition: bitcoingui.cpp:576
const PlatformStyle * platformStyle
Definition: bitcoingui.h:129
QLabel * labelWalletEncryptionIcon
Definition: bitcoingui.h:86
QAction * overviewAction
Definition: bitcoingui.h:95
void detectShutdown()
called by a timer to check if fRequestShutdown has been set
bool enableWallet
Definition: bitcoingui.h:71
RPCConsole * rpcConsole
Definition: bitcoingui.h:121
QAction * backupWalletAction
Definition: bitcoingui.h:111
void message(const QString &title, const QString &message, unsigned int style, bool *ret=NULL)
Notify the user of an event from the core network or transaction handling code.
Definition: bitcoingui.cpp:896
QAction * sendCoinsMenuAction
Definition: bitcoingui.h:99
QAction * showHelpMessageAction
Definition: bitcoingui.h:116
QAction * aboutQtAction
Definition: bitcoingui.h:113
void closeEvent(QCloseEvent *event)
Definition: bitcoingui.cpp:974
ClientModel * clientModel
Definition: bitcoingui.h:82
void updateHeadersSyncProgressLabel()
Definition: bitcoingui.cpp:777
void setTrayIconVisible(bool)
When hideTrayIcon setting is changed in OptionsModel hide or show the icon accordingly.
void createMenuBar()
Create the menu bar and sub-menus.
Definition: bitcoingui.cpp:428
QSystemTrayIcon * trayIcon
Definition: bitcoingui.h:118
static const QString DEFAULT_WALLET
Display name for default wallet name.
Definition: bitcoingui.h:51
void showHelpMessageClicked()
Show help message dialog.
Definition: bitcoingui.cpp:688
QAction * sendCoinsAction
Definition: bitcoingui.h:98
QLabel * labelWalletHDStatusIcon
Definition: bitcoingui.h:87
void setNumConnections(int count)
Set number of connections shown in the UI.
Definition: bitcoingui.cpp:767
void trayIconActivated(QSystemTrayIcon::ActivationReason reason)
Handle tray icon clicked.
Definition: bitcoingui.cpp:645
QAction * signMessageAction
Definition: bitcoingui.h:102
bool eventFilter(QObject *object, QEvent *event)
void showModalOverlay()
Notificator * notificator
Definition: bitcoingui.h:120
QMenuBar * appMenuBar
Definition: bitcoingui.h:94
void setNetworkActive(bool networkActive)
Set network state shown in the UI.
Definition: bitcoingui.cpp:772
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances,...
Definition: wallet.h:493
Model for Bitcoin network client.
Definition: clientmodel.h:42
"Help message" dialog box
Definition: utilitydialog.h:46
Modal overlay to display information about the chain-sync state.
Definition: modaloverlay.h:20
Cross-platform desktop notification client.
Definition: notificator.h:25
Interface from Qt to configuration data structure for Bitcoin client.
Definition: optionsmodel.h:23
Local Bitcoin RPC console.
Definition: rpcconsole.h:32
void updateDisplayUnit(int newUnits)
When Display Units are changed on OptionsModel it will refresh the display text of the control on the...
void createContextMenu()
Creates context menu, its actions, and wires up all the relevant signals for mouse events.
OptionsModel * optionsModel
Definition: bitcoingui.h:263
void mousePressEvent(QMouseEvent *event)
So that it responds to left-button clicks.
UnitDisplayStatusBarControl(const PlatformStyle *platformStyle)
void onMenuSelection(QAction *action)
Tells underlying optionsModel to update its current display unit.
void setOptionsModel(OptionsModel *optionsModel)
Lets the control know about the Options Model (and its signals)
void onDisplayUnitsClicked(const QPoint &point)
Shows context menu with Display Unit options by the mouse coordinates.
A container for embedding all wallet-related controls into BitcoinGUI.
Definition: walletframe.h:30
Interface to Bitcoin wallet from Qt view code.
Definition: walletmodel.h:99