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>
20 /** General change type (added, updated, removed). */
28 /** Signals for UI communication. */
29 class CClientUIInterface
32 /** Flags for CClientUIInterface::ThreadSafeMessageBox */
36 ICON_WARNING
= (1U << 0),
37 ICON_ERROR
= (1U << 1),
39 * Mask of all available icons in CClientUIInterface::MessageBoxFlags
40 * This needs to be updated, when icons are changed there!
42 ICON_MASK
= (ICON_INFORMATION
| ICON_WARNING
| ICON_ERROR
),
44 /** These values are taken from qmessagebox.h "enum StandardButton" to be directly usable */
45 BTN_OK
= 0x00000400U
, // QMessageBox::Ok
46 BTN_YES
= 0x00004000U
, // QMessageBox::Yes
47 BTN_NO
= 0x00010000U
, // QMessageBox::No
48 BTN_ABORT
= 0x00040000U
, // QMessageBox::Abort
49 BTN_RETRY
= 0x00080000U
, // QMessageBox::Retry
50 BTN_IGNORE
= 0x00100000U
, // QMessageBox::Ignore
51 BTN_CLOSE
= 0x00200000U
, // QMessageBox::Close
52 BTN_CANCEL
= 0x00400000U
, // QMessageBox::Cancel
53 BTN_DISCARD
= 0x00800000U
, // QMessageBox::Discard
54 BTN_HELP
= 0x01000000U
, // QMessageBox::Help
55 BTN_APPLY
= 0x02000000U
, // QMessageBox::Apply
56 BTN_RESET
= 0x04000000U
, // QMessageBox::Reset
58 * Mask of all available buttons in CClientUIInterface::MessageBoxFlags
59 * This needs to be updated, when buttons are changed there!
61 BTN_MASK
= (BTN_OK
| BTN_YES
| BTN_NO
| BTN_ABORT
| BTN_RETRY
| BTN_IGNORE
|
62 BTN_CLOSE
| BTN_CANCEL
| BTN_DISCARD
| BTN_HELP
| BTN_APPLY
| BTN_RESET
),
64 /** Force blocking, modal message box dialog (not just OS notification) */
67 /** Do not print contents of message to debug log */
70 /** Predefined combinations for certain default usage cases */
71 MSG_INFORMATION
= ICON_INFORMATION
,
72 MSG_WARNING
= (ICON_WARNING
| BTN_OK
| MODAL
),
73 MSG_ERROR
= (ICON_ERROR
| BTN_OK
| MODAL
)
76 /** Show message box. */
77 boost::signals2::signal
<bool (const std::string
& message
, const std::string
& caption
, unsigned int style
), boost::signals2::last_value
<bool> > ThreadSafeMessageBox
;
79 /** If possible, ask the user a question. If not, falls back to ThreadSafeMessageBox(noninteractive_message, caption, style) and returns false. */
80 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
;
82 /** Progress message during initialization. */
83 boost::signals2::signal
<void (const std::string
&message
)> InitMessage
;
85 /** Number of network connections changed. */
86 boost::signals2::signal
<void (int newNumConnections
)> NotifyNumConnectionsChanged
;
88 /** Network activity state changed. */
89 boost::signals2::signal
<void (bool networkActive
)> NotifyNetworkActiveChanged
;
92 * Status bar alerts changed.
94 boost::signals2::signal
<void ()> NotifyAlertChanged
;
96 /** A wallet has been loaded. */
97 boost::signals2::signal
<void (CWallet
* wallet
)> LoadWallet
;
99 /** Show progress e.g. for verifychain */
100 boost::signals2::signal
<void (const std::string
&title
, int nProgress
)> ShowProgress
;
102 /** New block has been accepted */
103 boost::signals2::signal
<void (bool, const CBlockIndex
*)> NotifyBlockTip
;
105 /** Best header has changed */
106 boost::signals2::signal
<void (bool, const CBlockIndex
*)> NotifyHeaderTip
;
108 /** Banlist did change. */
109 boost::signals2::signal
<void (void)> BannedListChanged
;
112 /** Show warning message **/
113 void InitWarning(const std::string
& str
);
115 /** Show error message **/
116 bool InitError(const std::string
& str
);
118 std::string
AmountHighWarn(const std::string
& optname
);
120 std::string
AmountErrMsg(const char* const optname
, const std::string
& strValue
);
122 extern CClientUIInterface uiInterface
;
124 #endif // BITCOIN_UI_INTERFACE_H