mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-26 03:03:22 -03:00
Move BitcoinApplication to header so it can be tested
Move-only commit, no code changes
This commit is contained in:
parent
f7e182a973
commit
ca20b65cc0
3 changed files with 125 additions and 96 deletions
|
@ -120,6 +120,7 @@ QT_MOC_CPP = \
|
||||||
qt/moc_bantablemodel.cpp \
|
qt/moc_bantablemodel.cpp \
|
||||||
qt/moc_bitcoinaddressvalidator.cpp \
|
qt/moc_bitcoinaddressvalidator.cpp \
|
||||||
qt/moc_bitcoinamountfield.cpp \
|
qt/moc_bitcoinamountfield.cpp \
|
||||||
|
qt/moc_bitcoin.cpp \
|
||||||
qt/moc_bitcoingui.cpp \
|
qt/moc_bitcoingui.cpp \
|
||||||
qt/moc_bitcoinunits.cpp \
|
qt/moc_bitcoinunits.cpp \
|
||||||
qt/moc_clientmodel.cpp \
|
qt/moc_clientmodel.cpp \
|
||||||
|
@ -166,7 +167,6 @@ BITCOIN_MM = \
|
||||||
qt/macos_appnap.mm
|
qt/macos_appnap.mm
|
||||||
|
|
||||||
QT_MOC = \
|
QT_MOC = \
|
||||||
qt/bitcoin.moc \
|
|
||||||
qt/bitcoinamountfield.moc \
|
qt/bitcoinamountfield.moc \
|
||||||
qt/intro.moc \
|
qt/intro.moc \
|
||||||
qt/overviewpage.moc \
|
qt/overviewpage.moc \
|
||||||
|
@ -194,6 +194,7 @@ BITCOIN_QT_H = \
|
||||||
qt/bantablemodel.h \
|
qt/bantablemodel.h \
|
||||||
qt/bitcoinaddressvalidator.h \
|
qt/bitcoinaddressvalidator.h \
|
||||||
qt/bitcoinamountfield.h \
|
qt/bitcoinamountfield.h \
|
||||||
|
qt/bitcoin.h \
|
||||||
qt/bitcoingui.h \
|
qt/bitcoingui.h \
|
||||||
qt/bitcoinunits.h \
|
qt/bitcoinunits.h \
|
||||||
qt/clientmodel.h \
|
qt/clientmodel.h \
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include <config/bitcoin-config.h>
|
#include <config/bitcoin-config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <qt/bitcoin.h>
|
||||||
#include <qt/bitcoingui.h>
|
#include <qt/bitcoingui.h>
|
||||||
|
|
||||||
#include <chainparams.h>
|
#include <chainparams.h>
|
||||||
|
@ -140,101 +141,6 @@ void DebugMessageHandler(QtMsgType type, const QMessageLogContext& context, cons
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Class encapsulating Bitcoin Core startup and shutdown.
|
|
||||||
* Allows running startup and shutdown in a different thread from the UI thread.
|
|
||||||
*/
|
|
||||||
class BitcoinCore: public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
explicit BitcoinCore(interfaces::Node& node);
|
|
||||||
|
|
||||||
public Q_SLOTS:
|
|
||||||
void initialize();
|
|
||||||
void shutdown();
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
|
||||||
void initializeResult(bool success);
|
|
||||||
void shutdownResult();
|
|
||||||
void runawayException(const QString &message);
|
|
||||||
|
|
||||||
private:
|
|
||||||
/// Pass fatal exception message to UI thread
|
|
||||||
void handleRunawayException(const std::exception *e);
|
|
||||||
|
|
||||||
interfaces::Node& m_node;
|
|
||||||
};
|
|
||||||
|
|
||||||
/** Main Bitcoin application object */
|
|
||||||
class BitcoinApplication: public QApplication
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
explicit BitcoinApplication(interfaces::Node& node, int &argc, char **argv);
|
|
||||||
~BitcoinApplication();
|
|
||||||
|
|
||||||
#ifdef ENABLE_WALLET
|
|
||||||
/// Create payment server
|
|
||||||
void createPaymentServer();
|
|
||||||
#endif
|
|
||||||
/// parameter interaction/setup based on rules
|
|
||||||
void parameterSetup();
|
|
||||||
/// Create options model
|
|
||||||
void createOptionsModel(bool resetSettings);
|
|
||||||
/// Create main window
|
|
||||||
void createWindow(const NetworkStyle *networkStyle);
|
|
||||||
/// Create splash screen
|
|
||||||
void createSplashScreen(const NetworkStyle *networkStyle);
|
|
||||||
|
|
||||||
/// Request core initialization
|
|
||||||
void requestInitialize();
|
|
||||||
/// Request core shutdown
|
|
||||||
void requestShutdown();
|
|
||||||
|
|
||||||
/// Get process return value
|
|
||||||
int getReturnValue() const { return returnValue; }
|
|
||||||
|
|
||||||
/// Get window identifier of QMainWindow (BitcoinGUI)
|
|
||||||
WId getMainWinId() const;
|
|
||||||
|
|
||||||
/// Setup platform style
|
|
||||||
void setupPlatformStyle();
|
|
||||||
|
|
||||||
public Q_SLOTS:
|
|
||||||
void initializeResult(bool success);
|
|
||||||
void shutdownResult();
|
|
||||||
/// Handle runaway exceptions. Shows a message box with the problem and quits the program.
|
|
||||||
void handleRunawayException(const QString &message);
|
|
||||||
void addWallet(WalletModel* walletModel);
|
|
||||||
void removeWallet();
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
|
||||||
void requestedInitialize();
|
|
||||||
void requestedShutdown();
|
|
||||||
void stopThread();
|
|
||||||
void splashFinished();
|
|
||||||
|
|
||||||
private:
|
|
||||||
QThread *coreThread;
|
|
||||||
interfaces::Node& m_node;
|
|
||||||
OptionsModel *optionsModel;
|
|
||||||
ClientModel *clientModel;
|
|
||||||
BitcoinGUI *window;
|
|
||||||
QTimer *pollShutdownTimer;
|
|
||||||
#ifdef ENABLE_WALLET
|
|
||||||
PaymentServer* paymentServer;
|
|
||||||
std::vector<WalletModel*> m_wallet_models;
|
|
||||||
std::unique_ptr<interfaces::Handler> m_handler_load_wallet;
|
|
||||||
#endif
|
|
||||||
int returnValue;
|
|
||||||
const PlatformStyle *platformStyle;
|
|
||||||
std::unique_ptr<QWidget> shutdownWindow;
|
|
||||||
|
|
||||||
void startThread();
|
|
||||||
};
|
|
||||||
|
|
||||||
#include <qt/bitcoin.moc>
|
|
||||||
|
|
||||||
BitcoinCore::BitcoinCore(interfaces::Node& node) :
|
BitcoinCore::BitcoinCore(interfaces::Node& node) :
|
||||||
QObject(), m_node(node)
|
QObject(), m_node(node)
|
||||||
{
|
{
|
||||||
|
|
122
src/qt/bitcoin.h
Normal file
122
src/qt/bitcoin.h
Normal file
|
@ -0,0 +1,122 @@
|
||||||
|
// Copyright (c) 2011-2016 The Bitcoin Core developers
|
||||||
|
// Distributed under the MIT software license, see the accompanying
|
||||||
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
#ifndef BITCOIN_QT_BITCOIN_H
|
||||||
|
#define BITCOIN_QT_BITCOIN_H
|
||||||
|
|
||||||
|
#if defined(HAVE_CONFIG_H)
|
||||||
|
#include <config/bitcoin-config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
|
#include <memory>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
class BitcoinGUI;
|
||||||
|
class ClientModel;
|
||||||
|
class NetworkStyle;
|
||||||
|
class OptionsModel;
|
||||||
|
class PaymentServer;
|
||||||
|
class PlatformStyle;
|
||||||
|
class WalletModel;
|
||||||
|
|
||||||
|
namespace interfaces {
|
||||||
|
class Handler;
|
||||||
|
class Node;
|
||||||
|
} // namespace interfaces
|
||||||
|
|
||||||
|
/** Class encapsulating Bitcoin Core startup and shutdown.
|
||||||
|
* Allows running startup and shutdown in a different thread from the UI thread.
|
||||||
|
*/
|
||||||
|
class BitcoinCore: public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit BitcoinCore(interfaces::Node& node);
|
||||||
|
|
||||||
|
public Q_SLOTS:
|
||||||
|
void initialize();
|
||||||
|
void shutdown();
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void initializeResult(bool success);
|
||||||
|
void shutdownResult();
|
||||||
|
void runawayException(const QString &message);
|
||||||
|
|
||||||
|
private:
|
||||||
|
/// Pass fatal exception message to UI thread
|
||||||
|
void handleRunawayException(const std::exception *e);
|
||||||
|
|
||||||
|
interfaces::Node& m_node;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Main Bitcoin application object */
|
||||||
|
class BitcoinApplication: public QApplication
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit BitcoinApplication(interfaces::Node& node, int &argc, char **argv);
|
||||||
|
~BitcoinApplication();
|
||||||
|
|
||||||
|
#ifdef ENABLE_WALLET
|
||||||
|
/// Create payment server
|
||||||
|
void createPaymentServer();
|
||||||
|
#endif
|
||||||
|
/// parameter interaction/setup based on rules
|
||||||
|
void parameterSetup();
|
||||||
|
/// Create options model
|
||||||
|
void createOptionsModel(bool resetSettings);
|
||||||
|
/// Create main window
|
||||||
|
void createWindow(const NetworkStyle *networkStyle);
|
||||||
|
/// Create splash screen
|
||||||
|
void createSplashScreen(const NetworkStyle *networkStyle);
|
||||||
|
|
||||||
|
/// Request core initialization
|
||||||
|
void requestInitialize();
|
||||||
|
/// Request core shutdown
|
||||||
|
void requestShutdown();
|
||||||
|
|
||||||
|
/// Get process return value
|
||||||
|
int getReturnValue() const { return returnValue; }
|
||||||
|
|
||||||
|
/// Get window identifier of QMainWindow (BitcoinGUI)
|
||||||
|
WId getMainWinId() const;
|
||||||
|
|
||||||
|
/// Setup platform style
|
||||||
|
void setupPlatformStyle();
|
||||||
|
|
||||||
|
public Q_SLOTS:
|
||||||
|
void initializeResult(bool success);
|
||||||
|
void shutdownResult();
|
||||||
|
/// Handle runaway exceptions. Shows a message box with the problem and quits the program.
|
||||||
|
void handleRunawayException(const QString &message);
|
||||||
|
void addWallet(WalletModel* walletModel);
|
||||||
|
void removeWallet();
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void requestedInitialize();
|
||||||
|
void requestedShutdown();
|
||||||
|
void stopThread();
|
||||||
|
void splashFinished();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QThread *coreThread;
|
||||||
|
interfaces::Node& m_node;
|
||||||
|
OptionsModel *optionsModel;
|
||||||
|
ClientModel *clientModel;
|
||||||
|
BitcoinGUI *window;
|
||||||
|
QTimer *pollShutdownTimer;
|
||||||
|
#ifdef ENABLE_WALLET
|
||||||
|
PaymentServer* paymentServer;
|
||||||
|
std::vector<WalletModel*> m_wallet_models;
|
||||||
|
std::unique_ptr<interfaces::Handler> m_handler_load_wallet;
|
||||||
|
#endif
|
||||||
|
int returnValue;
|
||||||
|
const PlatformStyle *platformStyle;
|
||||||
|
std::unique_ptr<QWidget> shutdownWindow;
|
||||||
|
|
||||||
|
void startThread();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BITCOIN_QT_BITCOIN_H
|
Loading…
Add table
Reference in a new issue