Bitcoin Core 32.99.0
P2P Digital Currency
Loading...
Searching...
No Matches
bitcoingui.h
Go to the documentation of this file.
1// Copyright (c) 2011-present 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#include <bitcoin-build-config.h> // IWYU pragma: keep
9
10#include <qt/bitcoinunits.h>
11#include <qt/clientmodel.h>
12#include <qt/guiutil.h>
13#include <qt/optionsdialog.h>
14
15#include <consensus/amount.h>
16
17#include <QLabel>
18#include <QMainWindow>
19#include <QMap>
20#include <QMenu>
21#include <QPoint>
22#include <QSystemTrayIcon>
23
24#ifdef Q_OS_MACOS
25#include <qt/macos_appnap.h>
26#endif
27
28#include <memory>
29
30class NetworkStyle;
31class Notificator;
32class OptionsModel;
33class PlatformStyle;
34class RPCConsole;
38class WalletFrame;
39class WalletModel;
41class ModalOverlay;
42enum class SynchronizationState;
43
44namespace interfaces {
45class Handler;
46class Node;
47struct BlockAndHeaderTipInfo;
48}
49
51class QAction;
52class QComboBox;
53class QDateTime;
54class QProgressBar;
55class QProgressDialog;
57
58namespace GUIUtil {
59class ClickableLabel;
61}
62
67class BitcoinGUI : public QMainWindow
68{
70
71public:
72 static const std::string DEFAULT_UIPLATFORM;
73
74 explicit BitcoinGUI(interfaces::Node& node, const PlatformStyle *platformStyle, const NetworkStyle *networkStyle, QWidget *parent = nullptr);
76
81#ifdef ENABLE_WALLET
84#endif
85
86#ifdef ENABLE_WALLET
91 void addWallet(WalletModel* walletModel);
92 void removeWallet(WalletModel* walletModel);
93#endif // ENABLE_WALLET
94 bool enableWallet = false;
95
99 bool hasTrayIcon() const { return trayIcon; }
100
103
104 bool isPrivacyModeActivated() const;
105
106protected:
107 void changeEvent(QEvent *e) override;
108 void closeEvent(QCloseEvent *event) override;
109 void showEvent(QShowEvent *event) override;
110 void dragEnterEvent(QDragEnterEvent *event) override;
111 void dropEvent(QDropEvent *event) override;
112 bool eventFilter(QObject *object, QEvent *event) override;
113
114private:
116#ifdef ENABLE_WALLET
117 WalletController* m_wallet_controller{nullptr};
118#endif // ENABLE_WALLET
119 std::unique_ptr<interfaces::Handler> m_handler_message_box;
120 std::unique_ptr<interfaces::Handler> m_handler_question;
123
130 QLabel* progressBarLabel = nullptr;
133
138 QAction* quitAction = nullptr;
154 QAction* openAction = nullptr;
162#ifdef ENABLE_WALLET
165#endif // ENABLE_WALLET
170#ifdef ENABLE_WALLET
171 QLabel *m_wallet_selector_label = nullptr;
172 QComboBox* m_wallet_selector = nullptr;
173#endif // ENABLE_WALLET
175 const std::unique_ptr<QMenu> trayIconMenu;
180
182
183#ifdef Q_OS_MACOS
185#endif
186
188 int prevBlocks = 0;
190
193
195 void createActions();
197 void createMenuBar();
199 void createToolBars();
201 void createTrayIcon();
203 void createTrayIconMenu();
204
206 void setWalletActionsEnabled(bool enabled);
207
210
212 void updateNetworkState();
213
216
219
223 void receivedURI(const QString &uri);
226 void setPrivacy(bool privacy);
227
228public Q_SLOTS:
230 void setNumConnections(int count);
236 void createWallet();
237
246 void message(const QString& title, QString message, unsigned int style, bool* ret = nullptr, const QString& detailed_message = QString());
247
248#ifdef ENABLE_WALLET
249 void setCurrentWallet(WalletModel* wallet_model);
250 void setCurrentWalletBySelectorIndex(int index);
253 void updateWalletStatus();
254
255private:
260 void setEncryptionStatus(int status);
261
266 void setHDStatus(bool privkeyDisabled, int hdEnabled);
267
268public Q_SLOTS:
269 bool handlePaymentRequest(const SendCoinsRecipient& recipient);
270
272 void incomingTransaction(const QString& date, BitcoinUnit unit, const CAmount& amount, const QString& type, const QString& address, const QString& label, const QString& walletName);
273#endif // ENABLE_WALLET
274
275private:
277 void updateProxyIcon();
278 void updateWindowTitle();
279
280public Q_SLOTS:
281#ifdef ENABLE_WALLET
283 void gotoOverviewPage();
285 void gotoHistoryPage();
287 void gotoReceiveCoinsPage();
289 void gotoSendCoinsPage(QString addr = "");
290
292 void gotoSignMessageTab(QString addr = "");
294 void gotoVerifyMessageTab(QString addr = "");
296 void gotoLoadPSBT(bool from_clipboard = false);
298 void enableHistoryAction(bool privacy);
299
301 void openClicked();
302#endif // ENABLE_WALLET
304 void optionsClicked();
306 void aboutClicked();
308 void showDebugWindow();
313
318 void toggleHidden();
319
321 void detectShutdown();
322
324 void showProgress(const QString &title, int nProgress);
325
326 void showModalOverlay();
327};
328
329class UnitDisplayStatusBarControl : public QLabel
330{
332
333public:
334 explicit UnitDisplayStatusBarControl(const PlatformStyle *platformStyle);
337
338protected:
340 void mousePressEvent(QMouseEvent *event) override;
341 void changeEvent(QEvent* e) override;
342
343private:
345 QMenu* menu{nullptr};
347
349 void onDisplayUnitsClicked(const QPoint& point);
351 void createContextMenu();
352
353private Q_SLOTS:
358};
359
360#endif // BITCOIN_QT_BITCOINGUI_H
int64_t CAmount
Amount in satoshis (Can be negative)
Definition amount.h:12
int ret
Bitcoin GUI main class.
Definition bitcoingui.h:68
void updateHeadersPresyncProgressLabel(int64_t height, const QDateTime &blockDate)
GUIUtil::ClickableProgressBar * progressBar
Definition bitcoingui.h:131
QAction * m_close_all_wallets_action
Definition bitcoingui.h:161
void showEvent(QShowEvent *event) override
QLabel * progressBarLabel
Definition bitcoingui.h:130
QAction * m_open_wallet_action
Definition bitcoingui.h:157
static const std::string DEFAULT_UIPLATFORM
Definition bitcoingui.h:72
QAction * m_export_watchonly_action
Definition bitcoingui.h:169
QAction * openAction
Definition bitcoingui.h:154
void createWallet()
Launch the wallet creation modal (no-op if wallet is not compiled)
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:128
void receivedURI(const QString &uri)
Signal raised when a URI was entered or dragged to the GUI.
ModalOverlay * modalOverlay
Definition bitcoingui.h:179
GUIUtil::ThemedLabel * labelWalletEncryptionIcon
Definition bitcoingui.h:125
QAction * changePassphraseAction
Definition bitcoingui.h:151
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:188
QAction * openRPCConsoleAction
Definition bitcoingui.h:153
const NetworkStyle *const m_network_style
Definition bitcoingui.h:192
void changeEvent(QEvent *e) override
GUIUtil::ClickableLabel * labelProxyIcon
Definition bitcoingui.h:127
QAction * historyAction
Definition bitcoingui.h:137
bool eventFilter(QObject *object, QEvent *event) override
QMenu * m_open_wallet_menu
Definition bitcoingui.h:158
void createTrayIcon()
Create system tray icon and notification.
QAction * m_load_psbt_clipboard_action
Definition bitcoingui.h:145
QAction * quitAction
Definition bitcoingui.h:138
void setNetworkActive(bool network_active)
Set network state shown in the UI.
void setPrivacy(bool privacy)
QProgressDialog * progressDialog
Definition bitcoingui.h:132
std::unique_ptr< interfaces::Handler > m_handler_message_box
Definition bitcoingui.h:119
WalletFrame * walletFrame
Definition bitcoingui.h:122
void updateProxyIcon()
Set the proxy-enabled icon as shown in the UI.
QAction * m_restore_wallet_action
Definition bitcoingui.h:159
QAction * receiveCoinsAction
Definition bitcoingui.h:147
const std::unique_ptr< QMenu > trayIconMenu
Definition bitcoingui.h:175
QAction * usedSendingAddressesAction
Definition bitcoingui.h:140
void unsubscribeFromCoreSignals()
Disconnect core signals from GUI client.
void closeEvent(QCloseEvent *event) override
QAction * verifyMessageAction
Definition bitcoingui.h:143
QAction * m_migrate_wallet_action
Definition bitcoingui.h:167
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)
QAction * encryptWalletAction
Definition bitcoingui.h:149
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:99
QAction * m_mask_values_action
Definition bitcoingui.h:166
int spinnerFrame
Definition bitcoingui.h:189
QAction * aboutAction
Definition bitcoingui.h:146
void consoleShown(RPCConsole *console)
Signal raised when RPC console shown.
bool isPrivacyModeActivated() const
QMenu * m_migrate_wallet_menu
Definition bitcoingui.h:168
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:141
void subscribeToCoreSignals()
Connect core signals to GUI client.
void createToolBars()
Create the toolbars.
UnitDisplayStatusBarControl * unitDisplayControl
Definition bitcoingui.h:124
QAction * optionsAction
Definition bitcoingui.h:148
void updateWindowTitle()
void setWalletActionsEnabled(bool enabled)
Enable or disable all wallet-related actions.
const PlatformStyle * platformStyle
Definition bitcoingui.h:191
void dragEnterEvent(QDragEnterEvent *event) override
QAction * m_close_wallet_action
Definition bitcoingui.h:160
QAction * overviewAction
Definition bitcoingui.h:136
GUIUtil::ClickableLabel * labelBlocksIcon
Definition bitcoingui.h:129
interfaces::Node & m_node
Definition bitcoingui.h:115
QAction * m_create_wallet_action
Definition bitcoingui.h:156
QAction * m_load_psbt_action
Definition bitcoingui.h:144
void detectShutdown()
called by a timer to check if shutdown has been requested
bool enableWallet
Definition bitcoingui.h:94
RPCConsole * rpcConsole
Definition bitcoingui.h:177
QMenu * m_network_context_menu
Definition bitcoingui.h:181
QAction * backupWalletAction
Definition bitcoingui.h:150
QAction * showHelpMessageAction
Definition bitcoingui.h:155
QAction * aboutQtAction
Definition bitcoingui.h:152
void showNormalIfMinimized()
Show window if hidden, unminimize when minimized, rise when obscured or show if hidden and fToggleHid...
Definition bitcoingui.h:315
ClientModel * clientModel
Definition bitcoingui.h:121
void updateHeadersSyncProgressLabel()
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:139
void quitRequested()
QToolBar * appToolBar
Definition bitcoingui.h:135
void setNumConnections(int count)
Set number of connections shown in the UI.
QAction * signMessageAction
Definition bitcoingui.h:142
GUIUtil::ThemedLabel * labelWalletHDStatusIcon
Definition bitcoingui.h:126
void showModalOverlay()
Notificator * notificator
Definition bitcoingui.h:176
std::unique_ptr< interfaces::Handler > m_handler_question
Definition bitcoingui.h:120
QMenuBar * appMenuBar
Definition bitcoingui.h:134
Unit
Bitcoin units.
Model for Bitcoin network client.
Definition clientmodel.h:57
"Help message" dialog box
Modal overlay to display information about the chain-sync state.
Cross-platform desktop notification client.
Definition notificator.h:23
Interface from Qt to configuration data structure for Bitcoin client.
Local Bitcoin RPC console.
Definition rpcconsole.h:44
void changeEvent(QEvent *e) override
void mousePressEvent(QMouseEvent *event) override
So that it responds to left-button clicks.
void createContextMenu()
Creates context menu, its actions, and wires up all the relevant signals for mouse events.
void updateDisplayUnit(BitcoinUnit newUnits)
When Display Units are changed on OptionsModel it will refresh the display text of the control on the...
OptionsModel * optionsModel
Definition bitcoingui.h:344
void onMenuSelection(QAction *action)
Tells underlying optionsModel to update its current display unit.
const PlatformStyle * m_platform_style
Definition bitcoingui.h:346
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:49
Top-level interface for a bitcoin node (bitcoind process).
Definition node.h:66
SyncType
Definition clientmodel.h:42
Utility functions used by the Bitcoin Qt UI.
Definition bitcoingui.h:58
Block and header tip information.
Definition node.h:46
static int count
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.
Definition time.h:82
SynchronizationState
Current sync state passed to tip changed callbacks.
Definition validation.h:96