1 // Copyright (c) 2010 Satoshi Nakamoto
2 // Copyright (c) 2012-2016 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.
6 #ifndef BITCOIN_UI_INTERFACE_H
7 #define BITCOIN_UI_INTERFACE_H
12 #include <boost/signals2/last_value.hpp>
13 #include <boost/signals2/signal.hpp>
18 /** General change type (added, updated, removed). */
26 /** Signals for UI communication. */
27 class CClientUIInterface
30 /** Flags for CClientUIInterface::ThreadSafeMessageBox */
34 ICON_WARNING
= (1U << 0),
35 ICON_ERROR
= (1U << 1),
37 * Mask of all available icons in CClientUIInterface::MessageBoxFlags
38 * This needs to be updated, when icons are changed there!
40 ICON_MASK
= (ICON_INFORMATION
| ICON_WARNING
| ICON_ERROR
),
42 /** These values are taken from qmessagebox.h "enum StandardButton" to be directly usable */
43 BTN_OK
= 0x00000400U
, // QMessageBox::Ok
44 BTN_YES
= 0x00004000U
, // QMessageBox::Yes
45 BTN_NO
= 0x00010000U
, // QMessageBox::No
46 BTN_ABORT
= 0x00040000U
, // QMessageBox::Abort
47 BTN_RETRY
= 0x00080000U
, // QMessageBox::Retry
48 BTN_IGNORE
= 0x00100000U
, // QMessageBox::Ignore
49 BTN_CLOSE
= 0x00200000U
, // QMessageBox::Close
50 BTN_CANCEL
= 0x00400000U
, // QMessageBox::Cancel
51 BTN_DISCARD
= 0x00800000U
, // QMessageBox::Discard
52 BTN_HELP
= 0x01000000U
, // QMessageBox::Help
53 BTN_APPLY
= 0x02000000U
, // QMessageBox::Apply
54 BTN_RESET
= 0x04000000U
, // QMessageBox::Reset
56 * Mask of all available buttons in CClientUIInterface::MessageBoxFlags
57 * This needs to be updated, when buttons are changed there!
59 BTN_MASK
= (BTN_OK
| BTN_YES
| BTN_NO
| BTN_ABORT
| BTN_RETRY
| BTN_IGNORE
|
60 BTN_CLOSE
| BTN_CANCEL
| BTN_DISCARD
| BTN_HELP
| BTN_APPLY
| BTN_RESET
),
62 /** Force blocking, modal message box dialog (not just OS notification) */
65 /** Do not print contents of message to debug log */
68 /** Predefined combinations for certain default usage cases */
69 MSG_INFORMATION
= ICON_INFORMATION
,
70 MSG_WARNING
= (ICON_WARNING
| BTN_OK
| MODAL
),
71 MSG_ERROR
= (ICON_ERROR
| BTN_OK
| MODAL
)
74 /** Show message box. */
75 boost::signals2::signal
<bool (const std::string
& message
, const std::string
& caption
, unsigned int style
), boost::signals2::last_value
<bool> > ThreadSafeMessageBox
;
77 /** If possible, ask the user a question. If not, falls back to ThreadSafeMessageBox(noninteractive_message, caption, style) and returns false. */
78 boost::signals2::signal
<bool (const std::string
& message
, const std::string
& noninteractive_message
, const std::string
& caption
, unsigned int style
), boost::signals2::last_value
<bool> > ThreadSafeQuestion
;
80 /** Progress message during initialization. */
81 boost::signals2::signal
<void (const std::string
&message
)> InitMessage
;
83 /** Number of network connections changed. */
84 boost::signals2::signal
<void (int newNumConnections
)> NotifyNumConnectionsChanged
;
86 /** Network activity state changed. */
87 boost::signals2::signal
<void (bool networkActive
)> NotifyNetworkActiveChanged
;
90 * Status bar alerts changed.
92 boost::signals2::signal
<void ()> NotifyAlertChanged
;
94 /** A wallet has been loaded. */
95 boost::signals2::signal
<void (CWallet
* wallet
)> LoadWallet
;
98 * Show progress e.g. for verifychain.
99 * resume_possible indicates shutting down now will result in the current progress action resuming upon restart.
101 boost::signals2::signal
<void (const std::string
&title
, int nProgress
, bool resume_possible
)> ShowProgress
;
103 /** New block has been accepted */
104 boost::signals2::signal
<void (bool, const CBlockIndex
*)> NotifyBlockTip
;
106 /** Best header has changed */
107 boost::signals2::signal
<void (bool, const CBlockIndex
*)> NotifyHeaderTip
;
109 /** Banlist did change. */
110 boost::signals2::signal
<void (void)> BannedListChanged
;
113 /** Show warning message **/
114 void InitWarning(const std::string
& str
);
116 /** Show error message **/
117 bool InitError(const std::string
& str
);
119 std::string
AmountHighWarn(const std::string
& optname
);
121 std::string
AmountErrMsg(const char* const optname
, const std::string
& strValue
);
123 extern CClientUIInterface uiInterface
;
125 #endif // BITCOIN_UI_INTERFACE_H