mirror of
https://github.com/monero-project/monero-gui.git
synced 2025-01-10 11:52:05 +02:00
Merge pull request #2551
646d339
Wallet: persistent subaddress account selection (xiphon)
This commit is contained in:
commit
63d4ba6df8
@ -40,8 +40,8 @@ import "components/effects/" as MoneroEffects
|
|||||||
Rectangle {
|
Rectangle {
|
||||||
id: panel
|
id: panel
|
||||||
|
|
||||||
property int currentAccountIndex: 0
|
property int currentAccountIndex
|
||||||
property string currentAccountLabel: "Primary account"
|
property alias currentAccountLabel: accountLabel.text
|
||||||
property string balanceString: "?.??"
|
property string balanceString: "?.??"
|
||||||
property string balanceUnlockedString: "?.??"
|
property string balanceUnlockedString: "?.??"
|
||||||
property string balanceFiatString: "?.??"
|
property string balanceFiatString: "?.??"
|
||||||
@ -184,7 +184,7 @@ Rectangle {
|
|||||||
MoneroComponents.Label {
|
MoneroComponents.Label {
|
||||||
fontSize: 12
|
fontSize: 12
|
||||||
id: accountIndex
|
id: accountIndex
|
||||||
text: qsTr("Account") + " #" + currentAccountIndex
|
text: qsTr("Account") + translationManager.emptyString + " #" + currentAccountIndex
|
||||||
color: MoneroComponents.Style.blackTheme ? "white" : "black"
|
color: MoneroComponents.Style.blackTheme ? "white" : "black"
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.leftMargin: 60
|
anchors.leftMargin: 60
|
||||||
@ -204,7 +204,6 @@ Rectangle {
|
|||||||
fontSize: 16
|
fontSize: 16
|
||||||
id: accountLabel
|
id: accountLabel
|
||||||
textWidth: 170
|
textWidth: 170
|
||||||
text: currentAccountLabel
|
|
||||||
color: MoneroComponents.Style.blackTheme ? "white" : "black"
|
color: MoneroComponents.Style.blackTheme ? "white" : "black"
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.leftMargin: 60
|
anchors.leftMargin: 60
|
||||||
|
11
main.qml
11
main.qml
@ -112,7 +112,6 @@ ApplicationWindow {
|
|||||||
property var current_address
|
property var current_address
|
||||||
property var current_address_label: "Primary"
|
property var current_address_label: "Primary"
|
||||||
property int current_subaddress_table_index: 0
|
property int current_subaddress_table_index: 0
|
||||||
property int current_subaddress_account_table_index: 0
|
|
||||||
|
|
||||||
function altKeyReleased() { ctrlPressed = false; }
|
function altKeyReleased() { ctrlPressed = false; }
|
||||||
|
|
||||||
@ -418,8 +417,6 @@ ApplicationWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
leftPanel.minutesToUnlock = (balance !== balanceU) ? currentWallet.history.minutesToUnlock : "";
|
leftPanel.minutesToUnlock = (balance !== balanceU) ? currentWallet.history.minutesToUnlock : "";
|
||||||
leftPanel.currentAccountIndex = currentWallet.currentSubaddressAccount;
|
|
||||||
leftPanel.currentAccountLabel = currentWallet.getSubaddressLabel(currentWallet.currentSubaddressAccount, 0);
|
|
||||||
leftPanel.balanceString = balance
|
leftPanel.balanceString = balance
|
||||||
leftPanel.balanceUnlockedString = balanceU
|
leftPanel.balanceUnlockedString = balanceU
|
||||||
}
|
}
|
||||||
@ -1616,6 +1613,13 @@ ApplicationWindow {
|
|||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
visible: rootItem.state == "normal" && middlePanel.state != "Merchant"
|
visible: rootItem.state == "normal" && middlePanel.state != "Merchant"
|
||||||
|
currentAccountIndex: currentWallet ? currentWallet.currentSubaddressAccount : 0
|
||||||
|
currentAccountLabel: {
|
||||||
|
if (currentWallet) {
|
||||||
|
return currentWallet.getSubaddressLabel(currentWallet.currentSubaddressAccount, 0);
|
||||||
|
}
|
||||||
|
return qsTr("Primary account") + translationManager.emptyString;
|
||||||
|
}
|
||||||
|
|
||||||
onTransferClicked: {
|
onTransferClicked: {
|
||||||
middlePanel.state = "Transfer";
|
middlePanel.state = "Transfer";
|
||||||
@ -1687,6 +1691,7 @@ ApplicationWindow {
|
|||||||
|
|
||||||
MiddlePanel {
|
MiddlePanel {
|
||||||
id: middlePanel
|
id: middlePanel
|
||||||
|
accountView.currentAccountIndex: currentWallet ? currentWallet.currentSubaddressAccount : 0
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
anchors.left: leftPanel.visible ? leftPanel.right : parent.left
|
anchors.left: leftPanel.visible ? leftPanel.right : parent.left
|
||||||
|
@ -49,6 +49,7 @@ Rectangle {
|
|||||||
property var model
|
property var model
|
||||||
property alias accountHeight: mainLayout.height
|
property alias accountHeight: mainLayout.height
|
||||||
property bool selectAndSend: false
|
property bool selectAndSend: false
|
||||||
|
property int currentAccountIndex
|
||||||
|
|
||||||
function renameSubaddressAccountLabel(_index){
|
function renameSubaddressAccountLabel(_index){
|
||||||
inputDialog.labelText = qsTr("Set the label of the selected account:") + translationManager.emptyString;
|
inputDialog.labelText = qsTr("Set the label of the selected account:") + translationManager.emptyString;
|
||||||
@ -180,6 +181,7 @@ Rectangle {
|
|||||||
clip: true
|
clip: true
|
||||||
boundsBehavior: ListView.StopAtBounds
|
boundsBehavior: ListView.StopAtBounds
|
||||||
interactive: false
|
interactive: false
|
||||||
|
currentIndex: currentAccountIndex
|
||||||
|
|
||||||
delegate: Rectangle {
|
delegate: Rectangle {
|
||||||
id: tableItem2
|
id: tableItem2
|
||||||
@ -211,7 +213,7 @@ Rectangle {
|
|||||||
|
|
||||||
MoneroComponents.Label {
|
MoneroComponents.Label {
|
||||||
id: idLabel
|
id: idLabel
|
||||||
color: index === appWindow.current_subaddress_account_table_index ? MoneroComponents.Style.defaultFontColor : "#757575"
|
color: index === currentAccountIndex ? MoneroComponents.Style.defaultFontColor : "#757575"
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.leftMargin: 6
|
anchors.leftMargin: 6
|
||||||
@ -278,9 +280,9 @@ Rectangle {
|
|||||||
onEntered: tableItem2.color = MoneroComponents.Style.titleBarButtonHoverColor
|
onEntered: tableItem2.color = MoneroComponents.Style.titleBarButtonHoverColor
|
||||||
onExited: tableItem2.color = "transparent"
|
onExited: tableItem2.color = "transparent"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (index == subaddressAccountListView.currentIndex && selectAndSend)
|
appWindow.currentWallet.switchSubaddressAccount(index);
|
||||||
|
if (selectAndSend)
|
||||||
appWindow.showPageRequest("Transfer");
|
appWindow.showPageRequest("Transfer");
|
||||||
subaddressAccountListView.currentIndex = index;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -319,17 +321,9 @@ Rectangle {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onCurrentItemChanged: {
|
|
||||||
// reset global vars
|
|
||||||
appWindow.current_subaddress_account_table_index = subaddressAccountListView.currentIndex;
|
|
||||||
appWindow.currentWallet.switchSubaddressAccount(appWindow.current_subaddress_account_table_index);
|
|
||||||
appWindow.onWalletUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
onCurrentIndexChanged: {
|
onCurrentIndexChanged: {
|
||||||
if (selectAndSend) {
|
appWindow.onWalletUpdate();
|
||||||
appWindow.showPageRequest("Transfer");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -364,8 +358,6 @@ Rectangle {
|
|||||||
inputDialog.onAcceptedCallback = function() {
|
inputDialog.onAcceptedCallback = function() {
|
||||||
appWindow.currentWallet.subaddressAccount.addRow(inputDialog.inputText)
|
appWindow.currentWallet.subaddressAccount.addRow(inputDialog.inputText)
|
||||||
appWindow.currentWallet.switchSubaddressAccount(appWindow.currentWallet.numSubaddressAccounts() - 1)
|
appWindow.currentWallet.switchSubaddressAccount(appWindow.currentWallet.numSubaddressAccounts() - 1)
|
||||||
current_subaddress_account_table_index = appWindow.currentWallet.numSubaddressAccounts() - 1
|
|
||||||
subaddressAccountListView.currentIndex = current_subaddress_account_table_index
|
|
||||||
appWindow.onWalletUpdate();
|
appWindow.onWalletUpdate();
|
||||||
}
|
}
|
||||||
inputDialog.onRejectedCallback = null;
|
inputDialog.onRejectedCallback = null;
|
||||||
|
@ -55,6 +55,8 @@ namespace {
|
|||||||
static const int DAEMON_BLOCKCHAIN_HEIGHT_CACHE_TTL_SECONDS = 5;
|
static const int DAEMON_BLOCKCHAIN_HEIGHT_CACHE_TTL_SECONDS = 5;
|
||||||
static const int DAEMON_BLOCKCHAIN_TARGET_HEIGHT_CACHE_TTL_SECONDS = 30;
|
static const int DAEMON_BLOCKCHAIN_TARGET_HEIGHT_CACHE_TTL_SECONDS = 30;
|
||||||
static const int WALLET_CONNECTION_STATUS_CACHE_TTL_SECONDS = 5;
|
static const int WALLET_CONNECTION_STATUS_CACHE_TTL_SECONDS = 5;
|
||||||
|
|
||||||
|
static constexpr char ATTRIBUTE_SUBADDRESS_ACCOUNT[] ="gui.subaddress_account";
|
||||||
}
|
}
|
||||||
|
|
||||||
class WalletListenerImpl : public Monero::WalletListener
|
class WalletListenerImpl : public Monero::WalletListener
|
||||||
@ -316,8 +318,13 @@ void Wallet::switchSubaddressAccount(quint32 accountIndex)
|
|||||||
if (accountIndex < numSubaddressAccounts())
|
if (accountIndex < numSubaddressAccounts())
|
||||||
{
|
{
|
||||||
m_currentSubaddressAccount = accountIndex;
|
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_subaddress->refresh(m_currentSubaddressAccount);
|
||||||
m_history->refresh(m_currentSubaddressAccount);
|
m_history->refresh(m_currentSubaddressAccount);
|
||||||
|
emit currentSubaddressAccountChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void Wallet::addSubaddressAccount(const QString& label)
|
void Wallet::addSubaddressAccount(const QString& label)
|
||||||
@ -982,6 +989,7 @@ Wallet::Wallet(Monero::Wallet *w, QObject *parent)
|
|||||||
m_walletListener = new WalletListenerImpl(this);
|
m_walletListener = new WalletListenerImpl(this);
|
||||||
m_walletImpl->setListener(m_walletListener);
|
m_walletImpl->setListener(m_walletListener);
|
||||||
m_connectionStatus = Wallet::ConnectionStatus_Disconnected;
|
m_connectionStatus = Wallet::ConnectionStatus_Disconnected;
|
||||||
|
m_currentSubaddressAccount = getCacheAttribute(ATTRIBUTE_SUBADDRESS_ACCOUNT).toUInt();
|
||||||
// start cache timers
|
// start cache timers
|
||||||
m_connectionStatusTime.restart();
|
m_connectionStatusTime.restart();
|
||||||
m_daemonBlockChainHeightTime.restart();
|
m_daemonBlockChainHeightTime.restart();
|
||||||
|
@ -65,7 +65,7 @@ class Wallet : public QObject
|
|||||||
Q_PROPERTY(Status status READ status)
|
Q_PROPERTY(Status status READ status)
|
||||||
Q_PROPERTY(NetworkType::Type nettype READ nettype)
|
Q_PROPERTY(NetworkType::Type nettype READ nettype)
|
||||||
// Q_PROPERTY(ConnectionStatus connected READ connected)
|
// 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(bool synchronized READ synchronized)
|
||||||
Q_PROPERTY(QString errorString READ errorString)
|
Q_PROPERTY(QString errorString READ errorString)
|
||||||
Q_PROPERTY(TransactionHistory * history READ history)
|
Q_PROPERTY(TransactionHistory * history READ history)
|
||||||
@ -365,6 +365,7 @@ signals:
|
|||||||
void transactionCreated(PendingTransaction * transaction, QString address, QString paymentId, quint32 mixinCount);
|
void transactionCreated(PendingTransaction * transaction, QString address, QString paymentId, quint32 mixinCount);
|
||||||
|
|
||||||
void connectionStatusChanged(int status) const;
|
void connectionStatusChanged(int status) const;
|
||||||
|
void currentSubaddressAccountChanged() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Wallet(QObject * parent = nullptr);
|
Wallet(QObject * parent = nullptr);
|
||||||
|
Loading…
Reference in New Issue
Block a user