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 xdustinface
parent 50f1a6205e
commit 2fdf3d8c64
6 changed files with 17 additions and 7 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

@ -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();
}

View File

@ -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;
}

View File

@ -20,6 +20,7 @@
#include <clientversion.h>
#include <init.h>
#include <interface/node.h>
#include <util.h>
#include <stdio.h>
@ -32,7 +33,7 @@
#include <QVBoxLayout>
/** "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) {

View File

@ -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();