From 80aba61a74e128c10d4ec30faecac2541dac300c Mon Sep 17 00:00:00 2001 From: Fuzzbawls Date: Fri, 1 May 2020 04:12:44 -0700 Subject: [PATCH] [GUI][Bug] Don't clear address label during send address validation The current sending flow clears and/or overwrites the user-supplied address label multiple times, including when doing final address validation after clicking the send button. This results in the entered label never being used. This stops the default clear and the overzealous replacing/setting of the label text. --- src/qt/pivx/send.cpp | 3 ++- src/qt/pivx/sendmultirow.cpp | 15 ++++++++------- src/qt/pivx/sendmultirow.h | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/qt/pivx/send.cpp b/src/qt/pivx/send.cpp index 2e0c01a1eaf7c..6c7a521481ec6 100644 --- a/src/qt/pivx/send.cpp +++ b/src/qt/pivx/send.cpp @@ -727,7 +727,8 @@ void SendWidget::onContactsClicked(SendMultiRow* entry) menuContacts->setWalletModel(walletModel, AddressTableModel::Send); connect(menuContacts, &ContactsDropdown::contactSelected, [this](QString address, QString label) { if (focusedEntry) { - focusedEntry->setLabel(label); + if (label != "(no label)") + focusedEntry->setLabel(label); focusedEntry->setAddress(address); } }); diff --git a/src/qt/pivx/sendmultirow.cpp b/src/qt/pivx/sendmultirow.cpp index b3233b5e0eac5..c157264becdb1 100644 --- a/src/qt/pivx/sendmultirow.cpp +++ b/src/qt/pivx/sendmultirow.cpp @@ -57,7 +57,7 @@ SendMultiRow::SendMultiRow(PWidget *parent) : iconNumber->move(posIconX, posIconY); connect(ui->lineEditAmount, &QLineEdit::textChanged, this, &SendMultiRow::amountChanged); - connect(ui->lineEditAddress, &QLineEdit::textChanged, this, &SendMultiRow::addressChanged); + connect(ui->lineEditAddress, &QLineEdit::textChanged, [this](){addressChanged(ui->lineEditAddress->text());}); connect(btnContact, &QAction::triggered, [this](){Q_EMIT onContactsClicked(this);}); connect(ui->btnMenu, &QPushButton::clicked, [this](){Q_EMIT onMenuClicked(this);}); } @@ -83,9 +83,8 @@ CAmount SendMultiRow::getAmountValue(QString amount){ return isValid ? value : -1; } -bool SendMultiRow::addressChanged(const QString& str) +bool SendMultiRow::addressChanged(const QString& str, bool fOnlyValidate) { - ui->lineEditDescription->clear(); if(!str.isEmpty()) { QString trimmedStr = str.trimmed(); const bool valid = walletModel->validateAddress(trimmedStr, this->onlyStakingAddressAccepted); @@ -108,9 +107,11 @@ bool SendMultiRow::addressChanged(const QString& str) } } else { setCssProperty(ui->lineEditAddress, "edit-primary-multi-book"); - QString label = walletModel->getAddressTableModel()->labelForAddress(trimmedStr); - if (!label.isNull()){ - ui->lineEditDescription->setText(label); + if (!fOnlyValidate) { + QString label = walletModel->getAddressTableModel()->labelForAddress(trimmedStr); + if (!label.isEmpty()) { + ui->lineEditDescription->setText(label); + } } } updateStyle(ui->lineEditAddress); @@ -162,7 +163,7 @@ bool SendMultiRow::validate() retval = false; setCssProperty(ui->lineEditAddress, "edit-primary-multi-book-error", true); } else - retval = addressChanged(address); + retval = addressChanged(address, true); CAmount value = getAmountValue(ui->lineEditAmount->text()); diff --git a/src/qt/pivx/sendmultirow.h b/src/qt/pivx/sendmultirow.h index 317e3ab892f42..bf69471a5d2d6 100644 --- a/src/qt/pivx/sendmultirow.h +++ b/src/qt/pivx/sendmultirow.h @@ -73,7 +73,7 @@ public Q_SLOTS: private Q_SLOTS: void amountChanged(const QString&); - bool addressChanged(const QString&); + bool addressChanged(const QString&, bool fOnlyValidate = false); void deleteClicked(); //void on_payTo_textChanged(const QString& address); //void on_addressBookButton_clicked();