mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-11 20:32:35 -03:00
Qt: Load all wallets into WalletModels
This commit is contained in:
parent
ed6ae8059c
commit
3dba3c3ac1
3 changed files with 21 additions and 15 deletions
|
@ -251,7 +251,7 @@ private:
|
|||
QTimer *pollShutdownTimer;
|
||||
#ifdef ENABLE_WALLET
|
||||
PaymentServer* paymentServer;
|
||||
WalletModel *walletModel;
|
||||
std::vector<WalletModel*> m_wallet_models;
|
||||
#endif
|
||||
int returnValue;
|
||||
const PlatformStyle *platformStyle;
|
||||
|
@ -333,7 +333,7 @@ BitcoinApplication::BitcoinApplication(int &argc, char **argv):
|
|||
pollShutdownTimer(0),
|
||||
#ifdef ENABLE_WALLET
|
||||
paymentServer(0),
|
||||
walletModel(0),
|
||||
m_wallet_models(),
|
||||
#endif
|
||||
returnValue(0)
|
||||
{
|
||||
|
@ -451,8 +451,10 @@ void BitcoinApplication::requestShutdown()
|
|||
|
||||
#ifdef ENABLE_WALLET
|
||||
window->removeAllWallets();
|
||||
for (WalletModel *walletModel : m_wallet_models) {
|
||||
delete walletModel;
|
||||
walletModel = 0;
|
||||
}
|
||||
m_wallet_models.clear();
|
||||
#endif
|
||||
delete clientModel;
|
||||
clientModel = 0;
|
||||
|
@ -481,16 +483,25 @@ void BitcoinApplication::initializeResult(bool success)
|
|||
window->setClientModel(clientModel);
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
// TODO: Expose secondary wallets
|
||||
if (!vpwallets.empty())
|
||||
{
|
||||
walletModel = new WalletModel(platformStyle, vpwallets[0], optionsModel);
|
||||
bool fFirstWallet = true;
|
||||
for (CWalletRef pwallet : vpwallets) {
|
||||
WalletModel * const walletModel = new WalletModel(platformStyle, pwallet, optionsModel);
|
||||
|
||||
window->addWallet(BitcoinGUI::DEFAULT_WALLET, walletModel);
|
||||
window->setCurrentWallet(BitcoinGUI::DEFAULT_WALLET);
|
||||
QString WalletName = QString::fromStdString(pwallet->GetName());
|
||||
if (WalletName.endsWith(".dat")) {
|
||||
WalletName.truncate(WalletName.size() - 4);
|
||||
}
|
||||
|
||||
window->addWallet(WalletName, walletModel);
|
||||
if (fFirstWallet) {
|
||||
window->setCurrentWallet(WalletName);
|
||||
fFirstWallet = false;
|
||||
}
|
||||
|
||||
connect(walletModel, SIGNAL(coinsSent(CWallet*,SendCoinsRecipient,QByteArray)),
|
||||
paymentServer, SLOT(fetchPaymentACK(CWallet*,const SendCoinsRecipient&,QByteArray)));
|
||||
|
||||
m_wallet_models.push_back(walletModel);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -70,10 +70,6 @@ const std::string BitcoinGUI::DEFAULT_UIPLATFORM =
|
|||
#endif
|
||||
;
|
||||
|
||||
/** Display name for default wallet name. Uses tilde to avoid name
|
||||
* collisions in the future with additional wallets */
|
||||
const QString BitcoinGUI::DEFAULT_WALLET = "~Default";
|
||||
|
||||
BitcoinGUI::BitcoinGUI(const PlatformStyle *_platformStyle, const NetworkStyle *networkStyle, QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
enableWallet(false),
|
||||
|
|
|
@ -46,7 +46,6 @@ class BitcoinGUI : public QMainWindow
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static const QString DEFAULT_WALLET;
|
||||
static const std::string DEFAULT_UIPLATFORM;
|
||||
|
||||
explicit BitcoinGUI(const PlatformStyle *platformStyle, const NetworkStyle *networkStyle, QWidget *parent = 0);
|
||||
|
|
Loading…
Reference in a new issue