]>
Commit | Line | Data |
---|---|---|
467c31ea | 1 | // Copyright (c) 2010 Satoshi Nakamoto |
160eb23b | 2 | // Copyright (c) 2012 The Bitcoin developers |
467c31ea | 3 | // Distributed under the MIT/X11 software license, see the accompanying |
3a25a2b9 | 4 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. |
51ed9ec9 | 5 | |
5cccb13d WL |
6 | #ifndef BITCOIN_UI_INTERFACE_H |
7 | #define BITCOIN_UI_INTERFACE_H | |
467c31ea | 8 | |
51ed9ec9 | 9 | #include <stdint.h> |
467c31ea | 10 | #include <string> |
51ed9ec9 | 11 | |
ab1b288f | 12 | #include <boost/signals2/last_value.hpp> |
51ed9ec9 | 13 | #include <boost/signals2/signal.hpp> |
467c31ea | 14 | |
fe4a6550 WL |
15 | class CBasicKeyStore; |
16 | class CWallet; | |
17 | class uint256; | |
18 | ||
ab1b288f | 19 | /** General change type (added, updated, removed). */ |
fe4a6550 WL |
20 | enum ChangeType |
21 | { | |
22 | CT_NEW, | |
23 | CT_UPDATED, | |
24 | CT_DELETED | |
25 | }; | |
26 | ||
ab1b288f WL |
27 | /** Signals for UI communication. */ |
28 | class CClientUIInterface | |
29 | { | |
30 | public: | |
239c11d0 WL |
31 | /** Flags for CClientUIInterface::ThreadSafeMessageBox */ |
32 | enum MessageBoxFlags | |
33 | { | |
5350ea41 PK |
34 | ICON_INFORMATION = 0, |
35 | ICON_WARNING = (1U << 0), | |
36 | ICON_ERROR = (1U << 1), | |
37 | /** | |
38 | * Mask of all available icons in CClientUIInterface::MessageBoxFlags | |
39 | * This needs to be updated, when icons are changed there! | |
40 | */ | |
41 | ICON_MASK = (ICON_INFORMATION | ICON_WARNING | ICON_ERROR), | |
42 | ||
43 | /** These values are taken from qmessagebox.h "enum StandardButton" to be directly usable */ | |
44 | BTN_OK = 0x00000400U, // QMessageBox::Ok | |
45 | BTN_YES = 0x00004000U, // QMessageBox::Yes | |
46 | BTN_NO = 0x00010000U, // QMessageBox::No | |
47 | BTN_ABORT = 0x00040000U, // QMessageBox::Abort | |
48 | BTN_RETRY = 0x00080000U, // QMessageBox::Retry | |
49 | BTN_IGNORE = 0x00100000U, // QMessageBox::Ignore | |
50 | BTN_CLOSE = 0x00200000U, // QMessageBox::Close | |
51 | BTN_CANCEL = 0x00400000U, // QMessageBox::Cancel | |
52 | BTN_DISCARD = 0x00800000U, // QMessageBox::Discard | |
53 | BTN_HELP = 0x01000000U, // QMessageBox::Help | |
54 | BTN_APPLY = 0x02000000U, // QMessageBox::Apply | |
55 | BTN_RESET = 0x04000000U, // QMessageBox::Reset | |
56 | /** | |
57 | * Mask of all available buttons in CClientUIInterface::MessageBoxFlags | |
58 | * This needs to be updated, when buttons are changed there! | |
59 | */ | |
60 | BTN_MASK = (BTN_OK | BTN_YES | BTN_NO | BTN_ABORT | BTN_RETRY | BTN_IGNORE | | |
61 | BTN_CLOSE | BTN_CANCEL | BTN_DISCARD | BTN_HELP | BTN_APPLY | BTN_RESET), | |
62 | ||
63 | /** Force blocking, modal message box dialog (not just OS notification) */ | |
64 | MODAL = 0x10000000U, | |
1ad26362 WL |
65 | /** Don't bring GUI to foreground. Use for messages during initialization */ |
66 | NOSHOWGUI = 0x20000000U, | |
5350ea41 PK |
67 | |
68 | /** Predefined combinations for certain default usage cases */ | |
7f5a1b52 | 69 | MSG_INFORMATION = ICON_INFORMATION, |
5350ea41 PK |
70 | MSG_WARNING = (ICON_WARNING | BTN_OK | MODAL), |
71 | MSG_ERROR = (ICON_ERROR | BTN_OK | MODAL) | |
239c11d0 WL |
72 | }; |
73 | ||
ab1b288f | 74 | /** Show message box. */ |
f7f3a96b | 75 | boost::signals2::signal<bool (const std::string& message, const std::string& caption, unsigned int style), boost::signals2::last_value<bool> > ThreadSafeMessageBox; |
5cccb13d | 76 | |
ab1b288f WL |
77 | /** Progress message during initialization. */ |
78 | boost::signals2::signal<void (const std::string &message)> InitMessage; | |
fe4a6550 | 79 | |
ab1b288f WL |
80 | /** Translate a message to the native language of the user. */ |
81 | boost::signals2::signal<std::string (const char* psz)> Translate; | |
fe4a6550 | 82 | |
ab1b288f WL |
83 | /** Block chain changed. */ |
84 | boost::signals2::signal<void ()> NotifyBlocksChanged; | |
fe4a6550 | 85 | |
ab1b288f WL |
86 | /** Number of network connections changed. */ |
87 | boost::signals2::signal<void (int newNumConnections)> NotifyNumConnectionsChanged; | |
88 | ||
89 | /** | |
90 | * New, updated or cancelled alert. | |
91 | * @note called with lock cs_mapAlerts held. | |
92 | */ | |
93 | boost::signals2::signal<void (const uint256 &hash, ChangeType status)> NotifyAlertChanged; | |
94 | }; | |
95 | ||
96 | extern CClientUIInterface uiInterface; | |
97 | ||
98 | /** | |
99 | * Translation function: Call Translate signal on UI interface, which returns a boost::optional result. | |
100 | * If no translation slot is registered, nothing is returned, and simply return the input. | |
fe4a6550 | 101 | */ |
ab1b288f WL |
102 | inline std::string _(const char* psz) |
103 | { | |
104 | boost::optional<std::string> rv = uiInterface.Translate(psz); | |
105 | return rv ? (*rv) : psz; | |
106 | } | |
fe4a6550 | 107 | |
467c31ea | 108 | #endif |