Changeset View
Changeset View
Standalone View
Standalone View
src/qt/bitcoin.cpp
Show First 20 Lines • Show All 223 Lines • ▼ Show 20 Lines | #endif | ||||
void setupPlatformStyle(); | void setupPlatformStyle(); | ||||
public Q_SLOTS: | public Q_SLOTS: | ||||
void initializeResult(bool success); | void initializeResult(bool success); | ||||
void shutdownResult(); | void shutdownResult(); | ||||
/// Handle runaway exceptions. Shows a message box with the problem and | /// Handle runaway exceptions. Shows a message box with the problem and | ||||
/// quits the program. | /// quits the program. | ||||
void handleRunawayException(const QString &message); | void handleRunawayException(const QString &message); | ||||
void addWallet(WalletModel *walletModel); | |||||
Q_SIGNALS: | Q_SIGNALS: | ||||
void requestedInitialize(Config *config, RPCServer *rpcServer, | void requestedInitialize(Config *config, RPCServer *rpcServer, | ||||
HTTPRPCRequestProcessor *httpRPCRequestProcessor); | HTTPRPCRequestProcessor *httpRPCRequestProcessor); | ||||
void requestedShutdown(); | void requestedShutdown(); | ||||
void stopThread(); | void stopThread(); | ||||
void splashFinished(QWidget *window); | void splashFinished(QWidget *window); | ||||
private: | private: | ||||
QThread *coreThread; | QThread *coreThread; | ||||
interfaces::Node &m_node; | interfaces::Node &m_node; | ||||
OptionsModel *optionsModel; | OptionsModel *optionsModel; | ||||
ClientModel *clientModel; | ClientModel *clientModel; | ||||
BitcoinGUI *window; | BitcoinGUI *window; | ||||
QTimer *pollShutdownTimer; | QTimer *pollShutdownTimer; | ||||
#ifdef ENABLE_WALLET | #ifdef ENABLE_WALLET | ||||
PaymentServer *paymentServer; | PaymentServer *paymentServer; | ||||
std::vector<WalletModel *> m_wallet_models; | std::vector<WalletModel *> m_wallet_models; | ||||
std::unique_ptr<interfaces::Handler> m_handler_load_wallet; | |||||
#endif | #endif | ||||
int returnValue; | int returnValue; | ||||
const PlatformStyle *platformStyle; | const PlatformStyle *platformStyle; | ||||
std::unique_ptr<QWidget> shutdownWindow; | std::unique_ptr<QWidget> shutdownWindow; | ||||
void startThread(); | void startThread(); | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 190 Lines • ▼ Show 20 Lines | #endif | ||||
clientModel = 0; | clientModel = 0; | ||||
m_node.startShutdown(); | m_node.startShutdown(); | ||||
// Request shutdown from core thread | // Request shutdown from core thread | ||||
Q_EMIT requestedShutdown(); | Q_EMIT requestedShutdown(); | ||||
} | } | ||||
void BitcoinApplication::addWallet(WalletModel *walletModel) { | |||||
#ifdef ENABLE_WALLET | |||||
window->addWallet(walletModel); | |||||
if (m_wallet_models.empty()) { | |||||
window->setCurrentWallet(walletModel->getWalletName()); | |||||
} | |||||
connect(walletModel, | |||||
SIGNAL(coinsSent(WalletModel *, SendCoinsRecipient, QByteArray)), | |||||
paymentServer, | |||||
SLOT(fetchPaymentACK(WalletModel *, const SendCoinsRecipient &, | |||||
QByteArray))); | |||||
m_wallet_models.push_back(walletModel); | |||||
#endif | |||||
} | |||||
void BitcoinApplication::initializeResult(bool success) { | void BitcoinApplication::initializeResult(bool success) { | ||||
qDebug() << __func__ << ": Initialization result: " << success; | qDebug() << __func__ << ": Initialization result: " << success; | ||||
returnValue = success ? EXIT_SUCCESS : EXIT_FAILURE; | returnValue = success ? EXIT_SUCCESS : EXIT_FAILURE; | ||||
if (!success) { | if (!success) { | ||||
// Make sure splash screen doesn't stick around during shutdown. | // Make sure splash screen doesn't stick around during shutdown. | ||||
Q_EMIT splashFinished(window); | Q_EMIT splashFinished(window); | ||||
// Exit first main loop invocation. | // Exit first main loop invocation. | ||||
quit(); | quit(); | ||||
return; | return; | ||||
} | } | ||||
// Log this only after AppInitMain finishes, as then logging setup is | // Log this only after AppInitMain finishes, as then logging setup is | ||||
// guaranteed complete. | // guaranteed complete. | ||||
qWarning() << "Platform customization:" << platformStyle->getName(); | qWarning() << "Platform customization:" << platformStyle->getName(); | ||||
#ifdef ENABLE_WALLET | #ifdef ENABLE_WALLET | ||||
PaymentServer::LoadRootCAs(); | PaymentServer::LoadRootCAs(); | ||||
paymentServer->setOptionsModel(optionsModel); | paymentServer->setOptionsModel(optionsModel); | ||||
#endif | #endif | ||||
clientModel = new ClientModel(m_node, optionsModel); | clientModel = new ClientModel(m_node, optionsModel); | ||||
window->setClientModel(clientModel); | window->setClientModel(clientModel); | ||||
#ifdef ENABLE_WALLET | #ifdef ENABLE_WALLET | ||||
bool fFirstWallet = true; | m_handler_load_wallet = m_node.handleLoadWallet( | ||||
auto wallets = m_node.getWallets(); | [this](std::unique_ptr<interfaces::Wallet> wallet) { | ||||
for (auto &wallet : wallets) { | QMetaObject::invokeMethod( | ||||
WalletModel *const walletModel = new WalletModel( | this, "addWallet", Qt::QueuedConnection, | ||||
std::move(wallet), m_node, platformStyle, optionsModel); | Q_ARG(WalletModel *, | ||||
new WalletModel(std::move(wallet), m_node, platformStyle, | |||||
window->addWallet(walletModel); | optionsModel))); | ||||
if (fFirstWallet) { | }); | ||||
window->setCurrentWallet(walletModel->getWalletName()); | |||||
fFirstWallet = false; | for (auto &wallet : m_node.getWallets()) { | ||||
} | addWallet(new WalletModel(std::move(wallet), m_node, platformStyle, | ||||
optionsModel)); | |||||
connect( | |||||
walletModel, | |||||
SIGNAL(coinsSent(WalletModel *, SendCoinsRecipient, QByteArray)), | |||||
paymentServer, | |||||
SLOT(fetchPaymentACK(WalletModel *, const SendCoinsRecipient &, | |||||
QByteArray))); | |||||
m_wallet_models.push_back(walletModel); | |||||
} | } | ||||
#endif | #endif | ||||
// If -min option passed, start window minimized. | // If -min option passed, start window minimized. | ||||
if (gArgs.GetBoolArg("-min", false)) { | if (gArgs.GetBoolArg("-min", false)) { | ||||
window->showMinimized(); | window->showMinimized(); | ||||
} else { | } else { | ||||
window->show(); | window->show(); | ||||
▲ Show 20 Lines • Show All 151 Lines • ▼ Show 20 Lines | #endif | ||||
// Register meta types used for QMetaObject::invokeMethod | // Register meta types used for QMetaObject::invokeMethod | ||||
qRegisterMetaType<bool *>(); | qRegisterMetaType<bool *>(); | ||||
// Need to pass name here as Amount is a typedef (see | // Need to pass name here as Amount is a typedef (see | ||||
// http://qt-project.org/doc/qt-5/qmetatype.html#qRegisterMetaType) | // http://qt-project.org/doc/qt-5/qmetatype.html#qRegisterMetaType) | ||||
// IMPORTANT if it is no longer a typedef use the normal variant above | // IMPORTANT if it is no longer a typedef use the normal variant above | ||||
qRegisterMetaType<Amount>("Amount"); | qRegisterMetaType<Amount>("Amount"); | ||||
qRegisterMetaType<std::function<void()>>("std::function<void()>"); | qRegisterMetaType<std::function<void()>>("std::function<void()>"); | ||||
#ifdef ENABLE_WALLET | |||||
qRegisterMetaType<WalletModel *>("WalletModel*"); | |||||
#endif | |||||
// Need to register any types Qt doesn't know about if you intend | // Need to register any types Qt doesn't know about if you intend | ||||
// to use them with the signal/slot mechanism Qt provides. Even pointers. | // to use them with the signal/slot mechanism Qt provides. Even pointers. | ||||
// Note that class Config is noncopyable and so we can't register a | // Note that class Config is noncopyable and so we can't register a | ||||
// non-pointer version of it with Qt, because Qt expects to be able to | // non-pointer version of it with Qt, because Qt expects to be able to | ||||
// copy-construct non-pointers to objects for invoking slots | // copy-construct non-pointers to objects for invoking slots | ||||
// behind-the-scenes in the 'Queued' connection case. | // behind-the-scenes in the 'Queued' connection case. | ||||
qRegisterMetaType<Config *>(); | qRegisterMetaType<Config *>(); | ||||
▲ Show 20 Lines • Show All 189 Lines • Show Last 20 Lines |