Merge #13097: ui: Support wallets loaded dynamically
2e7513471
fixup! ui: Support wallets loaded dynamically (João Barbosa)0e674ba55
ui: Support wallets loaded dynamically (João Barbosa)1c8fe0bf9
ui: Remove unnecessary variable fFirstWallet (João Barbosa) Pull request description: Add support in the UI for wallets loaded dynamically. Tree-SHA512: 4016d61580b31e28c49861b1cb0e77fac5417f9676a6ce6156be28cb6059fdf3d3dd4d57dbbc22a574ad428c2a4a3702aedca596a84e644ce148e1084feb29c9
This commit is contained in:
commit
e54550303b
3 changed files with 35 additions and 17 deletions
|
@ -5,4 +5,4 @@ Previously, wallets could only be loaded at startup, by specifying `-wallet` par
|
||||||
|
|
||||||
The wallet can be specified as file/directory basename (which must be located in the `walletdir` directory), or as an absolute path to a file/directory.
|
The wallet can be specified as file/directory basename (which must be located in the `walletdir` directory), or as an absolute path to a file/directory.
|
||||||
|
|
||||||
This feature is currently only available through the RPC interface. Wallets loaded in this way will not display in the bitcoin-qt GUI.
|
This feature is currently only available through the RPC interface. Wallets loaded in this way will display in the bitcoin-qt GUI.
|
||||||
|
|
|
@ -234,6 +234,7 @@ public Q_SLOTS:
|
||||||
void shutdownResult();
|
void shutdownResult();
|
||||||
/// Handle runaway exceptions. Shows a message box with the problem and quits the program.
|
/// Handle runaway exceptions. Shows a message box with the problem and quits the program.
|
||||||
void handleRunawayException(const QString &message);
|
void handleRunawayException(const QString &message);
|
||||||
|
void addWallet(WalletModel* walletModel);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void requestedInitialize();
|
void requestedInitialize();
|
||||||
|
@ -251,6 +252,7 @@ private:
|
||||||
#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;
|
||||||
|
@ -447,6 +449,22 @@ void BitcoinApplication::requestShutdown()
|
||||||
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;
|
||||||
|
@ -465,21 +483,13 @@ void BitcoinApplication::initializeResult(bool success)
|
||||||
window->setClientModel(clientModel);
|
window->setClientModel(clientModel);
|
||||||
|
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
bool fFirstWallet = true;
|
m_handler_load_wallet = m_node.handleLoadWallet([this](std::unique_ptr<interfaces::Wallet> wallet) {
|
||||||
auto wallets = m_node.getWallets();
|
QMetaObject::invokeMethod(this, "addWallet", Qt::QueuedConnection,
|
||||||
for (auto& wallet : wallets) {
|
Q_ARG(WalletModel*, new WalletModel(std::move(wallet), m_node, platformStyle, optionsModel)));
|
||||||
WalletModel * const walletModel = new WalletModel(std::move(wallet), m_node, platformStyle, optionsModel);
|
});
|
||||||
|
|
||||||
window->addWallet(walletModel);
|
for (auto& wallet : m_node.getWallets()) {
|
||||||
if (fFirstWallet) {
|
addWallet(new WalletModel(std::move(wallet), m_node, platformStyle, optionsModel));
|
||||||
window->setCurrentWallet(walletModel->getWalletName());
|
|
||||||
fFirstWallet = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
connect(walletModel, SIGNAL(coinsSent(WalletModel*,SendCoinsRecipient,QByteArray)),
|
|
||||||
paymentServer, SLOT(fetchPaymentACK(WalletModel*,const SendCoinsRecipient&,QByteArray)));
|
|
||||||
|
|
||||||
m_wallet_models.push_back(walletModel);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -595,6 +605,9 @@ int main(int argc, char *argv[])
|
||||||
// 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< CAmount >("CAmount");
|
qRegisterMetaType< CAmount >("CAmount");
|
||||||
qRegisterMetaType< std::function<void(void)> >("std::function<void(void)>");
|
qRegisterMetaType< std::function<void(void)> >("std::function<void(void)>");
|
||||||
|
#ifdef ENABLE_WALLET
|
||||||
|
qRegisterMetaType<WalletModel*>("WalletModel*");
|
||||||
|
#endif
|
||||||
|
|
||||||
/// 3. Application identification
|
/// 3. Application identification
|
||||||
// must be set before OptionsModel is initialized or translations are loaded,
|
// must be set before OptionsModel is initialized or translations are loaded,
|
||||||
|
|
|
@ -57,8 +57,13 @@ bool WalletFrame::addWallet(WalletModel *walletModel)
|
||||||
walletView->setWalletModel(walletModel);
|
walletView->setWalletModel(walletModel);
|
||||||
walletView->showOutOfSyncWarning(bOutOfSync);
|
walletView->showOutOfSyncWarning(bOutOfSync);
|
||||||
|
|
||||||
/* TODO we should goto the currently selected page once dynamically adding wallets is supported */
|
WalletView* current_wallet_view = currentWalletView();
|
||||||
walletView->gotoOverviewPage();
|
if (current_wallet_view) {
|
||||||
|
walletView->setCurrentIndex(current_wallet_view->currentIndex());
|
||||||
|
} else {
|
||||||
|
walletView->gotoOverviewPage();
|
||||||
|
}
|
||||||
|
|
||||||
walletStack->addWidget(walletView);
|
walletStack->addWidget(walletView);
|
||||||
mapWalletViews[name] = walletView;
|
mapWalletViews[name] = walletView;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue