Remove direct bitcoin calls from qt/utilitydialog.cpp

This commit is contained in:
Russell Yanofsky 2017-04-17 14:40:41 -04:00 committed by John Newbery
parent 3d619e9d36
commit c2f672fb19
6 changed files with 16 additions and 6 deletions

View File

@ -55,6 +55,7 @@ class NodeImpl : public Node
StopMapPort(); StopMapPort();
} }
} }
std::string helpMessage(HelpMessageMode mode) override { return HelpMessage(mode); }
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); }
std::unique_ptr<Handler> handleInitMessage(InitMessageFn fn) override std::unique_ptr<Handler> handleInitMessage(InitMessageFn fn) override
{ {

View File

@ -5,6 +5,7 @@
#ifndef BITCOIN_INTERFACE_NODE_H #ifndef BITCOIN_INTERFACE_NODE_H
#define BITCOIN_INTERFACE_NODE_H #define BITCOIN_INTERFACE_NODE_H
#include <init.h> // For HelpMessageMode
#include <netaddress.h> // For Network #include <netaddress.h> // For Network
#include <functional> #include <functional>
@ -62,6 +63,9 @@ public:
//! Return whether shutdown was requested. //! Return whether shutdown was requested.
virtual bool shutdownRequested() = 0; virtual bool shutdownRequested() = 0;
//! Get help message string.
virtual std::string helpMessage(HelpMessageMode mode) = 0;
//! Map port. //! Map port.
virtual void mapPort(bool use_upnp) = 0; virtual void mapPort(bool use_upnp) = 0;

View File

@ -595,7 +595,7 @@ int main(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(nullptr, gArgs.IsArgSet("-version")); HelpMessageDialog help(*node, nullptr, gArgs.IsArgSet("-version"));
help.showOrPrint(); help.showOrPrint();
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }

View File

@ -153,7 +153,7 @@ BitcoinGUI::BitcoinGUI(interface::Node& node, const PlatformStyle *_platformStyl
#endif #endif
rpcConsole = new RPCConsole(_platformStyle, 0); rpcConsole = new RPCConsole(_platformStyle, 0);
helpMessageDialog = new HelpMessageDialog(this, false); helpMessageDialog = new HelpMessageDialog(node, this, false);
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
if(enableWallet) if(enableWallet)
{ {
@ -668,7 +668,7 @@ void BitcoinGUI::aboutClicked()
if(!clientModel) if(!clientModel)
return; return;
HelpMessageDialog dlg(this, true); HelpMessageDialog dlg(m_node, this, true);
dlg.exec(); dlg.exec();
} }

View File

@ -19,6 +19,7 @@
#include <clientversion.h> #include <clientversion.h>
#include <init.h> #include <init.h>
#include <interface/node.h>
#include <util.h> #include <util.h>
#include <stdio.h> #include <stdio.h>
@ -31,7 +32,7 @@
#include <QVBoxLayout> #include <QVBoxLayout>
/** "Help message" or "About" dialog box */ /** "Help message" or "About" dialog box */
HelpMessageDialog::HelpMessageDialog(QWidget *parent, bool about) : HelpMessageDialog::HelpMessageDialog(interface::Node& node, QWidget *parent, bool about) :
QDialog(parent), QDialog(parent),
ui(new Ui::HelpMessageDialog) ui(new Ui::HelpMessageDialog)
{ {
@ -77,7 +78,7 @@ HelpMessageDialog::HelpMessageDialog(QWidget *parent, bool about) :
cursor.insertText(header); cursor.insertText(header);
cursor.insertBlock(); 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); const bool showDebug = gArgs.GetBoolArg("-help-debug", false);
strUsage += HelpMessageGroup(tr("UI Options:").toStdString()); strUsage += HelpMessageGroup(tr("UI Options:").toStdString());
if (showDebug) { if (showDebug) {

View File

@ -10,6 +10,10 @@
class BitcoinGUI; class BitcoinGUI;
namespace interface {
class Node;
}
namespace Ui { namespace Ui {
class HelpMessageDialog; class HelpMessageDialog;
} }
@ -20,7 +24,7 @@ class HelpMessageDialog : public QDialog
Q_OBJECT Q_OBJECT
public: public:
explicit HelpMessageDialog(QWidget *parent, bool about); explicit HelpMessageDialog(interface::Node& node, QWidget *parent, bool about);
~HelpMessageDialog(); ~HelpMessageDialog();
void printToConsole(); void printToConsole();