Bitcoin ABC 0.34.5
P2P Digital Currency
Loading...
Searching...
No Matches
bitcoingui.h
Go to the documentation of this file.
1// Copyright (c) 2011-2019 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 <qt/clientmodel.h>
13#include <qt/optionsdialog.h>
14
15#include <consensus/amount.h>
16
17#include <QLabel>
18#include <QMainWindow>
19#include <QMap>
20#include <QPoint>
21#include <QSystemTrayIcon>
22
23#ifdef Q_OS_MAC
24#include <qt/macos_appnap.h>
25#endif
26
27#include <memory>
28
29class Config;
31class ModalOverlay;
32class NetworkStyle;
33class Notificator;
34class OptionsModel;
35class PlatformStyle;
36class RPCConsole;
38enum class SynchronizationState;
41class WalletFrame;
42class WalletModel;
43
44namespace interfaces {
45class Handler;
46class Node;
47struct BlockAndHeaderTipInfo;
48} // namespace interfaces
49
50QT_BEGIN_NAMESPACE
51class QAction;
52class QComboBox;
53class QMenu;
54class QProgressBar;
55class QProgressDialog;
56QT_END_NAMESPACE
57
58namespace GUIUtil {
59class ClickableLabel;
61} // namespace GUIUtil
62
68class BitcoinGUI : public QMainWindow {
69 Q_OBJECT
70
71public:
72 static const std::string DEFAULT_UIPLATFORM;
73
74 explicit BitcoinGUI(interfaces::Node &node, const Config &,
76 const NetworkStyle *networkStyle,
77 QWidget *parent = nullptr);
79
86 interfaces::BlockAndHeaderTipInfo *tip_info = nullptr);
87#ifdef ENABLE_WALLET
88 void setWalletController(WalletController *wallet_controller);
89 WalletController *getWalletController();
90#endif
91
92#ifdef ENABLE_WALLET
98 void addWallet(WalletModel *walletModel);
99 void removeWallet(WalletModel *walletModel);
100 void removeAllWallets();
101#endif // ENABLE_WALLET
102 bool enableWallet = false;
103
106
107 bool isPrivacyModeActivated() const;
108
113 bool hasTrayIcon() const { return trayIcon; }
114
115protected:
116 void changeEvent(QEvent *e) override;
117 void closeEvent(QCloseEvent *event) override;
118 void showEvent(QShowEvent *event) override;
119 void dragEnterEvent(QDragEnterEvent *event) override;
120 void dropEvent(QDropEvent *event) override;
121 bool eventFilter(QObject *object, QEvent *event) override;
122
123private:
126 std::unique_ptr<interfaces::Handler> m_handler_message_box;
127 std::unique_ptr<interfaces::Handler> m_handler_question;
130
132 QLabel *labelWalletEncryptionIcon = nullptr;
133 QLabel *labelWalletHDStatusIcon = nullptr;
137 QLabel *progressBarLabel = nullptr;
139 QProgressDialog *progressDialog = nullptr;
140
141 QMenuBar *appMenuBar = nullptr;
142 QToolBar *appToolBar = nullptr;
143 QAction *overviewAction = nullptr;
144 QAction *historyAction = nullptr;
145 QAction *quitAction = nullptr;
146 QAction *sendCoinsAction = nullptr;
147 QAction *usedSendingAddressesAction = nullptr;
149 QAction *signMessageAction = nullptr;
150 QAction *verifyMessageAction = nullptr;
151 QAction *m_load_psbt_action = nullptr;
152 QAction *aboutAction = nullptr;
153 QAction *receiveCoinsAction = nullptr;
154 QAction *optionsAction = nullptr;
155 QAction *encryptWalletAction = nullptr;
156 QAction *backupWalletAction = nullptr;
157 QAction *changePassphraseAction = nullptr;
158 QAction *aboutQtAction = nullptr;
159 QAction *openRPCConsoleAction = nullptr;
160 QAction *openAction = nullptr;
161 QAction *showHelpMessageAction = nullptr;
162 QAction *m_create_wallet_action{nullptr};
163 QAction *m_open_wallet_action{nullptr};
164 QMenu *m_open_wallet_menu{nullptr};
165 QAction *m_close_wallet_action{nullptr};
166 QAction *m_close_all_wallets_action{nullptr};
168 QAction *m_wallet_selector_action = nullptr;
169 QAction *m_mask_values_action{nullptr};
170
171 QLabel *m_wallet_selector_label = nullptr;
172 QComboBox *m_wallet_selector = nullptr;
173
174 QSystemTrayIcon *trayIcon = nullptr;
175 const std::unique_ptr<QMenu> trayIconMenu;
180
181#ifdef Q_OS_MAC
182 CAppNapInhibitor *m_app_nap_inhibitor = nullptr;
183#endif
184
186 int prevBlocks = 0;
188
192
194 void createActions();
196 void createMenuBar();
198 void createToolBars();
200 void createTrayIcon();
202 void createTrayIconMenu();
203
205 void setWalletActionsEnabled(bool enabled);
206
209
211 void updateNetworkState();
212
214 void updateHeadersPresyncProgressLabel(int64_t height,
215 const QDateTime &blockDate);
216
219
220Q_SIGNALS:
223 void receivedURI(const QString &uri);
225 void consoleShown(RPCConsole *console);
226 void setPrivacy(bool privacy);
227
228public Q_SLOTS:
230 void setNumConnections(int count);
232 void setNetworkActive(bool networkActive);
234 void setNumBlocks(int count, const QDateTime &blockDate,
235 double nVerificationProgress, SyncType synctype,
236 SynchronizationState sync_state);
237
250 void message(const QString &title, QString message, unsigned int style,
251 bool *ret = nullptr,
252 const QString &detailed_message = QString());
253
254#ifdef ENABLE_WALLET
255 void setCurrentWallet(WalletModel *wallet_model);
256 void setCurrentWalletBySelectorIndex(int index);
259 void updateWalletStatus();
260
261private:
266 void setEncryptionStatus(int status);
267
272 void setHDStatus(bool privkeyDisabled, int hdEnabled);
273
274public Q_SLOTS:
275 bool handlePaymentRequest(const SendCoinsRecipient &recipient);
276
278 void incomingTransaction(const QString &date, int unit, const Amount amount,
279 const QString &type, const QString &address,
280 const QString &label, const QString &walletName);
281#endif // ENABLE_WALLET
282
283private:
285 void updateProxyIcon();
286 void updateWindowTitle();
287
288public Q_SLOTS:
289#ifdef ENABLE_WALLET
291 void gotoOverviewPage();
293 void gotoHistoryPage();
295 void gotoReceiveCoinsPage();
297 void gotoSendCoinsPage(QString addr = "");
298
300 void gotoSignMessageTab(QString addr = "");
302 void gotoVerifyMessageTab(QString addr = "");
304 void gotoLoadPSBT();
305
307 void openClicked();
308#endif // ENABLE_WALLET
310 void optionsClicked();
312 void aboutClicked();
314 void showDebugWindow();
319
323 void showNormalIfMinimized(bool fToggleHidden);
325 void toggleHidden();
326
328 void detectShutdown();
329
331 void showProgress(const QString &title, int nProgress);
332
335 void setTrayIconVisible(bool);
336
337 void showModalOverlay();
338};
339
340class UnitDisplayStatusBarControl : public QLabel {
341 Q_OBJECT
342
343public:
344 explicit UnitDisplayStatusBarControl(const PlatformStyle *platformStyle);
347
348protected:
350 void mousePressEvent(QMouseEvent *event) override;
351
352private:
354 QMenu *menu;
355
357 void onDisplayUnitsClicked(const QPoint &point);
360 void createContextMenu();
361
362private Q_SLOTS:
365 void updateDisplayUnit(int newUnits);
367 void onMenuSelection(QAction *action);
368};
369
370#endif // BITCOIN_QT_BITCOINGUI_H
Bitcoin GUI main class.
Definition bitcoingui.h:68
void updateHeadersPresyncProgressLabel(int64_t height, const QDateTime &blockDate)
GUIUtil::ClickableProgressBar * progressBar
Definition bitcoingui.h:138
QAction * m_close_all_wallets_action
Definition bitcoingui.h:166
void showEvent(QShowEvent *event) override
QLabel * progressBarLabel
Definition bitcoingui.h:137
QAction * m_open_wallet_action
Definition bitcoingui.h:163
static const std::string DEFAULT_UIPLATFORM
Definition bitcoingui.h:72
QAction * openAction
Definition bitcoingui.h:160
void setNumBlocks(int count, const QDateTime &blockDate, double nVerificationProgress, SyncType synctype, SynchronizationState sync_state)
Set number of blocks and last block date shown in the UI.
void setClientModel(ClientModel *clientModel=nullptr, interfaces::BlockAndHeaderTipInfo *tip_info=nullptr)
Set the client model.
GUIUtil::ClickableLabel * connectionsControl
Definition bitcoingui.h:135
void receivedURI(const QString &uri)
Signal raised when a URI was entered or dragged to the GUI.
ModalOverlay * modalOverlay
Definition bitcoingui.h:179
QAction * changePassphraseAction
Definition bitcoingui.h:157
void openOptionsDialogWithTab(OptionsDialog::Tab tab)
Open the OptionsDialog on the specified tab index.
int prevBlocks
Keep track of previous number of blocks, to detect progress.
Definition bitcoingui.h:186
QAction * openRPCConsoleAction
Definition bitcoingui.h:159
const NetworkStyle *const m_network_style
Definition bitcoingui.h:191
void changeEvent(QEvent *e) override
GUIUtil::ClickableLabel * labelProxyIcon
Definition bitcoingui.h:134
QAction * historyAction
Definition bitcoingui.h:144
bool eventFilter(QObject *object, QEvent *event) override
QMenu * m_open_wallet_menu
Definition bitcoingui.h:164
void createTrayIcon()
Create system tray icon and notification.
QAction * quitAction
Definition bitcoingui.h:145
void setPrivacy(bool privacy)
QProgressDialog * progressDialog
Definition bitcoingui.h:139
std::unique_ptr< interfaces::Handler > m_handler_message_box
Definition bitcoingui.h:126
WalletFrame * walletFrame
Definition bitcoingui.h:129
void updateProxyIcon()
Set the proxy-enabled icon as shown in the UI.
QAction * receiveCoinsAction
Definition bitcoingui.h:153
const std::unique_ptr< QMenu > trayIconMenu
Definition bitcoingui.h:175
QAction * usedSendingAddressesAction
Definition bitcoingui.h:147
void unsubscribeFromCoreSignals()
Disconnect core signals from GUI client.
void closeEvent(QCloseEvent *event) override
QAction * verifyMessageAction
Definition bitcoingui.h:150
void createTrayIconMenu()
Create system tray menu (or setup the dock menu)
HelpMessageDialog * helpMessageDialog
Definition bitcoingui.h:178
void aboutClicked()
Show about dialog.
void toggleHidden()
Simply calls showNormalIfMinimized(true) for use in SLOT() macro.
QAction * encryptWalletAction
Definition bitcoingui.h:155
void updateNetworkState()
Update UI with latest network info from model.
void createActions()
Create the main UI actions.
void showDebugWindow()
Show debug window.
bool hasTrayIcon() const
Get the tray icon status.
Definition bitcoingui.h:113
QAction * m_mask_values_action
Definition bitcoingui.h:169
int spinnerFrame
Definition bitcoingui.h:187
QAction * aboutAction
Definition bitcoingui.h:152
void consoleShown(RPCConsole *console)
Signal raised when RPC console shown.
bool isPrivacyModeActivated() const
void showDebugWindowActivateConsole()
Show debug window and set focus to the console.
void dropEvent(QDropEvent *event) override
void showProgress(const QString &title, int nProgress)
Show progress dialog e.g.
QAction * usedReceivingAddressesAction
Definition bitcoingui.h:148
void subscribeToCoreSignals()
Connect core signals to GUI client.
void createToolBars()
Create the toolbars.
QAction * m_wallet_selector_action
Definition bitcoingui.h:168
UnitDisplayStatusBarControl * unitDisplayControl
Definition bitcoingui.h:131
QAction * optionsAction
Definition bitcoingui.h:154
void updateWindowTitle()
void setWalletActionsEnabled(bool enabled)
Enable or disable all wallet-related actions.
const PlatformStyle * platformStyle
Definition bitcoingui.h:190
void dragEnterEvent(QDragEnterEvent *event) override
QAction * m_close_wallet_action
Definition bitcoingui.h:165
QLabel * labelWalletEncryptionIcon
Definition bitcoingui.h:132
QAction * overviewAction
Definition bitcoingui.h:143
GUIUtil::ClickableLabel * labelBlocksIcon
Definition bitcoingui.h:136
interfaces::Node & m_node
Definition bitcoingui.h:124
QAction * m_create_wallet_action
Definition bitcoingui.h:162
QAction * m_load_psbt_action
Definition bitcoingui.h:151
void detectShutdown()
called by a timer to check if ShutdownRequested() has been set
QAction * m_wallet_selector_label_action
Definition bitcoingui.h:167
WalletController * m_wallet_controller
Definition bitcoingui.h:125
bool enableWallet
Definition bitcoingui.h:102
RPCConsole * rpcConsole
Definition bitcoingui.h:177
const Config & config
Definition bitcoingui.h:189
QAction * backupWalletAction
Definition bitcoingui.h:156
QAction * showHelpMessageAction
Definition bitcoingui.h:161
QAction * aboutQtAction
Definition bitcoingui.h:158
QComboBox * m_wallet_selector
Definition bitcoingui.h:172
QLabel * m_wallet_selector_label
Definition bitcoingui.h:171
void showNormalIfMinimized()
Show window if hidden, unminimize when minimized, rise when obscured or show if hidden and fToggleHid...
Definition bitcoingui.h:322
ClientModel * clientModel
Definition bitcoingui.h:128
void updateHeadersSyncProgressLabel()
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.
QSystemTrayIcon * trayIcon
Definition bitcoingui.h:174
void message(const QString &title, QString message, unsigned int style, bool *ret=nullptr, const QString &detailed_message=QString())
Notify the user of an event from the core network or transaction handling code.
void showHelpMessageClicked()
Show help message dialog.
QAction * sendCoinsAction
Definition bitcoingui.h:146
void quitRequested()
QToolBar * appToolBar
Definition bitcoingui.h:142
QLabel * labelWalletHDStatusIcon
Definition bitcoingui.h:133
void setNumConnections(int count)
Set number of connections shown in the UI.
QAction * signMessageAction
Definition bitcoingui.h:149
void showModalOverlay()
Notificator * notificator
Definition bitcoingui.h:176
std::unique_ptr< interfaces::Handler > m_handler_question
Definition bitcoingui.h:127
QMenuBar * appMenuBar
Definition bitcoingui.h:141
void setNetworkActive(bool networkActive)
Set network state shown in the UI.
Model for Bitcoin network client.
Definition clientmodel.h:43
"Help message" dialog box
Modal overlay to display information about the chain-sync state.
Cross-platform desktop notification client.
Definition notificator.h:24
Interface from Qt to configuration data structure for Bitcoin client.
Local Bitcoin RPC console.
Definition rpcconsole.h:41
void mousePressEvent(QMouseEvent *event) override
So that it responds to left-button clicks.
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:353
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.
Controller between interfaces::Node, WalletModel instances and the GUI.
A container for embedding all wallet-related controls into BitcoinGUI.
Definition walletframe.h:29
Interface to Bitcoin wallet from Qt view code.
Definition walletmodel.h:47
Top-level interface for a bitcoin node (bitcoind process).
Definition node.h:59
SyncType
Definition clientmodel.h:40
Utility functions used by the Bitcoin Qt UI.
Definition bitcoingui.h:58
Block and header tip information.
Definition node.h:50
static int count
SynchronizationState
Current sync state passed to tip changed callbacks.
Definition validation.h:110