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();
}
}
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<Handler> handleInitMessage(InitMessageFn fn) override
{

View file

@ -5,6 +5,7 @@
#ifndef BITCOIN_INTERFACE_NODE_H
#define BITCOIN_INTERFACE_NODE_H
#include <init.h> // For HelpMessageMode
#include <netaddress.h> // For Network
#include <functional>
@ -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;

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,
// but before showing splash screen.
if (HelpRequested(gArgs) || gArgs.IsArgSet("-version")) {
HelpMessageDialog help(nullptr, gArgs.IsArgSet("-version"));
HelpMessageDialog help(*node, nullptr, gArgs.IsArgSet("-version"));
help.showOrPrint();
return EXIT_SUCCESS;
}

View file

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

View file

@ -19,6 +19,7 @@
#include <clientversion.h>
#include <init.h>
#include <interface/node.h>
#include <util.h>
#include <stdio.h>
@ -31,7 +32,7 @@
#include <QVBoxLayout>
/** "Help message" or "About" dialog box */
HelpMessageDialog::HelpMessageDialog(QWidget *parent, bool about) :
HelpMessageDialog::HelpMessageDialog(interface::Node& node, QWidget *parent, bool about) :
QDialog(parent),
ui(new Ui::HelpMessageDialog)
{
@ -77,7 +78,7 @@ HelpMessageDialog::HelpMessageDialog(QWidget *parent, bool about) :
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) {

View file

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