Changeset View
Changeset View
Standalone View
Standalone View
src/qt/bitcoin.cpp
Show First 20 Lines • Show All 252 Lines • ▼ Show 20 Lines | |||||
private: | private: | ||||
QThread *coreThread; | QThread *coreThread; | ||||
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; | ||||
WalletModel *walletModel; | std::vector<WalletModel *> m_wallet_models; | ||||
#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 51 Lines • ▼ Show 20 Lines | try { | ||||
handleRunawayException(nullptr); | handleRunawayException(nullptr); | ||||
} | } | ||||
} | } | ||||
BitcoinApplication::BitcoinApplication(int &argc, char **argv) | BitcoinApplication::BitcoinApplication(int &argc, char **argv) | ||||
: QApplication(argc, argv), coreThread(0), optionsModel(0), clientModel(0), | : QApplication(argc, argv), coreThread(0), optionsModel(0), clientModel(0), | ||||
window(0), pollShutdownTimer(0), | window(0), pollShutdownTimer(0), | ||||
#ifdef ENABLE_WALLET | #ifdef ENABLE_WALLET | ||||
paymentServer(0), walletModel(0), | paymentServer(0), m_wallet_models(), | ||||
#endif | #endif | ||||
returnValue(0) { | returnValue(0) { | ||||
setQuitOnLastWindowClosed(false); | setQuitOnLastWindowClosed(false); | ||||
// UI per-platform customization. | // UI per-platform customization. | ||||
// This must be done inside the BitcoinApplication constructor, or after it, | // This must be done inside the BitcoinApplication constructor, or after it, | ||||
// because PlatformStyle::instantiate requires a QApplication. | // because PlatformStyle::instantiate requires a QApplication. | ||||
std::string platformName; | std::string platformName; | ||||
▲ Show 20 Lines • Show All 123 Lines • ▼ Show 20 Lines | void BitcoinApplication::requestShutdown(Config &config) { | ||||
qDebug() << __func__ << ": Requesting shutdown"; | qDebug() << __func__ << ": Requesting shutdown"; | ||||
startThread(); | startThread(); | ||||
window->hide(); | window->hide(); | ||||
window->setClientModel(0); | window->setClientModel(0); | ||||
pollShutdownTimer->stop(); | pollShutdownTimer->stop(); | ||||
#ifdef ENABLE_WALLET | #ifdef ENABLE_WALLET | ||||
window->removeAllWallets(); | window->removeAllWallets(); | ||||
for (WalletModel *walletModel : m_wallet_models) { | |||||
delete walletModel; | delete walletModel; | ||||
walletModel = 0; | } | ||||
m_wallet_models.clear(); | |||||
#endif | #endif | ||||
delete clientModel; | delete clientModel; | ||||
clientModel = 0; | clientModel = 0; | ||||
StartShutdown(); | StartShutdown(); | ||||
// Request shutdown from core thread | // Request shutdown from core thread | ||||
Q_EMIT requestedShutdown(); | Q_EMIT requestedShutdown(); | ||||
Show All 16 Lines | #ifdef ENABLE_WALLET | ||||
PaymentServer::LoadRootCAs(); | PaymentServer::LoadRootCAs(); | ||||
paymentServer->setOptionsModel(optionsModel); | paymentServer->setOptionsModel(optionsModel); | ||||
#endif | #endif | ||||
clientModel = new ClientModel(optionsModel); | clientModel = new ClientModel(optionsModel); | ||||
window->setClientModel(clientModel); | window->setClientModel(clientModel); | ||||
#ifdef ENABLE_WALLET | #ifdef ENABLE_WALLET | ||||
// TODO: Expose secondary wallets | bool fFirstWallet = true; | ||||
if (!vpwallets.empty()) { | for (CWalletRef pwallet : vpwallets) { | ||||
walletModel = | WalletModel *const walletModel = | ||||
new WalletModel(platformStyle, vpwallets[0], optionsModel); | new WalletModel(platformStyle, pwallet, optionsModel); | ||||
window->addWallet(BitcoinGUI::DEFAULT_WALLET, walletModel); | window->addWallet(walletModel); | ||||
window->setCurrentWallet(BitcoinGUI::DEFAULT_WALLET); | if (fFirstWallet) { | ||||
window->setCurrentWallet(walletModel->getWalletName()); | |||||
fFirstWallet = false; | |||||
} | |||||
connect(walletModel, | connect(walletModel, | ||||
SIGNAL(coinsSent(CWallet *, SendCoinsRecipient, QByteArray)), | SIGNAL(coinsSent(CWallet *, SendCoinsRecipient, QByteArray)), | ||||
paymentServer, | paymentServer, | ||||
SLOT(fetchPaymentACK(CWallet *, const SendCoinsRecipient &, | SLOT(fetchPaymentACK(CWallet *, const SendCoinsRecipient &, | ||||
QByteArray))); | 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 303 Lines • Show Last 20 Lines |