Qt: Ensure UI updates only come from the currently selected walletView
This commit is contained in:
parent
e449f9a9e6
commit
85d5319716
7 changed files with 32 additions and 10 deletions
|
@ -21,6 +21,7 @@
|
|||
#ifdef ENABLE_WALLET
|
||||
#include <qt/walletframe.h>
|
||||
#include <qt/walletmodel.h>
|
||||
#include <qt/walletview.h>
|
||||
#endif // ENABLE_WALLET
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
|
@ -1097,6 +1098,20 @@ void BitcoinGUI::setEncryptionStatus(int status)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void BitcoinGUI::updateWalletStatus()
|
||||
{
|
||||
if (!walletFrame) {
|
||||
return;
|
||||
}
|
||||
WalletView * const walletView = walletFrame->currentWalletView();
|
||||
if (!walletView) {
|
||||
return;
|
||||
}
|
||||
WalletModel * const walletModel = walletView->getWalletModel();
|
||||
setEncryptionStatus(walletModel->getEncryptionStatus());
|
||||
setHDStatus(walletModel->hdEnabled());
|
||||
}
|
||||
#endif // ENABLE_WALLET
|
||||
|
||||
void BitcoinGUI::showNormalIfMinimized(bool fToggleHidden)
|
||||
|
|
|
@ -174,6 +174,9 @@ public Q_SLOTS:
|
|||
|
||||
#ifdef ENABLE_WALLET
|
||||
bool setCurrentWallet(const QString& name);
|
||||
/** Set the UI status indicators based on the currently selected wallet.
|
||||
*/
|
||||
void updateWalletStatus();
|
||||
|
||||
private:
|
||||
/** Set the encryption status as shown in the UI.
|
||||
|
@ -188,6 +191,7 @@ private:
|
|||
*/
|
||||
void setHDStatus(int hdEnabled);
|
||||
|
||||
public Q_SLOTS:
|
||||
bool handlePaymentRequest(const SendCoinsRecipient& recipient);
|
||||
|
||||
/** Show incoming transaction notification for new transactions. */
|
||||
|
|
|
@ -59,6 +59,7 @@ private:
|
|||
|
||||
const PlatformStyle *platformStyle;
|
||||
|
||||
public:
|
||||
WalletView *currentWalletView();
|
||||
|
||||
public Q_SLOTS:
|
||||
|
|
|
@ -110,8 +110,9 @@ void WalletModel::updateStatus()
|
|||
{
|
||||
EncryptionStatus newEncryptionStatus = getEncryptionStatus();
|
||||
|
||||
if(cachedEncryptionStatus != newEncryptionStatus)
|
||||
Q_EMIT encryptionStatusChanged(newEncryptionStatus);
|
||||
if(cachedEncryptionStatus != newEncryptionStatus) {
|
||||
Q_EMIT encryptionStatusChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void WalletModel::pollBalanceChanged()
|
||||
|
|
|
@ -255,7 +255,7 @@ Q_SIGNALS:
|
|||
const CAmount& watchOnlyBalance, const CAmount& watchUnconfBalance, const CAmount& watchImmatureBalance);
|
||||
|
||||
// Encryption status of wallet changed
|
||||
void encryptionStatusChanged(int status);
|
||||
void encryptionStatusChanged();
|
||||
|
||||
// Signal emitted when wallet needs to be unlocked
|
||||
// It is valid behaviour for listeners to keep the wallet locked after this signal;
|
||||
|
|
|
@ -101,13 +101,13 @@ void WalletView::setBitcoinGUI(BitcoinGUI *gui)
|
|||
connect(this, SIGNAL(message(QString,QString,unsigned int)), gui, SLOT(message(QString,QString,unsigned int)));
|
||||
|
||||
// Pass through encryption status changed signals
|
||||
connect(this, SIGNAL(encryptionStatusChanged(int)), gui, SLOT(setEncryptionStatus(int)));
|
||||
connect(this, SIGNAL(encryptionStatusChanged()), gui, SLOT(updateWalletStatus()));
|
||||
|
||||
// Pass through transaction notifications
|
||||
connect(this, SIGNAL(incomingTransaction(QString,int,CAmount,QString,QString,QString)), gui, SLOT(incomingTransaction(QString,int,CAmount,QString,QString,QString)));
|
||||
|
||||
// Connect HD enabled state signal
|
||||
connect(this, SIGNAL(hdEnabledStatusChanged(int)), gui, SLOT(setHDStatus(int)));
|
||||
connect(this, SIGNAL(hdEnabledStatusChanged()), gui, SLOT(updateWalletStatus()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -137,11 +137,11 @@ void WalletView::setWalletModel(WalletModel *_walletModel)
|
|||
connect(_walletModel, SIGNAL(message(QString,QString,unsigned int)), this, SIGNAL(message(QString,QString,unsigned int)));
|
||||
|
||||
// Handle changes in encryption status
|
||||
connect(_walletModel, SIGNAL(encryptionStatusChanged(int)), this, SIGNAL(encryptionStatusChanged(int)));
|
||||
connect(_walletModel, SIGNAL(encryptionStatusChanged()), this, SIGNAL(encryptionStatusChanged()));
|
||||
updateEncryptionStatus();
|
||||
|
||||
// update HD status
|
||||
Q_EMIT hdEnabledStatusChanged(_walletModel->hdEnabled());
|
||||
Q_EMIT hdEnabledStatusChanged();
|
||||
|
||||
// Balloon pop-up for new transaction
|
||||
connect(_walletModel->getTransactionTableModel(), SIGNAL(rowsInserted(QModelIndex,int,int)),
|
||||
|
@ -234,7 +234,7 @@ void WalletView::showOutOfSyncWarning(bool fShow)
|
|||
|
||||
void WalletView::updateEncryptionStatus()
|
||||
{
|
||||
Q_EMIT encryptionStatusChanged(walletModel->getEncryptionStatus());
|
||||
Q_EMIT encryptionStatusChanged();
|
||||
}
|
||||
|
||||
void WalletView::encryptWallet(bool status)
|
||||
|
|
|
@ -44,6 +44,7 @@ public:
|
|||
The client model represents the part of the core that communicates with the P2P network, and is wallet-agnostic.
|
||||
*/
|
||||
void setClientModel(ClientModel *clientModel);
|
||||
WalletModel *getWalletModel() { return walletModel; }
|
||||
/** Set the wallet model.
|
||||
The wallet model represents a bitcoin wallet, and offers access to the list of transactions, address book and sending
|
||||
functionality.
|
||||
|
@ -119,9 +120,9 @@ Q_SIGNALS:
|
|||
/** Fired when a message should be reported to the user */
|
||||
void message(const QString &title, const QString &message, unsigned int style);
|
||||
/** Encryption status of wallet changed */
|
||||
void encryptionStatusChanged(int status);
|
||||
void encryptionStatusChanged();
|
||||
/** HD-Enabled status of wallet changed (only possible during startup) */
|
||||
void hdEnabledStatusChanged(int hdEnabled);
|
||||
void hdEnabledStatusChanged();
|
||||
/** Notify that a new transaction appeared */
|
||||
void incomingTransaction(const QString& date, int unit, const CAmount& amount, const QString& type, const QString& address, const QString& label);
|
||||
/** Notify that the out of sync warning icon has been pressed */
|
||||
|
|
Loading…
Reference in a new issue