diff options
Diffstat (limited to 'src/ui_interface.h')
-rw-r--r-- | src/ui_interface.h | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/src/ui_interface.h b/src/ui_interface.h index 3add369df0..fe466b3ca4 100644 --- a/src/ui_interface.h +++ b/src/ui_interface.h @@ -1,20 +1,23 @@ // Copyright (c) 2010 Satoshi Nakamoto -// Copyright (c) 2012-2017 The Bitcoin Core developers +// Copyright (c) 2012-2018 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef BITCOIN_UI_INTERFACE_H #define BITCOIN_UI_INTERFACE_H +#include <functional> #include <memory> #include <stdint.h> #include <string> -#include <boost/signals2/last_value.hpp> -#include <boost/signals2/signal.hpp> - class CWallet; class CBlockIndex; +namespace boost { +namespace signals2 { +class connection; +} +} // namespace boost /** General change type (added, updated, removed). */ enum ChangeType @@ -72,43 +75,49 @@ public: MSG_ERROR = (ICON_ERROR | BTN_OK | MODAL) }; +#define ADD_SIGNALS_DECL_WRAPPER(signal_name, rtype, ...) \ + rtype signal_name(__VA_ARGS__); \ + using signal_name##Sig = rtype(__VA_ARGS__); \ + boost::signals2::connection signal_name##_connect(std::function<signal_name##Sig> fn); \ + void signal_name##_disconnect(std::function<signal_name##Sig> fn); + /** Show message box. */ - boost::signals2::signal<bool (const std::string& message, const std::string& caption, unsigned int style), boost::signals2::last_value<bool> > ThreadSafeMessageBox; + ADD_SIGNALS_DECL_WRAPPER(ThreadSafeMessageBox, bool, const std::string& message, const std::string& caption, unsigned int style); /** If possible, ask the user a question. If not, falls back to ThreadSafeMessageBox(noninteractive_message, caption, style) and returns false. */ - 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; + ADD_SIGNALS_DECL_WRAPPER(ThreadSafeQuestion, bool, const std::string& message, const std::string& noninteractive_message, const std::string& caption, unsigned int style); /** Progress message during initialization. */ - boost::signals2::signal<void (const std::string &message)> InitMessage; + ADD_SIGNALS_DECL_WRAPPER(InitMessage, void, const std::string& message); /** Number of network connections changed. */ - boost::signals2::signal<void (int newNumConnections)> NotifyNumConnectionsChanged; + ADD_SIGNALS_DECL_WRAPPER(NotifyNumConnectionsChanged, void, int newNumConnections); /** Network activity state changed. */ - boost::signals2::signal<void (bool networkActive)> NotifyNetworkActiveChanged; + ADD_SIGNALS_DECL_WRAPPER(NotifyNetworkActiveChanged, void, bool networkActive); /** * Status bar alerts changed. */ - boost::signals2::signal<void ()> NotifyAlertChanged; + ADD_SIGNALS_DECL_WRAPPER(NotifyAlertChanged, void, ); /** A wallet has been loaded. */ - boost::signals2::signal<void (std::shared_ptr<CWallet> wallet)> LoadWallet; + ADD_SIGNALS_DECL_WRAPPER(LoadWallet, void, std::shared_ptr<CWallet> wallet); /** * Show progress e.g. for verifychain. * resume_possible indicates shutting down now will result in the current progress action resuming upon restart. */ - boost::signals2::signal<void (const std::string &title, int nProgress, bool resume_possible)> ShowProgress; + ADD_SIGNALS_DECL_WRAPPER(ShowProgress, void, const std::string& title, int nProgress, bool resume_possible); /** New block has been accepted */ - boost::signals2::signal<void (bool, const CBlockIndex *)> NotifyBlockTip; + ADD_SIGNALS_DECL_WRAPPER(NotifyBlockTip, void, bool, const CBlockIndex*); /** Best header has changed */ - boost::signals2::signal<void (bool, const CBlockIndex *)> NotifyHeaderTip; + ADD_SIGNALS_DECL_WRAPPER(NotifyHeaderTip, void, bool, const CBlockIndex*); /** Banlist did change. */ - boost::signals2::signal<void (void)> BannedListChanged; + ADD_SIGNALS_DECL_WRAPPER(BannedListChanged, void, void); }; /** Show warning message **/ |