Bitcoin Core 31.99.0
P2P Digital Currency
interface_ui.h
Go to the documentation of this file.
1// Copyright (c) 2010 Satoshi Nakamoto
2// Copyright (c) 2012-present The Bitcoin Core developers
3// Distributed under the MIT software license, see the accompanying
4// file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
6#ifndef BITCOIN_NODE_INTERFACE_UI_H
7#define BITCOIN_NODE_INTERFACE_UI_H
8
9#include <cstdint>
10#include <functional>
11#include <string>
12#include <vector>
13
14class CBlockIndex;
15enum class SynchronizationState;
16struct bilingual_str;
17
18namespace btcsignals {
19 class connection;
20} // namespace btcsignals
21
24{
25public:
27 enum MessageBoxFlags : uint32_t {
29 ICON_WARNING = (1U << 0),
30 ICON_ERROR = (1U << 1),
36
38 BTN_OK = 0x00000400U, // QMessageBox::Ok
39 BTN_YES = 0x00004000U, // QMessageBox::Yes
40 BTN_NO = 0x00010000U, // QMessageBox::No
41 BTN_ABORT = 0x00040000U, // QMessageBox::Abort
42 BTN_RETRY = 0x00080000U, // QMessageBox::Retry
43 BTN_IGNORE = 0x00100000U, // QMessageBox::Ignore
44 BTN_CLOSE = 0x00200000U, // QMessageBox::Close
45 BTN_CANCEL = 0x00400000U, // QMessageBox::Cancel
46 BTN_DISCARD = 0x00800000U, // QMessageBox::Discard
47 BTN_HELP = 0x01000000U, // QMessageBox::Help
48 BTN_APPLY = 0x02000000U, // QMessageBox::Apply
49 BTN_RESET = 0x04000000U, // QMessageBox::Reset
56
58 MODAL = 0x10000000U,
59
61 SECURE = 0x40000000U,
62
67 };
68
69#define ADD_SIGNALS_DECL_WRAPPER(signal_name, rtype, ...) \
70 rtype signal_name(__VA_ARGS__); \
71 using signal_name##Sig = rtype(__VA_ARGS__); \
72 btcsignals::connection signal_name##_connect(std::function<signal_name##Sig> fn)
73
75 ADD_SIGNALS_DECL_WRAPPER(ThreadSafeMessageBox, bool, const bilingual_str& message, unsigned int style);
76
78 ADD_SIGNALS_DECL_WRAPPER(ThreadSafeQuestion, bool, const bilingual_str& message, const std::string& noninteractive_message, unsigned int style);
79
81 ADD_SIGNALS_DECL_WRAPPER(InitMessage, void, const std::string& message);
82
84 ADD_SIGNALS_DECL_WRAPPER(InitWallet, void, );
85
87 ADD_SIGNALS_DECL_WRAPPER(NotifyNumConnectionsChanged, void, int newNumConnections);
88
90 ADD_SIGNALS_DECL_WRAPPER(NotifyNetworkActiveChanged, void, bool networkActive);
91
95 ADD_SIGNALS_DECL_WRAPPER(NotifyAlertChanged, void, );
96
101 ADD_SIGNALS_DECL_WRAPPER(ShowProgress, void, const std::string& title, int nProgress, bool resume_possible);
102
104 ADD_SIGNALS_DECL_WRAPPER(NotifyBlockTip, void, SynchronizationState, const CBlockIndex& block, double verification_progress);
105
107 ADD_SIGNALS_DECL_WRAPPER(NotifyHeaderTip, void, SynchronizationState, int64_t height, int64_t timestamp, bool presync);
108
110 ADD_SIGNALS_DECL_WRAPPER(BannedListChanged, void, void);
111};
112
114void InitWarning(const bilingual_str& str);
115
117bool InitError(const bilingual_str& str);
118bool InitError(const bilingual_str& str, const std::vector<std::string>& details);
119
121
122#endif // BITCOIN_NODE_INTERFACE_UI_H
static bool ThreadSafeMessageBox(BitcoinGUI *gui, const bilingual_str &message, unsigned int style)
The block chain is a tree shaped structure starting with the genesis block at the root,...
Definition: chain.h:94
Signals for UI communication.
Definition: interface_ui.h:24
ADD_SIGNALS_DECL_WRAPPER(BannedListChanged, void, void)
Banlist did change.
ADD_SIGNALS_DECL_WRAPPER(NotifyAlertChanged, void,)
Status bar alerts changed.
ADD_SIGNALS_DECL_WRAPPER(NotifyNetworkActiveChanged, void, bool networkActive)
Network activity state changed.
ADD_SIGNALS_DECL_WRAPPER(NotifyBlockTip, void, SynchronizationState, const CBlockIndex &block, double verification_progress)
New block has been accepted.
ADD_SIGNALS_DECL_WRAPPER(ShowProgress, void, const std::string &title, int nProgress, bool resume_possible)
Show progress e.g.
ADD_SIGNALS_DECL_WRAPPER(ThreadSafeMessageBox, bool, const bilingual_str &message, unsigned int style)
Show message box.
ADD_SIGNALS_DECL_WRAPPER(InitWallet, void,)
Wallet loader created.
ADD_SIGNALS_DECL_WRAPPER(NotifyHeaderTip, void, SynchronizationState, int64_t height, int64_t timestamp, bool presync)
Best header has changed.
MessageBoxFlags
Flags for CClientUIInterface::ThreadSafeMessageBox.
Definition: interface_ui.h:27
@ ICON_MASK
Mask of all available icons in CClientUIInterface::MessageBoxFlags This needs to be updated,...
Definition: interface_ui.h:35
@ BTN_MASK
Mask of all available buttons in CClientUIInterface::MessageBoxFlags This needs to be updated,...
Definition: interface_ui.h:54
@ BTN_OK
These values are taken from qmessagebox.h "enum StandardButton" to be directly usable.
Definition: interface_ui.h:38
@ MSG_INFORMATION
Predefined combinations for certain default usage cases.
Definition: interface_ui.h:64
@ MODAL
Force blocking, modal message box dialog (not just OS notification)
Definition: interface_ui.h:58
@ SECURE
Do not print contents of message to debug log.
Definition: interface_ui.h:61
ADD_SIGNALS_DECL_WRAPPER(InitMessage, void, const std::string &message)
Progress message during initialization.
ADD_SIGNALS_DECL_WRAPPER(NotifyNumConnectionsChanged, void, int newNumConnections)
Number of network connections changed.
ADD_SIGNALS_DECL_WRAPPER(ThreadSafeQuestion, bool, const bilingual_str &message, const std::string &noninteractive_message, unsigned int style)
If possible, ask the user a question.
CClientUIInterface uiInterface
void InitWarning(const bilingual_str &str)
Show warning message.
bool InitError(const bilingual_str &str)
Show error message.
btcsignals is a simple mechanism for signaling events to multiple subscribers.
Definition: btcsignals.h:31
static void ShowProgress(SplashScreen *splash, const std::string &title, int nProgress, bool resume_possible)
static void InitMessage(SplashScreen *splash, const std::string &message)
Bilingual messages:
Definition: translation.h:24
SynchronizationState
Current sync state passed to tip changed callbacks.
Definition: validation.h:93