Merge bitcoin-core/gui#35: Parse params directly instead of through node (partial revert #10244)
519cae8fd6gui: Delay interfaces::Node initialization (Russell Yanofsky)102abff9ebgui: Replace interface::Node references with pointers (Russell Yanofsky)91aced7c7egui: Remove unused interfaces::Node references (Russell Yanofsky)e133631625gui: Partially revert #10244 gArgs and Params changes (Russell Yanofsky) Pull request description: This PR is part of the [process separation project](https://github.com/bitcoin/bitcoin/projects/10). --- This is a partial revert of https://github.com/bitcoin/bitcoin/pull/10244. It changes gui code to go back to using gArgs and Params() functions directly instead of using interfaces::Node to handle arguments. These changes were originally pushed as part of https://github.com/bitcoin/bitcoin/pull/19461. Motivation is to support a new GUI process connecting to an already running node process. Details are explained in commit messages, but in addition to spawning a new bitcoin-node process, we want bitcoin-gui to connect to an existing bitcoin-node process. So for that reason it should be able to parse its own parameters, rather than rely on the node. ACKs for top commit: MarcoFalke: re-ACK519cae8fd6, only change is rebase and addressed nits of my previous review last week 🌄 Tree-SHA512: 9c339dd82ba78bcc7b887b84d872f35ccc7dfa3d271691e6eafe8a2048cbbe3bdde1e810ce33d0714d75d048c9de3470e9e9b6f8306a6047d1cb3548f6858dc8
This commit is contained in:
18 files changed
+125
-142
No files matched your search
+2
-17
@@ -57,22 +57,8 @@ class NodeImpl : public Node
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NodeImpl(NodeContext* context) { setContext(context); }
|
NodeImpl(NodeContext* context) { setContext(context); }
|
||||||
void initError(const bilingual_str& message) override { InitError(message); }
|
void initLogging() override { InitLogging(*Assert(m_context->args)); }
|
||||||
bool parseParameters(int argc, const char* const argv[], std::string& error) override
|
void initParameterInteraction() override { InitParameterInteraction(*Assert(m_context->args)); }
|
||||||
{
|
|
||||||
return gArgs.ParseParameters(argc, argv, error);
|
|
||||||
}
|
|
||||||
bool readConfigFiles(std::string& error) override { return gArgs.ReadConfigFiles(error, true); }
|
|
||||||
void forceSetArg(const std::string& arg, const std::string& value) override { gArgs.ForceSetArg(arg, value); }
|
|
||||||
bool softSetArg(const std::string& arg, const std::string& value) override { return gArgs.SoftSetArg(arg, value); }
|
|
||||||
bool softSetBoolArg(const std::string& arg, bool value) override { return gArgs.SoftSetBoolArg(arg, value); }
|
|
||||||
void selectParams(const std::string& network) override { SelectParams(network); }
|
|
||||||
bool initSettings(std::string& error) override { return gArgs.InitSettings(error); }
|
|
||||||
uint64_t getAssumedBlockchainSize() override { return Params().AssumedBlockchainSize(); }
|
|
||||||
uint64_t getAssumedChainStateSize() override { return Params().AssumedChainStateSize(); }
|
|
||||||
std::string getNetwork() override { return Params().NetworkIDString(); }
|
|
||||||
void initLogging() override { InitLogging(gArgs); }
|
|
||||||
void initParameterInteraction() override { InitParameterInteraction(gArgs); }
|
|
||||||
bilingual_str getWarnings() override { return GetWarnings(true); }
|
bilingual_str getWarnings() override { return GetWarnings(true); }
|
||||||
uint32_t getLogCategories() override { return LogInstance().GetCategoryMask(); }
|
uint32_t getLogCategories() override { return LogInstance().GetCategoryMask(); }
|
||||||
bool baseInitialize() override
|
bool baseInitialize() override
|
||||||
@@ -109,7 +95,6 @@ public:
|
|||||||
StopMapPort();
|
StopMapPort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void setupServerArgs() override { return SetupServerArgs(*m_context); }
|
|
||||||
bool getProxy(Network net, proxyType& proxy_info) override { return GetProxy(net, proxy_info); }
|
bool getProxy(Network net, proxyType& proxy_info) override { return GetProxy(net, proxy_info); }
|
||||||
size_t getNodeCount(CConnman::NumConnections flags) override
|
size_t getNodeCount(CConnman::NumConnections flags) override
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -55,41 +55,6 @@ class Node
|
|||||||
public:
|
public:
|
||||||
virtual ~Node() {}
|
virtual ~Node() {}
|
||||||
|
|
||||||
//! Send init error.
|
|
||||||
virtual void initError(const bilingual_str& message) = 0;
|
|
||||||
|
|
||||||
//! Set command line arguments.
|
|
||||||
virtual bool parseParameters(int argc, const char* const argv[], std::string& error) = 0;
|
|
||||||
|
|
||||||
//! Set a command line argument
|
|
||||||
virtual void forceSetArg(const std::string& arg, const std::string& value) = 0;
|
|
||||||
|
|
||||||
//! Set a command line argument if it doesn't already have a value
|
|
||||||
virtual bool softSetArg(const std::string& arg, const std::string& value) = 0;
|
|
||||||
|
|
||||||
//! Set a command line boolean argument if it doesn't already have a value
|
|
||||||
virtual bool softSetBoolArg(const std::string& arg, bool value) = 0;
|
|
||||||
|
|
||||||
//! Load settings from configuration file.
|
|
||||||
virtual bool readConfigFiles(std::string& error) = 0;
|
|
||||||
|
|
||||||
//! Choose network parameters.
|
|
||||||
virtual void selectParams(const std::string& network) = 0;
|
|
||||||
|
|
||||||
//! Read and update <datadir>/settings.json file with saved settings. This
|
|
||||||
//! needs to be called after selectParams() because the settings file
|
|
||||||
//! location is network-specific.
|
|
||||||
virtual bool initSettings(std::string& error) = 0;
|
|
||||||
|
|
||||||
//! Get the (assumed) blockchain size.
|
|
||||||
virtual uint64_t getAssumedBlockchainSize() = 0;
|
|
||||||
|
|
||||||
//! Get the (assumed) chain state size.
|
|
||||||
virtual uint64_t getAssumedChainStateSize() = 0;
|
|
||||||
|
|
||||||
//! Get network name.
|
|
||||||
virtual std::string getNetwork() = 0;
|
|
||||||
|
|
||||||
//! Init logging.
|
//! Init logging.
|
||||||
virtual void initLogging() = 0;
|
virtual void initLogging() = 0;
|
||||||
|
|
||||||
@@ -117,9 +82,6 @@ public:
|
|||||||
//! Return whether shutdown was requested.
|
//! Return whether shutdown was requested.
|
||||||
virtual bool shutdownRequested() = 0;
|
virtual bool shutdownRequested() = 0;
|
||||||
|
|
||||||
//! Setup arguments
|
|
||||||
virtual void setupServerArgs() = 0;
|
|
||||||
|
|
||||||
//! Map port.
|
//! Map port.
|
||||||
virtual void mapPort(bool use_upnp) = 0;
|
virtual void mapPort(bool use_upnp) = 0;
|
||||||
|
|
||||||
|
|||||||
+46
-33
@@ -27,9 +27,11 @@
|
|||||||
#include <qt/walletmodel.h>
|
#include <qt/walletmodel.h>
|
||||||
#endif // ENABLE_WALLET
|
#endif // ENABLE_WALLET
|
||||||
|
|
||||||
|
#include <init.h>
|
||||||
#include <interfaces/handler.h>
|
#include <interfaces/handler.h>
|
||||||
#include <interfaces/node.h>
|
#include <interfaces/node.h>
|
||||||
#include <node/context.h>
|
#include <node/context.h>
|
||||||
|
#include <node/ui_interface.h>
|
||||||
#include <noui.h>
|
#include <noui.h>
|
||||||
#include <uint256.h>
|
#include <uint256.h>
|
||||||
#include <util/system.h>
|
#include <util/system.h>
|
||||||
@@ -37,6 +39,7 @@
|
|||||||
#include <util/translation.h>
|
#include <util/translation.h>
|
||||||
#include <validation.h>
|
#include <validation.h>
|
||||||
|
|
||||||
|
#include <boost/signals2/connection.hpp>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
@@ -193,10 +196,9 @@ void BitcoinCore::shutdown()
|
|||||||
static int qt_argc = 1;
|
static int qt_argc = 1;
|
||||||
static const char* qt_argv = "bitcoin-qt";
|
static const char* qt_argv = "bitcoin-qt";
|
||||||
|
|
||||||
BitcoinApplication::BitcoinApplication(interfaces::Node& node):
|
BitcoinApplication::BitcoinApplication():
|
||||||
QApplication(qt_argc, const_cast<char **>(&qt_argv)),
|
QApplication(qt_argc, const_cast<char **>(&qt_argv)),
|
||||||
coreThread(nullptr),
|
coreThread(nullptr),
|
||||||
m_node(node),
|
|
||||||
optionsModel(nullptr),
|
optionsModel(nullptr),
|
||||||
clientModel(nullptr),
|
clientModel(nullptr),
|
||||||
window(nullptr),
|
window(nullptr),
|
||||||
@@ -246,12 +248,12 @@ void BitcoinApplication::createPaymentServer()
|
|||||||
|
|
||||||
void BitcoinApplication::createOptionsModel(bool resetSettings)
|
void BitcoinApplication::createOptionsModel(bool resetSettings)
|
||||||
{
|
{
|
||||||
optionsModel = new OptionsModel(m_node, this, resetSettings);
|
optionsModel = new OptionsModel(this, resetSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitcoinApplication::createWindow(const NetworkStyle *networkStyle)
|
void BitcoinApplication::createWindow(const NetworkStyle *networkStyle)
|
||||||
{
|
{
|
||||||
window = new BitcoinGUI(m_node, platformStyle, networkStyle, nullptr);
|
window = new BitcoinGUI(node(), platformStyle, networkStyle, nullptr);
|
||||||
|
|
||||||
pollShutdownTimer = new QTimer(window);
|
pollShutdownTimer = new QTimer(window);
|
||||||
connect(pollShutdownTimer, &QTimer::timeout, window, &BitcoinGUI::detectShutdown);
|
connect(pollShutdownTimer, &QTimer::timeout, window, &BitcoinGUI::detectShutdown);
|
||||||
@@ -259,17 +261,26 @@ void BitcoinApplication::createWindow(const NetworkStyle *networkStyle)
|
|||||||
|
|
||||||
void BitcoinApplication::createSplashScreen(const NetworkStyle *networkStyle)
|
void BitcoinApplication::createSplashScreen(const NetworkStyle *networkStyle)
|
||||||
{
|
{
|
||||||
SplashScreen *splash = new SplashScreen(m_node, nullptr, networkStyle);
|
assert(!m_splash);
|
||||||
|
m_splash = new SplashScreen(nullptr, networkStyle);
|
||||||
// We don't hold a direct pointer to the splash screen after creation, but the splash
|
// We don't hold a direct pointer to the splash screen after creation, but the splash
|
||||||
// screen will take care of deleting itself when finish() happens.
|
// screen will take care of deleting itself when finish() happens.
|
||||||
splash->show();
|
m_splash->show();
|
||||||
connect(this, &BitcoinApplication::splashFinished, splash, &SplashScreen::finish);
|
connect(this, &BitcoinApplication::splashFinished, m_splash, &SplashScreen::finish);
|
||||||
connect(this, &BitcoinApplication::requestedShutdown, splash, &QWidget::close);
|
connect(this, &BitcoinApplication::requestedShutdown, m_splash, &QWidget::close);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BitcoinApplication::setNode(interfaces::Node& node)
|
||||||
|
{
|
||||||
|
assert(!m_node);
|
||||||
|
m_node = &node;
|
||||||
|
if (optionsModel) optionsModel->setNode(*m_node);
|
||||||
|
if (m_splash) m_splash->setNode(*m_node);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BitcoinApplication::baseInitialize()
|
bool BitcoinApplication::baseInitialize()
|
||||||
{
|
{
|
||||||
return m_node.baseInitialize();
|
return node().baseInitialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitcoinApplication::startThread()
|
void BitcoinApplication::startThread()
|
||||||
@@ -277,7 +288,7 @@ void BitcoinApplication::startThread()
|
|||||||
if(coreThread)
|
if(coreThread)
|
||||||
return;
|
return;
|
||||||
coreThread = new QThread(this);
|
coreThread = new QThread(this);
|
||||||
BitcoinCore *executor = new BitcoinCore(m_node);
|
BitcoinCore *executor = new BitcoinCore(node());
|
||||||
executor->moveToThread(coreThread);
|
executor->moveToThread(coreThread);
|
||||||
|
|
||||||
/* communication to and from thread */
|
/* communication to and from thread */
|
||||||
@@ -298,8 +309,8 @@ void BitcoinApplication::parameterSetup()
|
|||||||
// print to the console unnecessarily.
|
// print to the console unnecessarily.
|
||||||
gArgs.SoftSetBoolArg("-printtoconsole", false);
|
gArgs.SoftSetBoolArg("-printtoconsole", false);
|
||||||
|
|
||||||
m_node.initLogging();
|
InitLogging(gArgs);
|
||||||
m_node.initParameterInteraction();
|
InitParameterInteraction(gArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitcoinApplication::InitializePruneSetting(bool prune)
|
void BitcoinApplication::InitializePruneSetting(bool prune)
|
||||||
@@ -331,7 +342,7 @@ void BitcoinApplication::requestShutdown()
|
|||||||
window->unsubscribeFromCoreSignals();
|
window->unsubscribeFromCoreSignals();
|
||||||
// Request node shutdown, which can interrupt long operations, like
|
// Request node shutdown, which can interrupt long operations, like
|
||||||
// rescanning a wallet.
|
// rescanning a wallet.
|
||||||
m_node.startShutdown();
|
node().startShutdown();
|
||||||
// Unsetting the client model can cause the current thread to wait for node
|
// Unsetting the client model can cause the current thread to wait for node
|
||||||
// to complete an operation, like wait for a RPC execution to complete.
|
// to complete an operation, like wait for a RPC execution to complete.
|
||||||
window->setClientModel(nullptr);
|
window->setClientModel(nullptr);
|
||||||
@@ -353,7 +364,7 @@ void BitcoinApplication::initializeResult(bool success, interfaces::BlockAndHead
|
|||||||
{
|
{
|
||||||
// Log this only after AppInitMain finishes, as then logging setup is guaranteed complete
|
// Log this only after AppInitMain finishes, as then logging setup is guaranteed complete
|
||||||
qInfo() << "Platform customization:" << platformStyle->getName();
|
qInfo() << "Platform customization:" << platformStyle->getName();
|
||||||
clientModel = new ClientModel(m_node, optionsModel);
|
clientModel = new ClientModel(node(), optionsModel);
|
||||||
window->setClientModel(clientModel, &tip_info);
|
window->setClientModel(clientModel, &tip_info);
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
if (WalletModel::isWalletEnabled()) {
|
if (WalletModel::isWalletEnabled()) {
|
||||||
@@ -437,9 +448,9 @@ int GuiMain(int argc, char* argv[])
|
|||||||
std::unique_ptr<interfaces::Node> node = interfaces::MakeNode(&node_context);
|
std::unique_ptr<interfaces::Node> node = interfaces::MakeNode(&node_context);
|
||||||
|
|
||||||
// Subscribe to global signals from core
|
// Subscribe to global signals from core
|
||||||
std::unique_ptr<interfaces::Handler> handler_message_box = node->handleMessageBox(noui_ThreadSafeMessageBox);
|
boost::signals2::scoped_connection handler_message_box = ::uiInterface.ThreadSafeMessageBox_connect(noui_ThreadSafeMessageBox);
|
||||||
std::unique_ptr<interfaces::Handler> handler_question = node->handleQuestion(noui_ThreadSafeQuestion);
|
boost::signals2::scoped_connection handler_question = ::uiInterface.ThreadSafeQuestion_connect(noui_ThreadSafeQuestion);
|
||||||
std::unique_ptr<interfaces::Handler> handler_init_message = node->handleInitMessage(noui_InitMessage);
|
boost::signals2::scoped_connection handler_init_message = ::uiInterface.InitMessage_connect(noui_InitMessage);
|
||||||
|
|
||||||
// Do not refer to data directory yet, this can be overridden by Intro::pickDataDirectory
|
// Do not refer to data directory yet, this can be overridden by Intro::pickDataDirectory
|
||||||
|
|
||||||
@@ -453,15 +464,15 @@ int GuiMain(int argc, char* argv[])
|
|||||||
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
BitcoinApplication app(*node);
|
BitcoinApplication app;
|
||||||
|
|
||||||
/// 2. Parse command-line options. We do this after qt in order to show an error if there are problems parsing these
|
/// 2. Parse command-line options. We do this after qt in order to show an error if there are problems parsing these
|
||||||
// Command-line options take precedence:
|
// Command-line options take precedence:
|
||||||
node->setupServerArgs();
|
SetupServerArgs(node_context);
|
||||||
SetupUIArgs(gArgs);
|
SetupUIArgs(gArgs);
|
||||||
std::string error;
|
std::string error;
|
||||||
if (!node->parseParameters(argc, argv, error)) {
|
if (!gArgs.ParseParameters(argc, argv, error)) {
|
||||||
node->initError(strprintf(Untranslated("Error parsing command line arguments: %s\n"), error));
|
InitError(strprintf(Untranslated("Error parsing command line arguments: %s\n"), error));
|
||||||
// Create a message box, because the gui has neither been created nor has subscribed to core signals
|
// Create a message box, because the gui has neither been created nor has subscribed to core signals
|
||||||
QMessageBox::critical(nullptr, PACKAGE_NAME,
|
QMessageBox::critical(nullptr, PACKAGE_NAME,
|
||||||
// message can not be translated because translations have not been initialized
|
// message can not be translated because translations have not been initialized
|
||||||
@@ -487,7 +498,7 @@ int GuiMain(int argc, char* argv[])
|
|||||||
// Show help message immediately after parsing command-line options (for "-lang") and setting locale,
|
// Show help message immediately after parsing command-line options (for "-lang") and setting locale,
|
||||||
// but before showing splash screen.
|
// but before showing splash screen.
|
||||||
if (HelpRequested(gArgs) || gArgs.IsArgSet("-version")) {
|
if (HelpRequested(gArgs) || gArgs.IsArgSet("-version")) {
|
||||||
HelpMessageDialog help(*node, nullptr, gArgs.IsArgSet("-version"));
|
HelpMessageDialog help(nullptr, gArgs.IsArgSet("-version"));
|
||||||
help.showOrPrint();
|
help.showOrPrint();
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
@@ -497,18 +508,18 @@ int GuiMain(int argc, char* argv[])
|
|||||||
bool did_show_intro = false;
|
bool did_show_intro = false;
|
||||||
bool prune = false; // Intro dialog prune check box
|
bool prune = false; // Intro dialog prune check box
|
||||||
// Gracefully exit if the user cancels
|
// Gracefully exit if the user cancels
|
||||||
if (!Intro::showIfNeeded(*node, did_show_intro, prune)) return EXIT_SUCCESS;
|
if (!Intro::showIfNeeded(did_show_intro, prune)) return EXIT_SUCCESS;
|
||||||
|
|
||||||
/// 6. Determine availability of data directory and parse bitcoin.conf
|
/// 6. Determine availability of data directory and parse bitcoin.conf
|
||||||
/// - Do not call GetDataDir(true) before this step finishes
|
/// - Do not call GetDataDir(true) before this step finishes
|
||||||
if (!CheckDataDirOption()) {
|
if (!CheckDataDirOption()) {
|
||||||
node->initError(strprintf(Untranslated("Specified data directory \"%s\" does not exist.\n"), gArgs.GetArg("-datadir", "")));
|
InitError(strprintf(Untranslated("Specified data directory \"%s\" does not exist.\n"), gArgs.GetArg("-datadir", "")));
|
||||||
QMessageBox::critical(nullptr, PACKAGE_NAME,
|
QMessageBox::critical(nullptr, PACKAGE_NAME,
|
||||||
QObject::tr("Error: Specified data directory \"%1\" does not exist.").arg(QString::fromStdString(gArgs.GetArg("-datadir", ""))));
|
QObject::tr("Error: Specified data directory \"%1\" does not exist.").arg(QString::fromStdString(gArgs.GetArg("-datadir", ""))));
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
if (!node->readConfigFiles(error)) {
|
if (!gArgs.ReadConfigFiles(error, true)) {
|
||||||
node->initError(strprintf(Untranslated("Error reading configuration file: %s\n"), error));
|
InitError(strprintf(Untranslated("Error reading configuration file: %s\n"), error));
|
||||||
QMessageBox::critical(nullptr, PACKAGE_NAME,
|
QMessageBox::critical(nullptr, PACKAGE_NAME,
|
||||||
QObject::tr("Error: Cannot parse configuration file: %1.").arg(QString::fromStdString(error)));
|
QObject::tr("Error: Cannot parse configuration file: %1.").arg(QString::fromStdString(error)));
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
@@ -522,18 +533,18 @@ int GuiMain(int argc, char* argv[])
|
|||||||
|
|
||||||
// Check for -chain, -testnet or -regtest parameter (Params() calls are only valid after this clause)
|
// Check for -chain, -testnet or -regtest parameter (Params() calls are only valid after this clause)
|
||||||
try {
|
try {
|
||||||
node->selectParams(gArgs.GetChainName());
|
SelectParams(gArgs.GetChainName());
|
||||||
} catch(std::exception &e) {
|
} catch(std::exception &e) {
|
||||||
node->initError(Untranslated(strprintf("%s\n", e.what())));
|
InitError(Untranslated(strprintf("%s\n", e.what())));
|
||||||
QMessageBox::critical(nullptr, PACKAGE_NAME, QObject::tr("Error: %1").arg(e.what()));
|
QMessageBox::critical(nullptr, PACKAGE_NAME, QObject::tr("Error: %1").arg(e.what()));
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
// Parse URIs on command line -- this can affect Params()
|
// Parse URIs on command line -- this can affect Params()
|
||||||
PaymentServer::ipcParseCommandLine(*node, argc, argv);
|
PaymentServer::ipcParseCommandLine(argc, argv);
|
||||||
#endif
|
#endif
|
||||||
if (!node->initSettings(error)) {
|
if (!gArgs.InitSettings(error)) {
|
||||||
node->initError(Untranslated(error));
|
InitError(Untranslated(error));
|
||||||
QMessageBox::critical(nullptr, PACKAGE_NAME, QObject::tr("Error initializing settings: %1").arg(QString::fromStdString(error)));
|
QMessageBox::critical(nullptr, PACKAGE_NAME, QObject::tr("Error initializing settings: %1").arg(QString::fromStdString(error)));
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
@@ -587,6 +598,8 @@ int GuiMain(int argc, char* argv[])
|
|||||||
if (gArgs.GetBoolArg("-splash", DEFAULT_SPLASHSCREEN) && !gArgs.GetBoolArg("-min", false))
|
if (gArgs.GetBoolArg("-splash", DEFAULT_SPLASHSCREEN) && !gArgs.GetBoolArg("-min", false))
|
||||||
app.createSplashScreen(networkStyle.data());
|
app.createSplashScreen(networkStyle.data());
|
||||||
|
|
||||||
|
app.setNode(*node);
|
||||||
|
|
||||||
int rv = EXIT_SUCCESS;
|
int rv = EXIT_SUCCESS;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -609,10 +622,10 @@ int GuiMain(int argc, char* argv[])
|
|||||||
}
|
}
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
PrintExceptionContinue(&e, "Runaway exception");
|
PrintExceptionContinue(&e, "Runaway exception");
|
||||||
app.handleRunawayException(QString::fromStdString(node->getWarnings().translated));
|
app.handleRunawayException(QString::fromStdString(app.node().getWarnings().translated));
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
PrintExceptionContinue(nullptr, "Runaway exception");
|
PrintExceptionContinue(nullptr, "Runaway exception");
|
||||||
app.handleRunawayException(QString::fromStdString(node->getWarnings().translated));
|
app.handleRunawayException(QString::fromStdString(app.node().getWarnings().translated));
|
||||||
}
|
}
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
+8
-2
@@ -10,6 +10,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <assert.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include <interfaces/node.h>
|
#include <interfaces/node.h>
|
||||||
@@ -20,6 +21,7 @@ class NetworkStyle;
|
|||||||
class OptionsModel;
|
class OptionsModel;
|
||||||
class PaymentServer;
|
class PaymentServer;
|
||||||
class PlatformStyle;
|
class PlatformStyle;
|
||||||
|
class SplashScreen;
|
||||||
class WalletController;
|
class WalletController;
|
||||||
class WalletModel;
|
class WalletModel;
|
||||||
|
|
||||||
@@ -54,7 +56,7 @@ class BitcoinApplication: public QApplication
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit BitcoinApplication(interfaces::Node& node);
|
explicit BitcoinApplication();
|
||||||
~BitcoinApplication();
|
~BitcoinApplication();
|
||||||
|
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
@@ -88,6 +90,9 @@ public:
|
|||||||
/// Setup platform style
|
/// Setup platform style
|
||||||
void setupPlatformStyle();
|
void setupPlatformStyle();
|
||||||
|
|
||||||
|
interfaces::Node& node() const { assert(m_node); return *m_node; }
|
||||||
|
void setNode(interfaces::Node& node);
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void initializeResult(bool success, interfaces::BlockAndHeaderTipInfo tip_info);
|
void initializeResult(bool success, interfaces::BlockAndHeaderTipInfo tip_info);
|
||||||
void shutdownResult();
|
void shutdownResult();
|
||||||
@@ -102,7 +107,6 @@ Q_SIGNALS:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QThread *coreThread;
|
QThread *coreThread;
|
||||||
interfaces::Node& m_node;
|
|
||||||
OptionsModel *optionsModel;
|
OptionsModel *optionsModel;
|
||||||
ClientModel *clientModel;
|
ClientModel *clientModel;
|
||||||
BitcoinGUI *window;
|
BitcoinGUI *window;
|
||||||
@@ -114,6 +118,8 @@ private:
|
|||||||
int returnValue;
|
int returnValue;
|
||||||
const PlatformStyle *platformStyle;
|
const PlatformStyle *platformStyle;
|
||||||
std::unique_ptr<QWidget> shutdownWindow;
|
std::unique_ptr<QWidget> shutdownWindow;
|
||||||
|
SplashScreen* m_splash = nullptr;
|
||||||
|
interfaces::Node* m_node = nullptr;
|
||||||
|
|
||||||
void startThread();
|
void startThread();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty
|
|||||||
updateWindowTitle();
|
updateWindowTitle();
|
||||||
|
|
||||||
rpcConsole = new RPCConsole(node, _platformStyle, nullptr);
|
rpcConsole = new RPCConsole(node, _platformStyle, nullptr);
|
||||||
helpMessageDialog = new HelpMessageDialog(node, this, false);
|
helpMessageDialog = new HelpMessageDialog(this, false);
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
if(enableWallet)
|
if(enableWallet)
|
||||||
{
|
{
|
||||||
@@ -821,7 +821,7 @@ void BitcoinGUI::aboutClicked()
|
|||||||
if(!clientModel)
|
if(!clientModel)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
HelpMessageDialog dlg(m_node, this, true);
|
HelpMessageDialog dlg(this, true);
|
||||||
dlg.exec();
|
dlg.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-4
@@ -6,6 +6,7 @@
|
|||||||
#include <config/bitcoin-config.h>
|
#include <config/bitcoin-config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <chainparams.h>
|
||||||
#include <fs.h>
|
#include <fs.h>
|
||||||
#include <qt/intro.h>
|
#include <qt/intro.h>
|
||||||
#include <qt/forms/ui_intro.h>
|
#include <qt/forms/ui_intro.h>
|
||||||
@@ -181,7 +182,7 @@ void Intro::setDataDirectory(const QString &dataDir)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Intro::showIfNeeded(interfaces::Node& node, bool& did_show_intro, bool& prune)
|
bool Intro::showIfNeeded(bool& did_show_intro, bool& prune)
|
||||||
{
|
{
|
||||||
did_show_intro = false;
|
did_show_intro = false;
|
||||||
|
|
||||||
@@ -199,13 +200,13 @@ bool Intro::showIfNeeded(interfaces::Node& node, bool& did_show_intro, bool& pru
|
|||||||
{
|
{
|
||||||
/* Use selectParams here to guarantee Params() can be used by node interface */
|
/* Use selectParams here to guarantee Params() can be used by node interface */
|
||||||
try {
|
try {
|
||||||
node.selectParams(gArgs.GetChainName());
|
SelectParams(gArgs.GetChainName());
|
||||||
} catch (const std::exception&) {
|
} catch (const std::exception&) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If current default data directory does not exist, let the user choose one */
|
/* If current default data directory does not exist, let the user choose one */
|
||||||
Intro intro(0, node.getAssumedBlockchainSize(), node.getAssumedChainStateSize());
|
Intro intro(0, Params().AssumedBlockchainSize(), Params().AssumedChainStateSize());
|
||||||
intro.setDataDirectory(dataDir);
|
intro.setDataDirectory(dataDir);
|
||||||
intro.setWindowIcon(QIcon(":icons/bitcoin"));
|
intro.setWindowIcon(QIcon(":icons/bitcoin"));
|
||||||
did_show_intro = true;
|
did_show_intro = true;
|
||||||
@@ -242,7 +243,7 @@ bool Intro::showIfNeeded(interfaces::Node& node, bool& did_show_intro, bool& pru
|
|||||||
* (to be consistent with bitcoind behavior)
|
* (to be consistent with bitcoind behavior)
|
||||||
*/
|
*/
|
||||||
if(dataDir != GUIUtil::getDefaultDataDirectory()) {
|
if(dataDir != GUIUtil::getDefaultDataDirectory()) {
|
||||||
node.softSetArg("-datadir", GUIUtil::qstringToBoostPath(dataDir).string()); // use OS locale for path setting
|
gArgs.SoftSetArg("-datadir", GUIUtil::qstringToBoostPath(dataDir).string()); // use OS locale for path setting
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -47,7 +47,7 @@ public:
|
|||||||
* @note do NOT call global GetDataDir() before calling this function, this
|
* @note do NOT call global GetDataDir() before calling this function, this
|
||||||
* will cause the wrong path to be cached.
|
* will cause the wrong path to be cached.
|
||||||
*/
|
*/
|
||||||
static bool showIfNeeded(interfaces::Node& node, bool& did_show_intro, bool& prune);
|
static bool showIfNeeded(bool& did_show_intro, bool& prune);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void requestCheck();
|
void requestCheck();
|
||||||
|
|||||||
+13
-13
@@ -27,8 +27,8 @@ const char *DEFAULT_GUI_PROXY_HOST = "127.0.0.1";
|
|||||||
|
|
||||||
static const QString GetDefaultProxyAddress();
|
static const QString GetDefaultProxyAddress();
|
||||||
|
|
||||||
OptionsModel::OptionsModel(interfaces::Node& node, QObject *parent, bool resetSettings) :
|
OptionsModel::OptionsModel(QObject *parent, bool resetSettings) :
|
||||||
QAbstractListModel(parent), m_node(node)
|
QAbstractListModel(parent)
|
||||||
{
|
{
|
||||||
Init(resetSettings);
|
Init(resetSettings);
|
||||||
}
|
}
|
||||||
@@ -97,12 +97,12 @@ void OptionsModel::Init(bool resetSettings)
|
|||||||
|
|
||||||
if (!settings.contains("nDatabaseCache"))
|
if (!settings.contains("nDatabaseCache"))
|
||||||
settings.setValue("nDatabaseCache", (qint64)nDefaultDbCache);
|
settings.setValue("nDatabaseCache", (qint64)nDefaultDbCache);
|
||||||
if (!m_node.softSetArg("-dbcache", settings.value("nDatabaseCache").toString().toStdString()))
|
if (!gArgs.SoftSetArg("-dbcache", settings.value("nDatabaseCache").toString().toStdString()))
|
||||||
addOverriddenOption("-dbcache");
|
addOverriddenOption("-dbcache");
|
||||||
|
|
||||||
if (!settings.contains("nThreadsScriptVerif"))
|
if (!settings.contains("nThreadsScriptVerif"))
|
||||||
settings.setValue("nThreadsScriptVerif", DEFAULT_SCRIPTCHECK_THREADS);
|
settings.setValue("nThreadsScriptVerif", DEFAULT_SCRIPTCHECK_THREADS);
|
||||||
if (!m_node.softSetArg("-par", settings.value("nThreadsScriptVerif").toString().toStdString()))
|
if (!gArgs.SoftSetArg("-par", settings.value("nThreadsScriptVerif").toString().toStdString()))
|
||||||
addOverriddenOption("-par");
|
addOverriddenOption("-par");
|
||||||
|
|
||||||
if (!settings.contains("strDataDir"))
|
if (!settings.contains("strDataDir"))
|
||||||
@@ -112,19 +112,19 @@ void OptionsModel::Init(bool resetSettings)
|
|||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
if (!settings.contains("bSpendZeroConfChange"))
|
if (!settings.contains("bSpendZeroConfChange"))
|
||||||
settings.setValue("bSpendZeroConfChange", true);
|
settings.setValue("bSpendZeroConfChange", true);
|
||||||
if (!m_node.softSetBoolArg("-spendzeroconfchange", settings.value("bSpendZeroConfChange").toBool()))
|
if (!gArgs.SoftSetBoolArg("-spendzeroconfchange", settings.value("bSpendZeroConfChange").toBool()))
|
||||||
addOverriddenOption("-spendzeroconfchange");
|
addOverriddenOption("-spendzeroconfchange");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Network
|
// Network
|
||||||
if (!settings.contains("fUseUPnP"))
|
if (!settings.contains("fUseUPnP"))
|
||||||
settings.setValue("fUseUPnP", DEFAULT_UPNP);
|
settings.setValue("fUseUPnP", DEFAULT_UPNP);
|
||||||
if (!m_node.softSetBoolArg("-upnp", settings.value("fUseUPnP").toBool()))
|
if (!gArgs.SoftSetBoolArg("-upnp", settings.value("fUseUPnP").toBool()))
|
||||||
addOverriddenOption("-upnp");
|
addOverriddenOption("-upnp");
|
||||||
|
|
||||||
if (!settings.contains("fListen"))
|
if (!settings.contains("fListen"))
|
||||||
settings.setValue("fListen", DEFAULT_LISTEN);
|
settings.setValue("fListen", DEFAULT_LISTEN);
|
||||||
if (!m_node.softSetBoolArg("-listen", settings.value("fListen").toBool()))
|
if (!gArgs.SoftSetBoolArg("-listen", settings.value("fListen").toBool()))
|
||||||
addOverriddenOption("-listen");
|
addOverriddenOption("-listen");
|
||||||
|
|
||||||
if (!settings.contains("fUseProxy"))
|
if (!settings.contains("fUseProxy"))
|
||||||
@@ -132,7 +132,7 @@ void OptionsModel::Init(bool resetSettings)
|
|||||||
if (!settings.contains("addrProxy"))
|
if (!settings.contains("addrProxy"))
|
||||||
settings.setValue("addrProxy", GetDefaultProxyAddress());
|
settings.setValue("addrProxy", GetDefaultProxyAddress());
|
||||||
// Only try to set -proxy, if user has enabled fUseProxy
|
// Only try to set -proxy, if user has enabled fUseProxy
|
||||||
if (settings.value("fUseProxy").toBool() && !m_node.softSetArg("-proxy", settings.value("addrProxy").toString().toStdString()))
|
if ((settings.value("fUseProxy").toBool() && !gArgs.SoftSetArg("-proxy", settings.value("addrProxy").toString().toStdString())))
|
||||||
addOverriddenOption("-proxy");
|
addOverriddenOption("-proxy");
|
||||||
else if(!settings.value("fUseProxy").toBool() && !gArgs.GetArg("-proxy", "").empty())
|
else if(!settings.value("fUseProxy").toBool() && !gArgs.GetArg("-proxy", "").empty())
|
||||||
addOverriddenOption("-proxy");
|
addOverriddenOption("-proxy");
|
||||||
@@ -142,7 +142,7 @@ void OptionsModel::Init(bool resetSettings)
|
|||||||
if (!settings.contains("addrSeparateProxyTor"))
|
if (!settings.contains("addrSeparateProxyTor"))
|
||||||
settings.setValue("addrSeparateProxyTor", GetDefaultProxyAddress());
|
settings.setValue("addrSeparateProxyTor", GetDefaultProxyAddress());
|
||||||
// Only try to set -onion, if user has enabled fUseSeparateProxyTor
|
// Only try to set -onion, if user has enabled fUseSeparateProxyTor
|
||||||
if (settings.value("fUseSeparateProxyTor").toBool() && !m_node.softSetArg("-onion", settings.value("addrSeparateProxyTor").toString().toStdString()))
|
if ((settings.value("fUseSeparateProxyTor").toBool() && !gArgs.SoftSetArg("-onion", settings.value("addrSeparateProxyTor").toString().toStdString())))
|
||||||
addOverriddenOption("-onion");
|
addOverriddenOption("-onion");
|
||||||
else if(!settings.value("fUseSeparateProxyTor").toBool() && !gArgs.GetArg("-onion", "").empty())
|
else if(!settings.value("fUseSeparateProxyTor").toBool() && !gArgs.GetArg("-onion", "").empty())
|
||||||
addOverriddenOption("-onion");
|
addOverriddenOption("-onion");
|
||||||
@@ -150,7 +150,7 @@ void OptionsModel::Init(bool resetSettings)
|
|||||||
// Display
|
// Display
|
||||||
if (!settings.contains("language"))
|
if (!settings.contains("language"))
|
||||||
settings.setValue("language", "");
|
settings.setValue("language", "");
|
||||||
if (!m_node.softSetArg("-lang", settings.value("language").toString().toStdString()))
|
if (!gArgs.SoftSetArg("-lang", settings.value("language").toString().toStdString()))
|
||||||
addOverriddenOption("-lang");
|
addOverriddenOption("-lang");
|
||||||
|
|
||||||
language = settings.value("language").toString();
|
language = settings.value("language").toString();
|
||||||
@@ -244,10 +244,10 @@ void OptionsModel::SetPruneEnabled(bool prune, bool force)
|
|||||||
const int64_t prune_target_mib = PruneGBtoMiB(settings.value("nPruneSize").toInt());
|
const int64_t prune_target_mib = PruneGBtoMiB(settings.value("nPruneSize").toInt());
|
||||||
std::string prune_val = prune ? ToString(prune_target_mib) : "0";
|
std::string prune_val = prune ? ToString(prune_target_mib) : "0";
|
||||||
if (force) {
|
if (force) {
|
||||||
m_node.forceSetArg("-prune", prune_val);
|
gArgs.ForceSetArg("-prune", prune_val);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!m_node.softSetArg("-prune", prune_val)) {
|
if (!gArgs.SoftSetArg("-prune", prune_val)) {
|
||||||
addOverriddenOption("-prune");
|
addOverriddenOption("-prune");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -353,7 +353,7 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
|
|||||||
break;
|
break;
|
||||||
case MapPortUPnP: // core option - can be changed on-the-fly
|
case MapPortUPnP: // core option - can be changed on-the-fly
|
||||||
settings.setValue("fUseUPnP", value.toBool());
|
settings.setValue("fUseUPnP", value.toBool());
|
||||||
m_node.mapPort(value.toBool());
|
node().mapPort(value.toBool());
|
||||||
break;
|
break;
|
||||||
case MinimizeOnClose:
|
case MinimizeOnClose:
|
||||||
fMinimizeOnClose = value.toBool();
|
fMinimizeOnClose = value.toBool();
|
||||||
|
|||||||
@@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
#include <QAbstractListModel>
|
#include <QAbstractListModel>
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
namespace interfaces {
|
namespace interfaces {
|
||||||
class Node;
|
class Node;
|
||||||
}
|
}
|
||||||
@@ -39,7 +41,7 @@ class OptionsModel : public QAbstractListModel
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit OptionsModel(interfaces::Node& node, QObject *parent = nullptr, bool resetSettings = false);
|
explicit OptionsModel(QObject *parent = nullptr, bool resetSettings = false);
|
||||||
|
|
||||||
enum OptionID {
|
enum OptionID {
|
||||||
StartAtStartup, // bool
|
StartAtStartup, // bool
|
||||||
@@ -92,10 +94,11 @@ public:
|
|||||||
void setRestartRequired(bool fRequired);
|
void setRestartRequired(bool fRequired);
|
||||||
bool isRestartRequired() const;
|
bool isRestartRequired() const;
|
||||||
|
|
||||||
interfaces::Node& node() const { return m_node; }
|
interfaces::Node& node() const { assert(m_node); return *m_node; }
|
||||||
|
void setNode(interfaces::Node& node) { assert(!m_node); m_node = &node; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
interfaces::Node& m_node;
|
interfaces::Node* m_node = nullptr;
|
||||||
/* Qt-only settings */
|
/* Qt-only settings */
|
||||||
bool fHideTrayIcon;
|
bool fHideTrayIcon;
|
||||||
bool fMinimizeToTray;
|
bool fMinimizeToTray;
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ static QSet<QString> savedPaymentRequests;
|
|||||||
// Warning: ipcSendCommandLine() is called early in init,
|
// Warning: ipcSendCommandLine() is called early in init,
|
||||||
// so don't use "Q_EMIT message()", but "QMessageBox::"!
|
// so don't use "Q_EMIT message()", but "QMessageBox::"!
|
||||||
//
|
//
|
||||||
void PaymentServer::ipcParseCommandLine(interfaces::Node& node, int argc, char* argv[])
|
void PaymentServer::ipcParseCommandLine(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
for (int i = 1; i < argc; i++)
|
for (int i = 1; i < argc; i++)
|
||||||
{
|
{
|
||||||
@@ -97,11 +97,11 @@ void PaymentServer::ipcParseCommandLine(interfaces::Node& node, int argc, char*
|
|||||||
auto tempChainParams = CreateChainParams(CBaseChainParams::MAIN);
|
auto tempChainParams = CreateChainParams(CBaseChainParams::MAIN);
|
||||||
|
|
||||||
if (IsValidDestinationString(r.address.toStdString(), *tempChainParams)) {
|
if (IsValidDestinationString(r.address.toStdString(), *tempChainParams)) {
|
||||||
node.selectParams(CBaseChainParams::MAIN);
|
SelectParams(CBaseChainParams::MAIN);
|
||||||
} else {
|
} else {
|
||||||
tempChainParams = CreateChainParams(CBaseChainParams::TESTNET);
|
tempChainParams = CreateChainParams(CBaseChainParams::TESTNET);
|
||||||
if (IsValidDestinationString(r.address.toStdString(), *tempChainParams)) {
|
if (IsValidDestinationString(r.address.toStdString(), *tempChainParams)) {
|
||||||
node.selectParams(CBaseChainParams::TESTNET);
|
SelectParams(CBaseChainParams::TESTNET);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ class PaymentServer : public QObject
|
|||||||
public:
|
public:
|
||||||
// Parse URIs on command line
|
// Parse URIs on command line
|
||||||
// Returns false on error
|
// Returns false on error
|
||||||
static void ipcParseCommandLine(interfaces::Node& node, int argc, char *argv[]);
|
static void ipcParseCommandLine(int argc, char *argv[]);
|
||||||
|
|
||||||
// Returns true if there were URIs on the command line
|
// Returns true if there were URIs on the command line
|
||||||
// which were successfully sent to an already-running
|
// which were successfully sent to an already-running
|
||||||
|
|||||||
+22
-9
@@ -24,8 +24,8 @@
|
|||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
|
|
||||||
|
|
||||||
SplashScreen::SplashScreen(interfaces::Node& node, Qt::WindowFlags f, const NetworkStyle *networkStyle) :
|
SplashScreen::SplashScreen(Qt::WindowFlags f, const NetworkStyle *networkStyle) :
|
||||||
QWidget(nullptr, f), curAlignment(0), m_node(node)
|
QWidget(nullptr, f), curAlignment(0)
|
||||||
{
|
{
|
||||||
// set reference point, paddings
|
// set reference point, paddings
|
||||||
int paddingRight = 50;
|
int paddingRight = 50;
|
||||||
@@ -124,7 +124,6 @@ SplashScreen::SplashScreen(interfaces::Node& node, Qt::WindowFlags f, const Netw
|
|||||||
setFixedSize(r.size());
|
setFixedSize(r.size());
|
||||||
move(QGuiApplication::primaryScreen()->geometry().center() - r.center());
|
move(QGuiApplication::primaryScreen()->geometry().center() - r.center());
|
||||||
|
|
||||||
subscribeToCoreSignals();
|
|
||||||
installEventFilter(this);
|
installEventFilter(this);
|
||||||
|
|
||||||
GUIUtil::handleCloseWindowShortcut(this);
|
GUIUtil::handleCloseWindowShortcut(this);
|
||||||
@@ -132,14 +131,28 @@ SplashScreen::SplashScreen(interfaces::Node& node, Qt::WindowFlags f, const Netw
|
|||||||
|
|
||||||
SplashScreen::~SplashScreen()
|
SplashScreen::~SplashScreen()
|
||||||
{
|
{
|
||||||
unsubscribeFromCoreSignals();
|
if (m_node) unsubscribeFromCoreSignals();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SplashScreen::setNode(interfaces::Node& node)
|
||||||
|
{
|
||||||
|
assert(!m_node);
|
||||||
|
m_node = &node;
|
||||||
|
subscribeToCoreSignals();
|
||||||
|
if (m_shutdown) m_node->startShutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SplashScreen::shutdown()
|
||||||
|
{
|
||||||
|
m_shutdown = true;
|
||||||
|
if (m_node) m_node->startShutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SplashScreen::eventFilter(QObject * obj, QEvent * ev) {
|
bool SplashScreen::eventFilter(QObject * obj, QEvent * ev) {
|
||||||
if (ev->type() == QEvent::KeyPress) {
|
if (ev->type() == QEvent::KeyPress) {
|
||||||
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(ev);
|
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(ev);
|
||||||
if (keyEvent->key() == Qt::Key_Q) {
|
if (keyEvent->key() == Qt::Key_Q) {
|
||||||
m_node.startShutdown();
|
shutdown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return QObject::eventFilter(obj, ev);
|
return QObject::eventFilter(obj, ev);
|
||||||
@@ -183,10 +196,10 @@ void SplashScreen::ConnectWallet(std::unique_ptr<interfaces::Wallet> wallet)
|
|||||||
void SplashScreen::subscribeToCoreSignals()
|
void SplashScreen::subscribeToCoreSignals()
|
||||||
{
|
{
|
||||||
// Connect signals to client
|
// Connect signals to client
|
||||||
m_handler_init_message = m_node.handleInitMessage(std::bind(InitMessage, this, std::placeholders::_1));
|
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_show_progress = m_node->handleShowProgress(std::bind(ShowProgress, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
|
||||||
#ifdef ENABLE_WALLET
|
#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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,6 +234,6 @@ void SplashScreen::paintEvent(QPaintEvent *event)
|
|||||||
|
|
||||||
void SplashScreen::closeEvent(QCloseEvent *event)
|
void SplashScreen::closeEvent(QCloseEvent *event)
|
||||||
{
|
{
|
||||||
m_node.startShutdown(); // allows an "emergency" shutdown during startup
|
shutdown(); // allows an "emergency" shutdown during startup
|
||||||
event->ignore();
|
event->ignore();
|
||||||
}
|
}
|
||||||
@@ -28,8 +28,9 @@ class SplashScreen : public QWidget
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit SplashScreen(interfaces::Node& node, Qt::WindowFlags f, const NetworkStyle *networkStyle);
|
explicit SplashScreen(Qt::WindowFlags f, const NetworkStyle *networkStyle);
|
||||||
~SplashScreen();
|
~SplashScreen();
|
||||||
|
void setNode(interfaces::Node& node);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *event) override;
|
void paintEvent(QPaintEvent *event) override;
|
||||||
@@ -50,6 +51,8 @@ private:
|
|||||||
void subscribeToCoreSignals();
|
void subscribeToCoreSignals();
|
||||||
/** Disconnect core signals to splash screen */
|
/** Disconnect core signals to splash screen */
|
||||||
void unsubscribeFromCoreSignals();
|
void unsubscribeFromCoreSignals();
|
||||||
|
/** Initiate shutdown */
|
||||||
|
void shutdown();
|
||||||
/** Connect wallet signals to splash screen */
|
/** Connect wallet signals to splash screen */
|
||||||
void ConnectWallet(std::unique_ptr<interfaces::Wallet> wallet);
|
void ConnectWallet(std::unique_ptr<interfaces::Wallet> wallet);
|
||||||
|
|
||||||
@@ -58,7 +61,8 @@ private:
|
|||||||
QColor curColor;
|
QColor curColor;
|
||||||
int curAlignment;
|
int curAlignment;
|
||||||
|
|
||||||
interfaces::Node& m_node;
|
interfaces::Node* m_node = nullptr;
|
||||||
|
bool m_shutdown = false;
|
||||||
std::unique_ptr<interfaces::Handler> m_handler_init_message;
|
std::unique_ptr<interfaces::Handler> m_handler_init_message;
|
||||||
std::unique_ptr<interfaces::Handler> m_handler_show_progress;
|
std::unique_ptr<interfaces::Handler> m_handler_show_progress;
|
||||||
std::unique_ptr<interfaces::Handler> m_handler_load_wallet;
|
std::unique_ptr<interfaces::Handler> m_handler_load_wallet;
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ void TestAddAddressesToSendBook(interfaces::Node& node)
|
|||||||
|
|
||||||
// Initialize relevant QT models.
|
// Initialize relevant QT models.
|
||||||
std::unique_ptr<const PlatformStyle> platformStyle(PlatformStyle::instantiate("other"));
|
std::unique_ptr<const PlatformStyle> platformStyle(PlatformStyle::instantiate("other"));
|
||||||
OptionsModel optionsModel(node);
|
OptionsModel optionsModel;
|
||||||
ClientModel clientModel(node, &optionsModel);
|
ClientModel clientModel(node, &optionsModel);
|
||||||
AddWallet(wallet);
|
AddWallet(wallet);
|
||||||
WalletModel walletModel(interfaces::MakeWallet(wallet), clientModel, platformStyle.get());
|
WalletModel walletModel(interfaces::MakeWallet(wallet), clientModel, platformStyle.get());
|
||||||
|
|||||||
@@ -68,11 +68,11 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
// Don't remove this, it's needed to access
|
// Don't remove this, it's needed to access
|
||||||
// QApplication:: and QCoreApplication:: in the tests
|
// QApplication:: and QCoreApplication:: in the tests
|
||||||
BitcoinApplication app(*node);
|
BitcoinApplication app;
|
||||||
|
app.setNode(*node);
|
||||||
app.setApplicationName("Bitcoin-Qt-test");
|
app.setApplicationName("Bitcoin-Qt-test");
|
||||||
|
|
||||||
node->setupServerArgs(); // Make gArgs available in the NodeContext
|
app.node().context()->args = &gArgs; // Make gArgs available in the NodeContext
|
||||||
node->context()->args->ClearArgs(); // Clear added args again
|
|
||||||
AppTests app_tests(app);
|
AppTests app_tests(app);
|
||||||
if (QTest::qExec(&app_tests) != 0) {
|
if (QTest::qExec(&app_tests) != 0) {
|
||||||
fInvalid = true;
|
fInvalid = true;
|
||||||
@@ -81,7 +81,7 @@ int main(int argc, char* argv[])
|
|||||||
if (QTest::qExec(&test1) != 0) {
|
if (QTest::qExec(&test1) != 0) {
|
||||||
fInvalid = true;
|
fInvalid = true;
|
||||||
}
|
}
|
||||||
RPCNestedTests test3(*node);
|
RPCNestedTests test3(app.node());
|
||||||
if (QTest::qExec(&test3) != 0) {
|
if (QTest::qExec(&test3) != 0) {
|
||||||
fInvalid = true;
|
fInvalid = true;
|
||||||
}
|
}
|
||||||
@@ -90,11 +90,11 @@ int main(int argc, char* argv[])
|
|||||||
fInvalid = true;
|
fInvalid = true;
|
||||||
}
|
}
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
WalletTests test5(*node);
|
WalletTests test5(app.node());
|
||||||
if (QTest::qExec(&test5) != 0) {
|
if (QTest::qExec(&test5) != 0) {
|
||||||
fInvalid = true;
|
fInvalid = true;
|
||||||
}
|
}
|
||||||
AddressBookTests test6(*node);
|
AddressBookTests test6(app.node());
|
||||||
if (QTest::qExec(&test6) != 0) {
|
if (QTest::qExec(&test6) != 0) {
|
||||||
fInvalid = true;
|
fInvalid = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ void TestGUI(interfaces::Node& node)
|
|||||||
std::unique_ptr<const PlatformStyle> platformStyle(PlatformStyle::instantiate("other"));
|
std::unique_ptr<const PlatformStyle> platformStyle(PlatformStyle::instantiate("other"));
|
||||||
SendCoinsDialog sendCoinsDialog(platformStyle.get());
|
SendCoinsDialog sendCoinsDialog(platformStyle.get());
|
||||||
TransactionView transactionView(platformStyle.get());
|
TransactionView transactionView(platformStyle.get());
|
||||||
OptionsModel optionsModel(node);
|
OptionsModel optionsModel;
|
||||||
ClientModel clientModel(node, &optionsModel);
|
ClientModel clientModel(node, &optionsModel);
|
||||||
AddWallet(wallet);
|
AddWallet(wallet);
|
||||||
WalletModel walletModel(interfaces::MakeWallet(wallet), clientModel, platformStyle.get());
|
WalletModel walletModel(interfaces::MakeWallet(wallet), clientModel, platformStyle.get());
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
/** "Help message" or "About" dialog box */
|
/** "Help message" or "About" dialog box */
|
||||||
HelpMessageDialog::HelpMessageDialog(interfaces::Node& node, QWidget *parent, bool about) :
|
HelpMessageDialog::HelpMessageDialog(QWidget *parent, bool about) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
ui(new Ui::HelpMessageDialog)
|
ui(new Ui::HelpMessageDialog)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,10 +12,6 @@ QT_BEGIN_NAMESPACE
|
|||||||
class QMainWindow;
|
class QMainWindow;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace interfaces {
|
|
||||||
class Node;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class HelpMessageDialog;
|
class HelpMessageDialog;
|
||||||
}
|
}
|
||||||
@@ -26,7 +22,7 @@ class HelpMessageDialog : public QDialog
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit HelpMessageDialog(interfaces::Node& node, QWidget *parent, bool about);
|
explicit HelpMessageDialog(QWidget *parent, bool about);
|
||||||
~HelpMessageDialog();
|
~HelpMessageDialog();
|
||||||
|
|
||||||
void printToConsole();
|
void printToConsole();
|
||||||
|
|||||||
Reference in new issue
Block a user