You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ui_interface.h 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. // Copyright (c) 2010 Satoshi Nakamoto
  2. // Copyright (c) 2012-2016 The Starwels developers
  3. // Distributed under the MIT software license, see the accompanying
  4. // file COPYING or http://www.opensource.org/licenses/mit-license.php.
  5. #ifndef STARWELS_UI_INTERFACE_H
  6. #define STARWELS_UI_INTERFACE_H
  7. #include <stdint.h>
  8. #include <string>
  9. #include <boost/signals2/last_value.hpp>
  10. #include <boost/signals2/signal.hpp>
  11. class CWallet;
  12. class CBlockIndex;
  13. /** General change type (added, updated, removed). */
  14. enum ChangeType
  15. {
  16. CT_NEW,
  17. CT_UPDATED,
  18. CT_DELETED
  19. };
  20. /** Signals for UI communication. */
  21. class CClientUIInterface
  22. {
  23. public:
  24. /** Flags for CClientUIInterface::ThreadSafeMessageBox */
  25. enum MessageBoxFlags
  26. {
  27. ICON_INFORMATION = 0,
  28. ICON_WARNING = (1U << 0),
  29. ICON_ERROR = (1U << 1),
  30. /**
  31. * Mask of all available icons in CClientUIInterface::MessageBoxFlags
  32. * This needs to be updated, when icons are changed there!
  33. */
  34. ICON_MASK = (ICON_INFORMATION | ICON_WARNING | ICON_ERROR),
  35. /** These values are taken from qmessagebox.h "enum StandardButton" to be directly usable */
  36. BTN_OK = 0x00000400U, // QMessageBox::Ok
  37. BTN_YES = 0x00004000U, // QMessageBox::Yes
  38. BTN_NO = 0x00010000U, // QMessageBox::No
  39. BTN_ABORT = 0x00040000U, // QMessageBox::Abort
  40. BTN_RETRY = 0x00080000U, // QMessageBox::Retry
  41. BTN_IGNORE = 0x00100000U, // QMessageBox::Ignore
  42. BTN_CLOSE = 0x00200000U, // QMessageBox::Close
  43. BTN_CANCEL = 0x00400000U, // QMessageBox::Cancel
  44. BTN_DISCARD = 0x00800000U, // QMessageBox::Discard
  45. BTN_HELP = 0x01000000U, // QMessageBox::Help
  46. BTN_APPLY = 0x02000000U, // QMessageBox::Apply
  47. BTN_RESET = 0x04000000U, // QMessageBox::Reset
  48. /**
  49. * Mask of all available buttons in CClientUIInterface::MessageBoxFlags
  50. * This needs to be updated, when buttons are changed there!
  51. */
  52. BTN_MASK = (BTN_OK | BTN_YES | BTN_NO | BTN_ABORT | BTN_RETRY | BTN_IGNORE |
  53. BTN_CLOSE | BTN_CANCEL | BTN_DISCARD | BTN_HELP | BTN_APPLY | BTN_RESET),
  54. /** Force blocking, modal message box dialog (not just OS notification) */
  55. MODAL = 0x10000000U,
  56. /** Do not print contents of message to debug log */
  57. SECURE = 0x40000000U,
  58. /** Predefined combinations for certain default usage cases */
  59. MSG_INFORMATION = ICON_INFORMATION,
  60. MSG_WARNING = (ICON_WARNING | BTN_OK | MODAL),
  61. MSG_ERROR = (ICON_ERROR | BTN_OK | MODAL)
  62. };
  63. /** Show message box. */
  64. boost::signals2::signal<bool (const std::string& message, const std::string& caption, unsigned int style), boost::signals2::last_value<bool> > ThreadSafeMessageBox;
  65. /** If possible, ask the user a question. If not, falls back to ThreadSafeMessageBox(noninteractive_message, caption, style) and returns false. */
  66. 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;
  67. /** Progress message during initialization. */
  68. boost::signals2::signal<void (const std::string &message)> InitMessage;
  69. /** Number of network connections changed. */
  70. boost::signals2::signal<void (int newNumConnections)> NotifyNumConnectionsChanged;
  71. /** Network activity state changed. */
  72. boost::signals2::signal<void (bool networkActive)> NotifyNetworkActiveChanged;
  73. /**
  74. * Status bar alerts changed.
  75. */
  76. boost::signals2::signal<void ()> NotifyAlertChanged;
  77. /** A wallet has been loaded. */
  78. boost::signals2::signal<void (CWallet* wallet)> LoadWallet;
  79. /** Show progress e.g. for verifychain */
  80. boost::signals2::signal<void (const std::string &title, int nProgress)> ShowProgress;
  81. /** Set progress break action (possible "cancel button" triggers that action) */
  82. boost::signals2::signal<void (std::function<void(void)> action)> SetProgressBreakAction;
  83. /** New block has been accepted */
  84. boost::signals2::signal<void (bool, const CBlockIndex *)> NotifyBlockTip;
  85. /** Best header has changed */
  86. boost::signals2::signal<void (bool, const CBlockIndex *)> NotifyHeaderTip;
  87. /** Banlist did change. */
  88. boost::signals2::signal<void (void)> BannedListChanged;
  89. };
  90. /** Show warning message **/
  91. void InitWarning(const std::string& str);
  92. /** Show error message **/
  93. bool InitError(const std::string& str);
  94. std::string AmountHighWarn(const std::string& optname);
  95. std::string AmountErrMsg(const char* const optname, const std::string& strValue);
  96. extern CClientUIInterface uiInterface;
  97. #endif // STARWELS_UI_INTERFACE_H