mirror of
https://github.com/monero-project/monero-gui.git
synced 2026-04-05 08:57:24 -04:00
Wallet: persistent subaddress account selection
This commit is contained in:
@@ -55,6 +55,8 @@ namespace {
|
||||
static const int DAEMON_BLOCKCHAIN_HEIGHT_CACHE_TTL_SECONDS = 5;
|
||||
static const int DAEMON_BLOCKCHAIN_TARGET_HEIGHT_CACHE_TTL_SECONDS = 30;
|
||||
static const int WALLET_CONNECTION_STATUS_CACHE_TTL_SECONDS = 5;
|
||||
|
||||
static constexpr char ATTRIBUTE_SUBADDRESS_ACCOUNT[] ="gui.subaddress_account";
|
||||
}
|
||||
|
||||
class WalletListenerImpl : public Monero::WalletListener
|
||||
@@ -316,8 +318,13 @@ void Wallet::switchSubaddressAccount(quint32 accountIndex)
|
||||
if (accountIndex < numSubaddressAccounts())
|
||||
{
|
||||
m_currentSubaddressAccount = accountIndex;
|
||||
if (!setCacheAttribute(ATTRIBUTE_SUBADDRESS_ACCOUNT, QString::number(m_currentSubaddressAccount)))
|
||||
{
|
||||
qWarning() << "failed to set " << ATTRIBUTE_SUBADDRESS_ACCOUNT << " cache attribute";
|
||||
}
|
||||
m_subaddress->refresh(m_currentSubaddressAccount);
|
||||
m_history->refresh(m_currentSubaddressAccount);
|
||||
emit currentSubaddressAccountChanged();
|
||||
}
|
||||
}
|
||||
void Wallet::addSubaddressAccount(const QString& label)
|
||||
@@ -982,6 +989,7 @@ Wallet::Wallet(Monero::Wallet *w, QObject *parent)
|
||||
m_walletListener = new WalletListenerImpl(this);
|
||||
m_walletImpl->setListener(m_walletListener);
|
||||
m_connectionStatus = Wallet::ConnectionStatus_Disconnected;
|
||||
m_currentSubaddressAccount = getCacheAttribute(ATTRIBUTE_SUBADDRESS_ACCOUNT).toUInt();
|
||||
// start cache timers
|
||||
m_connectionStatusTime.restart();
|
||||
m_daemonBlockChainHeightTime.restart();
|
||||
|
||||
@@ -65,7 +65,7 @@ class Wallet : public QObject
|
||||
Q_PROPERTY(Status status READ status)
|
||||
Q_PROPERTY(NetworkType::Type nettype READ nettype)
|
||||
// Q_PROPERTY(ConnectionStatus connected READ connected)
|
||||
Q_PROPERTY(quint32 currentSubaddressAccount READ currentSubaddressAccount)
|
||||
Q_PROPERTY(quint32 currentSubaddressAccount READ currentSubaddressAccount NOTIFY currentSubaddressAccountChanged)
|
||||
Q_PROPERTY(bool synchronized READ synchronized)
|
||||
Q_PROPERTY(QString errorString READ errorString)
|
||||
Q_PROPERTY(TransactionHistory * history READ history)
|
||||
@@ -365,6 +365,7 @@ signals:
|
||||
void transactionCreated(PendingTransaction * transaction, QString address, QString paymentId, quint32 mixinCount);
|
||||
|
||||
void connectionStatusChanged(int status) const;
|
||||
void currentSubaddressAccountChanged() const;
|
||||
|
||||
private:
|
||||
Wallet(QObject * parent = nullptr);
|
||||
|
||||
Reference in New Issue
Block a user