From 2fdf3d8c6485f5de331c2ab1f1563e27f5295cc0 Mon Sep 17 00:00:00 2001 From: Russell Yanofsky Date: Mon, 17 Apr 2017 14:40:41 -0400 Subject: [PATCH] Remove direct bitcoin calls from qt/utilitydialog.cpp --- src/interface/node.cpp | 1 + src/interface/node.h | 4 ++++ src/qt/bitcoingui.cpp | 6 +++--- src/qt/dash.cpp | 2 +- src/qt/utilitydialog.cpp | 5 +++-- src/qt/utilitydialog.h | 6 +++++- 6 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/interface/node.cpp b/src/interface/node.cpp index 7bfe79ed50..43bdfbaebc 100644 --- a/src/interface/node.cpp +++ b/src/interface/node.cpp @@ -55,6 +55,7 @@ class NodeImpl : public Node StopMapPort(); } } + std::string helpMessage(HelpMessageMode mode) override { return HelpMessage(mode); } bool getProxy(Network net, proxyType& proxy_info) override { return GetProxy(net, proxy_info); } std::unique_ptr handleInitMessage(InitMessageFn fn) override { diff --git a/src/interface/node.h b/src/interface/node.h index 00304cce24..60ef9cce1b 100644 --- a/src/interface/node.h +++ b/src/interface/node.h @@ -5,6 +5,7 @@ #ifndef BITCOIN_INTERFACE_NODE_H #define BITCOIN_INTERFACE_NODE_H +#include // For HelpMessageMode #include // For Network #include @@ -62,6 +63,9 @@ public: //! Return whether shutdown was requested. virtual bool shutdownRequested() = 0; + //! Get help message string. + virtual std::string helpMessage(HelpMessageMode mode) = 0; + //! Map port. virtual void mapPort(bool use_upnp) = 0; diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 2dcbdac6d2..f84bf73c09 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -150,7 +150,7 @@ BitcoinGUI::BitcoinGUI(interface::Node& node, const NetworkStyle* networkStyle, setWindowTitle(windowTitle); rpcConsole = new RPCConsole(this); - helpMessageDialog = new HelpMessageDialog(this, HelpMessageDialog::cmdline); + helpMessageDialog = new HelpMessageDialog(node, this, HelpMessageDialog::cmdline); #ifdef ENABLE_WALLET if(enableWallet) { @@ -942,7 +942,7 @@ void BitcoinGUI::aboutClicked() if(!clientModel) return; - HelpMessageDialog dlg(this, HelpMessageDialog::about); + HelpMessageDialog dlg(m_node, this, HelpMessageDialog::about); dlg.exec(); } @@ -1001,7 +1001,7 @@ void BitcoinGUI::showPrivateSendHelpClicked() if(!clientModel) return; - HelpMessageDialog dlg(this, HelpMessageDialog::pshelp); + HelpMessageDialog dlg(m_node, this, HelpMessageDialog::pshelp); dlg.exec(); } diff --git a/src/qt/dash.cpp b/src/qt/dash.cpp index 91b4d2cdfa..77c96a7184 100644 --- a/src/qt/dash.cpp +++ b/src/qt/dash.cpp @@ -589,7 +589,7 @@ int main(int argc, char *argv[]) // but before showing splash screen. if (gArgs.IsArgSet("-?") || gArgs.IsArgSet("-h") || gArgs.IsArgSet("-help") || gArgs.IsArgSet("-version")) { - HelpMessageDialog help(nullptr, gArgs.IsArgSet("-version") ? HelpMessageDialog::about : HelpMessageDialog::cmdline); + HelpMessageDialog help(*node, nullptr, gArgs.IsArgSet("-version") ? HelpMessageDialog::about : HelpMessageDialog::cmdline); help.showOrPrint(); return EXIT_SUCCESS; } diff --git a/src/qt/utilitydialog.cpp b/src/qt/utilitydialog.cpp index 3dbed88312..f4be80b689 100644 --- a/src/qt/utilitydialog.cpp +++ b/src/qt/utilitydialog.cpp @@ -20,6 +20,7 @@ #include #include +#include #include #include @@ -32,7 +33,7 @@ #include /** "Help message" or "About" dialog box */ -HelpMessageDialog::HelpMessageDialog(QWidget *parent, HelpMode helpMode) : +HelpMessageDialog::HelpMessageDialog(interface::Node& node, QWidget *parent, HelpMode helpMode) : QDialog(parent), ui(new Ui::HelpMessageDialog) { @@ -81,7 +82,7 @@ HelpMessageDialog::HelpMessageDialog(QWidget *parent, HelpMode helpMode) : cursor.insertText(header); cursor.insertBlock(); - std::string strUsage = HelpMessage(HelpMessageMode::BITCOIN_QT); + std::string strUsage = node.helpMessage(HelpMessageMode::BITCOIN_QT); const bool showDebug = gArgs.GetBoolArg("-help-debug", false); strUsage += HelpMessageGroup(tr("UI Options:").toStdString()); if (showDebug) { diff --git a/src/qt/utilitydialog.h b/src/qt/utilitydialog.h index 86dce7bd15..18ab346a9b 100644 --- a/src/qt/utilitydialog.h +++ b/src/qt/utilitydialog.h @@ -10,6 +10,10 @@ class BitcoinGUI; +namespace interface { + class Node; +} + namespace Ui { class HelpMessageDialog; } @@ -26,7 +30,7 @@ public: pshelp }; - explicit HelpMessageDialog(QWidget *parent, HelpMode helpMode); + explicit HelpMessageDialog(interface::Node& node, QWidget *parent, HelpMode helpMode); ~HelpMessageDialog(); void printToConsole();