Skip to content

Commit

Permalink
[GUI] Reset change address from within SendChangeAddressDialog
Browse files Browse the repository at this point in the history
  • Loading branch information
random-zebra committed Apr 23, 2020
1 parent 15b56a2 commit ca99eaa
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/qt/pivx/sendchangeaddressdialog.cpp
Expand Up @@ -4,7 +4,8 @@

#include "qt/pivx/sendchangeaddressdialog.h"
#include "qt/pivx/forms/ui_sendchangeaddressdialog.h"
#include "walletmodel.h"

#include "coincontrol.h"
#include "qt/pivx/qtutils.h"

SendChangeAddressDialog::SendChangeAddressDialog(QWidget *parent) :
Expand Down Expand Up @@ -32,16 +33,17 @@ SendChangeAddressDialog::SendChangeAddressDialog(QWidget *parent) :
ui->btnEsc->setProperty("cssClass", "ic-close");

ui->btnCancel->setProperty("cssClass", "btn-dialog-cancel");
ui->btnSave->setText("SAVE");
ui->btnSave->setText(tr("SAVE"));
setCssBtnPrimary(ui->btnSave);

connect(ui->btnEsc, &QPushButton::clicked, this, &SendChangeAddressDialog::close);
connect(ui->btnCancel, &QPushButton::clicked, this, &SendChangeAddressDialog::close);
connect(ui->btnCancel, &QPushButton::clicked, this, &SendChangeAddressDialog::reset);
connect(ui->btnSave, &QPushButton::clicked, [this](){ selected = true; accept(); });
}

void SendChangeAddressDialog::setAddress(QString address){
ui->lineEditAddress->setText(address);
ui->btnCancel->setText(tr("RESET"));
}

bool SendChangeAddressDialog::getAddress(WalletModel *model, QString *retAddress){
Expand All @@ -58,6 +60,16 @@ void SendChangeAddressDialog::showEvent(QShowEvent *event)
if (ui->lineEditAddress) ui->lineEditAddress->setFocus();
}

void SendChangeAddressDialog::reset()
{
if (!ui->lineEditAddress->text().isEmpty()) {
ui->lineEditAddress->clear();
ui->btnCancel->setText(tr("CANCEL"));
CoinControlDialog::coinControl->destChange = CNoDestination();
}
close();
}

SendChangeAddressDialog::~SendChangeAddressDialog(){
delete ui;
}
4 changes: 4 additions & 0 deletions src/qt/pivx/sendchangeaddressdialog.h
Expand Up @@ -26,8 +26,12 @@ class SendChangeAddressDialog : public QDialog
bool selected = false;

void showEvent(QShowEvent *event) override;

private:
Ui::SendChangeAddressDialog *ui;

private Q_SLOTS:
void reset();
};

#endif // SENDCHANGEADDRESSDIALOG_H

0 comments on commit ca99eaa

Please sign in to comment.