mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-26 23:09:03 +02:00
gui: Replace interface::Node references with pointers
No change in behavior. Replacing references with pointers allows Node interface creation to be delayed until later during gui startup next commit to support implementing -ipcconnect option
This commit is contained in:
@@ -24,8 +24,8 @@
|
||||
#include <QScreen>
|
||||
|
||||
|
||||
SplashScreen::SplashScreen(interfaces::Node& node, Qt::WindowFlags f, const NetworkStyle *networkStyle) :
|
||||
QWidget(nullptr, f), curAlignment(0), m_node(node)
|
||||
SplashScreen::SplashScreen(Qt::WindowFlags f, const NetworkStyle *networkStyle) :
|
||||
QWidget(nullptr, f), curAlignment(0)
|
||||
{
|
||||
// set reference point, paddings
|
||||
int paddingRight = 50;
|
||||
@@ -124,7 +124,6 @@ SplashScreen::SplashScreen(interfaces::Node& node, Qt::WindowFlags f, const Netw
|
||||
setFixedSize(r.size());
|
||||
move(QGuiApplication::primaryScreen()->geometry().center() - r.center());
|
||||
|
||||
subscribeToCoreSignals();
|
||||
installEventFilter(this);
|
||||
|
||||
GUIUtil::handleCloseWindowShortcut(this);
|
||||
@@ -132,14 +131,26 @@ SplashScreen::SplashScreen(interfaces::Node& node, Qt::WindowFlags f, const Netw
|
||||
|
||||
SplashScreen::~SplashScreen()
|
||||
{
|
||||
unsubscribeFromCoreSignals();
|
||||
if (m_node) unsubscribeFromCoreSignals();
|
||||
}
|
||||
|
||||
void SplashScreen::setNode(interfaces::Node& node)
|
||||
{
|
||||
assert(!m_node);
|
||||
m_node = &node;
|
||||
subscribeToCoreSignals();
|
||||
}
|
||||
|
||||
void SplashScreen::shutdown()
|
||||
{
|
||||
if (m_node) m_node->startShutdown();
|
||||
}
|
||||
|
||||
bool SplashScreen::eventFilter(QObject * obj, QEvent * ev) {
|
||||
if (ev->type() == QEvent::KeyPress) {
|
||||
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(ev);
|
||||
if (keyEvent->key() == Qt::Key_Q) {
|
||||
m_node.startShutdown();
|
||||
shutdown();
|
||||
}
|
||||
}
|
||||
return QObject::eventFilter(obj, ev);
|
||||
@@ -183,10 +194,10 @@ void SplashScreen::ConnectWallet(std::unique_ptr<interfaces::Wallet> wallet)
|
||||
void SplashScreen::subscribeToCoreSignals()
|
||||
{
|
||||
// Connect signals to client
|
||||
m_handler_init_message = m_node.handleInitMessage(std::bind(InitMessage, this, std::placeholders::_1));
|
||||
m_handler_show_progress = m_node.handleShowProgress(std::bind(ShowProgress, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
|
||||
m_handler_init_message = m_node->handleInitMessage(std::bind(InitMessage, this, std::placeholders::_1));
|
||||
m_handler_show_progress = m_node->handleShowProgress(std::bind(ShowProgress, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
|
||||
#ifdef ENABLE_WALLET
|
||||
m_handler_load_wallet = m_node.handleLoadWallet([this](std::unique_ptr<interfaces::Wallet> wallet) { ConnectWallet(std::move(wallet)); });
|
||||
m_handler_load_wallet = m_node->handleLoadWallet([this](std::unique_ptr<interfaces::Wallet> wallet) { ConnectWallet(std::move(wallet)); });
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -221,6 +232,6 @@ void SplashScreen::paintEvent(QPaintEvent *event)
|
||||
|
||||
void SplashScreen::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
m_node.startShutdown(); // allows an "emergency" shutdown during startup
|
||||
shutdown(); // allows an "emergency" shutdown during startup
|
||||
event->ignore();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user