Bitcoin Core  22.99.0
P2P Digital Currency
ui_interface.h
Go to the documentation of this file.
1 // Copyright (c) 2010 Satoshi Nakamoto
2 // Copyright (c) 2012-2021 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_UI_INTERFACE_H
7 #define BITCOIN_NODE_UI_INTERFACE_H
8 
9 #include <functional>
10 #include <memory>
11 #include <string>
12 
13 class CBlockIndex;
14 enum class SynchronizationState;
15 struct bilingual_str;
16 
17 namespace boost {
18 namespace signals2 {
19 class connection;
20 }
21 } // namespace boost
22 
25 {
26 public:
28  enum MessageBoxFlags : uint32_t {
30  ICON_WARNING = (1U << 0),
31  ICON_ERROR = (1U << 1),
37 
39  BTN_OK = 0x00000400U, // QMessageBox::Ok
40  BTN_YES = 0x00004000U, // QMessageBox::Yes
41  BTN_NO = 0x00010000U, // QMessageBox::No
42  BTN_ABORT = 0x00040000U, // QMessageBox::Abort
43  BTN_RETRY = 0x00080000U, // QMessageBox::Retry
44  BTN_IGNORE = 0x00100000U, // QMessageBox::Ignore
45  BTN_CLOSE = 0x00200000U, // QMessageBox::Close
46  BTN_CANCEL = 0x00400000U, // QMessageBox::Cancel
47  BTN_DISCARD = 0x00800000U, // QMessageBox::Discard
48  BTN_HELP = 0x01000000U, // QMessageBox::Help
49  BTN_APPLY = 0x02000000U, // QMessageBox::Apply
50  BTN_RESET = 0x04000000U, // QMessageBox::Reset
57 
59  MODAL = 0x10000000U,
60 
62  SECURE = 0x40000000U,
63 
68  };
69 
70 #define ADD_SIGNALS_DECL_WRAPPER(signal_name, rtype, ...) \
71  rtype signal_name(__VA_ARGS__); \
72  using signal_name##Sig = rtype(__VA_ARGS__); \
73  boost::signals2::connection signal_name##_connect(std::function<signal_name##Sig> fn);
74 
76  ADD_SIGNALS_DECL_WRAPPER(ThreadSafeMessageBox, bool, const bilingual_str& message, const std::string& caption, unsigned int style);
77 
79  ADD_SIGNALS_DECL_WRAPPER(ThreadSafeQuestion, bool, const bilingual_str& message, const std::string& noninteractive_message, const std::string& caption, unsigned int style);
80 
82  ADD_SIGNALS_DECL_WRAPPER(InitMessage, void, const std::string& message);
83 
85  ADD_SIGNALS_DECL_WRAPPER(InitWallet, void, );
86 
88  ADD_SIGNALS_DECL_WRAPPER(NotifyNumConnectionsChanged, void, int newNumConnections);
89 
91  ADD_SIGNALS_DECL_WRAPPER(NotifyNetworkActiveChanged, void, bool networkActive);
92 
97 
102  ADD_SIGNALS_DECL_WRAPPER(ShowProgress, void, const std::string& title, int nProgress, bool resume_possible);
103 
105  ADD_SIGNALS_DECL_WRAPPER(NotifyBlockTip, void, SynchronizationState, const CBlockIndex*);
106 
109 
112 };
113 
115 void InitWarning(const bilingual_str& str);
116 
118 bool InitError(const bilingual_str& str);
119 constexpr auto AbortError = InitError;
120 
122 
123 #endif // BITCOIN_NODE_UI_INTERFACE_H
CClientUIInterface::BTN_NO
@ BTN_NO
Definition: ui_interface.h:41
CClientUIInterface::BTN_DISCARD
@ BTN_DISCARD
Definition: ui_interface.h:47
CClientUIInterface
Signals for UI communication.
Definition: ui_interface.h:24
NotifyAlertChanged
static void NotifyAlertChanged(ClientModel *clientmodel)
Definition: clientmodel.cpp:263
CClientUIInterface::BTN_OK
@ BTN_OK
These values are taken from qmessagebox.h "enum StandardButton" to be directly usable.
Definition: ui_interface.h:39
InitMessage
static void InitMessage(SplashScreen *splash, const std::string &message)
Definition: splashscreen.cpp:174
CClientUIInterface::BTN_RETRY
@ BTN_RETRY
Definition: ui_interface.h:43
ShowProgress
static void ShowProgress(ClientModel *clientmodel, const std::string &title, int nProgress)
Definition: clientmodel.cpp:239
bilingual_str
Bilingual messages:
Definition: translation.h:16
InitError
bool InitError(const bilingual_str &str)
Show error message.
Definition: ui_interface.cpp:59
CClientUIInterface::MSG_ERROR
@ MSG_ERROR
Definition: ui_interface.h:67
CClientUIInterface::ICON_ERROR
@ ICON_ERROR
Definition: ui_interface.h:31
CClientUIInterface::ICON_WARNING
@ ICON_WARNING
Definition: ui_interface.h:30
CClientUIInterface::BTN_RESET
@ BTN_RESET
Definition: ui_interface.h:50
InitWarning
void InitWarning(const bilingual_str &str)
Show warning message.
Definition: ui_interface.cpp:65
CClientUIInterface::BTN_CLOSE
@ BTN_CLOSE
Definition: ui_interface.h:45
CClientUIInterface::ADD_SIGNALS_DECL_WRAPPER
ADD_SIGNALS_DECL_WRAPPER(ThreadSafeMessageBox, bool, const bilingual_str &message, const std::string &caption, unsigned int style)
Show message box.
CClientUIInterface::SECURE
@ SECURE
Do not print contents of message to debug log.
Definition: ui_interface.h:62
CClientUIInterface::BTN_MASK
@ BTN_MASK
Mask of all available buttons in CClientUIInterface::MessageBoxFlags This needs to be updated,...
Definition: ui_interface.h:55
CClientUIInterface::MessageBoxFlags
MessageBoxFlags
Flags for CClientUIInterface::ThreadSafeMessageBox.
Definition: ui_interface.h:28
CClientUIInterface::MODAL
@ MODAL
Force blocking, modal message box dialog (not just OS notification)
Definition: ui_interface.h:59
CClientUIInterface::BTN_CANCEL
@ BTN_CANCEL
Definition: ui_interface.h:46
CClientUIInterface::ICON_MASK
@ ICON_MASK
Mask of all available icons in CClientUIInterface::MessageBoxFlags This needs to be updated,...
Definition: ui_interface.h:36
CClientUIInterface::BTN_ABORT
@ BTN_ABORT
Definition: ui_interface.h:42
BannedListChanged
static void BannedListChanged(ClientModel *clientmodel)
Definition: clientmodel.cpp:270
NotifyHeaderTip
static bool NotifyHeaderTip(CChainState &chainstate) LOCKS_EXCLUDED(cs_main)
Definition: validation.cpp:2844
CClientUIInterface::ICON_INFORMATION
@ ICON_INFORMATION
Definition: ui_interface.h:29
CClientUIInterface::MSG_INFORMATION
@ MSG_INFORMATION
Predefined combinations for certain default usage cases.
Definition: ui_interface.h:65
ThreadSafeMessageBox
static bool ThreadSafeMessageBox(BitcoinGUI *gui, const bilingual_str &message, const std::string &caption, unsigned int style)
Definition: bitcoingui.cpp:1445
NotifyNumConnectionsChanged
static void NotifyNumConnectionsChanged(ClientModel *clientmodel, int newNumConnections)
Definition: clientmodel.cpp:248
CClientUIInterface::BTN_IGNORE
@ BTN_IGNORE
Definition: ui_interface.h:44
CClientUIInterface::BTN_HELP
@ BTN_HELP
Definition: ui_interface.h:48
SynchronizationState
SynchronizationState
Current sync state passed to tip changed callbacks.
Definition: validation.h:105
CClientUIInterface::BTN_APPLY
@ BTN_APPLY
Definition: ui_interface.h:49
AbortError
constexpr auto AbortError
Definition: ui_interface.h:119
CBlockIndex
The block chain is a tree shaped structure starting with the genesis block at the root,...
Definition: chain.h:151
CClientUIInterface::BTN_YES
@ BTN_YES
Definition: ui_interface.h:40
NotifyNetworkActiveChanged
static void NotifyNetworkActiveChanged(ClientModel *clientmodel, bool networkActive)
Definition: clientmodel.cpp:256
uiInterface
CClientUIInterface uiInterface
Definition: ui_interface.cpp:12
CClientUIInterface::MSG_WARNING
@ MSG_WARNING
Definition: ui_interface.h:66