diff --git a/src/dialog/AddressCheckerIndexDialog.cpp b/src/dialog/AddressCheckerIndexDialog.cpp index 4c186fb..bb5d897 100644 --- a/src/dialog/AddressCheckerIndexDialog.cpp +++ b/src/dialog/AddressCheckerIndexDialog.cpp @@ -6,6 +6,7 @@ #include "utils/Utils.h" #include "components.h" +#include "dialog/QrCodeDialog.h" AddressCheckerIndexDialog::AddressCheckerIndexDialog(Wallet *wallet, QWidget *parent) : WindowModalDialog(parent) @@ -14,20 +15,30 @@ AddressCheckerIndexDialog::AddressCheckerIndexDialog(Wallet *wallet, QWidget *pa { ui->setupUi(this); - connect(ui->btn_showAddress, &QPushButton::clicked, [this] { - this->showAddress(ui->line_index->text().toUInt()); + connect(ui->btn_showQRcode, &QPushButton::clicked, [this]{ + QString address = this->address(); + QrCode qr(address, QrCode::Version::AUTO, QrCode::ErrorCorrectionLevel::HIGH); + QrCodeDialog dialog{this, &qr, "Address"}; + dialog.exec(); + }); + + connect(ui->line_index, &QLineEdit::textChanged, [this]{ + ui->address->setText(this->address()); }); auto indexValidator = new U32Validator(this); ui->line_index->setValidator(indexValidator); ui->line_index->setText("0"); - this->showAddress(0); this->adjustSize(); } -void AddressCheckerIndexDialog::showAddress(uint32_t index) { - ui->address->setText(m_wallet->address(m_wallet->currentSubaddressAccount(), index)); +uint32_t AddressCheckerIndexDialog::index() { + return ui->line_index->text().toUInt(); +} + +QString AddressCheckerIndexDialog::address() { + return m_wallet->address(m_wallet->currentSubaddressAccount(), this->index()); } AddressCheckerIndexDialog::~AddressCheckerIndexDialog() = default; \ No newline at end of file diff --git a/src/dialog/AddressCheckerIndexDialog.h b/src/dialog/AddressCheckerIndexDialog.h index 1b103e4..2ddc1b1 100644 --- a/src/dialog/AddressCheckerIndexDialog.h +++ b/src/dialog/AddressCheckerIndexDialog.h @@ -20,7 +20,8 @@ class AddressCheckerIndexDialog : public WindowModalDialog ~AddressCheckerIndexDialog() override; private: - void showAddress(uint32_t index); + uint32_t index(); + QString address(); QScopedPointer ui; Wallet *m_wallet; diff --git a/src/dialog/AddressCheckerIndexDialog.ui b/src/dialog/AddressCheckerIndexDialog.ui index 6621003..0bb50bb 100644 --- a/src/dialog/AddressCheckerIndexDialog.ui +++ b/src/dialog/AddressCheckerIndexDialog.ui @@ -6,8 +6,8 @@ 0 0 - 712 - 127 + 458 + 99 @@ -34,9 +34,9 @@ - + - Show address + Show QR code