mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-25 18:53:23 -03:00
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
|
#ifdef ENABLE_WALLET
|
||||||
#include <qt/walletframe.h>
|
#include <qt/walletframe.h>
|
||||||
#include <qt/walletmodel.h>
|
#include <qt/walletmodel.h>
|
||||||
|
#include <qt/walletview.h>
|
||||||
#endif // ENABLE_WALLET
|
#endif // ENABLE_WALLET
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
|
@ -1097,6 +1098,20 @@ void BitcoinGUI::setEncryptionStatus(int status)
|
||||||
break;
|
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
|
#endif // ENABLE_WALLET
|
||||||
|
|
||||||
void BitcoinGUI::showNormalIfMinimized(bool fToggleHidden)
|
void BitcoinGUI::showNormalIfMinimized(bool fToggleHidden)
|
||||||
|
|
|
@ -174,6 +174,9 @@ public Q_SLOTS:
|
||||||
|
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
bool setCurrentWallet(const QString& name);
|
bool setCurrentWallet(const QString& name);
|
||||||
|
/** Set the UI status indicators based on the currently selected wallet.
|
||||||
|
*/
|
||||||
|
void updateWalletStatus();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** Set the encryption status as shown in the UI.
|
/** Set the encryption status as shown in the UI.
|
||||||
|
@ -188,6 +191,7 @@ private:
|
||||||
*/
|
*/
|
||||||
void setHDStatus(int hdEnabled);
|
void setHDStatus(int hdEnabled);
|
||||||
|
|
||||||
|
public Q_SLOTS:
|
||||||
bool handlePaymentRequest(const SendCoinsRecipient& recipient);
|
bool handlePaymentRequest(const SendCoinsRecipient& recipient);
|
||||||
|
|
||||||
/** Show incoming transaction notification for new transactions. */
|
/** Show incoming transaction notification for new transactions. */
|
||||||
|
|
|
@ -59,6 +59,7 @@ private:
|
||||||
|
|
||||||
const PlatformStyle *platformStyle;
|
const PlatformStyle *platformStyle;
|
||||||
|
|
||||||
|
public:
|
||||||
WalletView *currentWalletView();
|
WalletView *currentWalletView();
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
|
|
|
@ -110,8 +110,9 @@ void WalletModel::updateStatus()
|
||||||
{
|
{
|
||||||
EncryptionStatus newEncryptionStatus = getEncryptionStatus();
|
EncryptionStatus newEncryptionStatus = getEncryptionStatus();
|
||||||
|
|
||||||
if(cachedEncryptionStatus != newEncryptionStatus)
|
if(cachedEncryptionStatus != newEncryptionStatus) {
|
||||||
Q_EMIT encryptionStatusChanged(newEncryptionStatus);
|
Q_EMIT encryptionStatusChanged();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WalletModel::pollBalanceChanged()
|
void WalletModel::pollBalanceChanged()
|
||||||
|
|
|
@ -255,7 +255,7 @@ Q_SIGNALS:
|
||||||
const CAmount& watchOnlyBalance, const CAmount& watchUnconfBalance, const CAmount& watchImmatureBalance);
|
const CAmount& watchOnlyBalance, const CAmount& watchUnconfBalance, const CAmount& watchImmatureBalance);
|
||||||
|
|
||||||
// Encryption status of wallet changed
|
// Encryption status of wallet changed
|
||||||
void encryptionStatusChanged(int status);
|
void encryptionStatusChanged();
|
||||||
|
|
||||||
// Signal emitted when wallet needs to be unlocked
|
// Signal emitted when wallet needs to be unlocked
|
||||||
// It is valid behaviour for listeners to keep the wallet locked after this signal;
|
// 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)));
|
connect(this, SIGNAL(message(QString,QString,unsigned int)), gui, SLOT(message(QString,QString,unsigned int)));
|
||||||
|
|
||||||
// Pass through encryption status changed signals
|
// 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
|
// Pass through transaction notifications
|
||||||
connect(this, SIGNAL(incomingTransaction(QString,int,CAmount,QString,QString,QString)), gui, SLOT(incomingTransaction(QString,int,CAmount,QString,QString,QString)));
|
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 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)));
|
connect(_walletModel, SIGNAL(message(QString,QString,unsigned int)), this, SIGNAL(message(QString,QString,unsigned int)));
|
||||||
|
|
||||||
// Handle changes in encryption status
|
// Handle changes in encryption status
|
||||||
connect(_walletModel, SIGNAL(encryptionStatusChanged(int)), this, SIGNAL(encryptionStatusChanged(int)));
|
connect(_walletModel, SIGNAL(encryptionStatusChanged()), this, SIGNAL(encryptionStatusChanged()));
|
||||||
updateEncryptionStatus();
|
updateEncryptionStatus();
|
||||||
|
|
||||||
// update HD status
|
// update HD status
|
||||||
Q_EMIT hdEnabledStatusChanged(_walletModel->hdEnabled());
|
Q_EMIT hdEnabledStatusChanged();
|
||||||
|
|
||||||
// Balloon pop-up for new transaction
|
// Balloon pop-up for new transaction
|
||||||
connect(_walletModel->getTransactionTableModel(), SIGNAL(rowsInserted(QModelIndex,int,int)),
|
connect(_walletModel->getTransactionTableModel(), SIGNAL(rowsInserted(QModelIndex,int,int)),
|
||||||
|
@ -234,7 +234,7 @@ void WalletView::showOutOfSyncWarning(bool fShow)
|
||||||
|
|
||||||
void WalletView::updateEncryptionStatus()
|
void WalletView::updateEncryptionStatus()
|
||||||
{
|
{
|
||||||
Q_EMIT encryptionStatusChanged(walletModel->getEncryptionStatus());
|
Q_EMIT encryptionStatusChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WalletView::encryptWallet(bool status)
|
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.
|
The client model represents the part of the core that communicates with the P2P network, and is wallet-agnostic.
|
||||||
*/
|
*/
|
||||||
void setClientModel(ClientModel *clientModel);
|
void setClientModel(ClientModel *clientModel);
|
||||||
|
WalletModel *getWalletModel() { return walletModel; }
|
||||||
/** Set the wallet model.
|
/** Set the wallet model.
|
||||||
The wallet model represents a bitcoin wallet, and offers access to the list of transactions, address book and sending
|
The wallet model represents a bitcoin wallet, and offers access to the list of transactions, address book and sending
|
||||||
functionality.
|
functionality.
|
||||||
|
@ -119,9 +120,9 @@ Q_SIGNALS:
|
||||||
/** Fired when a message should be reported to the user */
|
/** Fired when a message should be reported to the user */
|
||||||
void message(const QString &title, const QString &message, unsigned int style);
|
void message(const QString &title, const QString &message, unsigned int style);
|
||||||
/** Encryption status of wallet changed */
|
/** Encryption status of wallet changed */
|
||||||
void encryptionStatusChanged(int status);
|
void encryptionStatusChanged();
|
||||||
/** HD-Enabled status of wallet changed (only possible during startup) */
|
/** HD-Enabled status of wallet changed (only possible during startup) */
|
||||||
void hdEnabledStatusChanged(int hdEnabled);
|
void hdEnabledStatusChanged();
|
||||||
/** Notify that a new transaction appeared */
|
/** 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);
|
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 */
|
/** Notify that the out of sync warning icon has been pressed */
|
||||||
|
|
Loading…
Add table
Reference in a new issue