mirror of
https://github.com/feather-wallet/feather.git
synced 2024-12-22 19:49:28 +00:00
airgap: allow showing address QR code
This commit is contained in:
parent
9056047b1b
commit
7c89a7d5bb
3 changed files with 22 additions and 10 deletions
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include "utils/Utils.h"
|
#include "utils/Utils.h"
|
||||||
#include "components.h"
|
#include "components.h"
|
||||||
|
#include "dialog/QrCodeDialog.h"
|
||||||
|
|
||||||
AddressCheckerIndexDialog::AddressCheckerIndexDialog(Wallet *wallet, QWidget *parent)
|
AddressCheckerIndexDialog::AddressCheckerIndexDialog(Wallet *wallet, QWidget *parent)
|
||||||
: WindowModalDialog(parent)
|
: WindowModalDialog(parent)
|
||||||
|
@ -14,20 +15,30 @@ AddressCheckerIndexDialog::AddressCheckerIndexDialog(Wallet *wallet, QWidget *pa
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
connect(ui->btn_showAddress, &QPushButton::clicked, [this] {
|
connect(ui->btn_showQRcode, &QPushButton::clicked, [this]{
|
||||||
this->showAddress(ui->line_index->text().toUInt());
|
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);
|
auto indexValidator = new U32Validator(this);
|
||||||
ui->line_index->setValidator(indexValidator);
|
ui->line_index->setValidator(indexValidator);
|
||||||
ui->line_index->setText("0");
|
ui->line_index->setText("0");
|
||||||
|
|
||||||
this->showAddress(0);
|
|
||||||
this->adjustSize();
|
this->adjustSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddressCheckerIndexDialog::showAddress(uint32_t index) {
|
uint32_t AddressCheckerIndexDialog::index() {
|
||||||
ui->address->setText(m_wallet->address(m_wallet->currentSubaddressAccount(), index));
|
return ui->line_index->text().toUInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString AddressCheckerIndexDialog::address() {
|
||||||
|
return m_wallet->address(m_wallet->currentSubaddressAccount(), this->index());
|
||||||
}
|
}
|
||||||
|
|
||||||
AddressCheckerIndexDialog::~AddressCheckerIndexDialog() = default;
|
AddressCheckerIndexDialog::~AddressCheckerIndexDialog() = default;
|
|
@ -20,7 +20,8 @@ class AddressCheckerIndexDialog : public WindowModalDialog
|
||||||
~AddressCheckerIndexDialog() override;
|
~AddressCheckerIndexDialog() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void showAddress(uint32_t index);
|
uint32_t index();
|
||||||
|
QString address();
|
||||||
|
|
||||||
QScopedPointer<Ui::AddressCheckerIndexDialog> ui;
|
QScopedPointer<Ui::AddressCheckerIndexDialog> ui;
|
||||||
Wallet *m_wallet;
|
Wallet *m_wallet;
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>712</width>
|
<width>458</width>
|
||||||
<height>127</height>
|
<height>99</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -34,9 +34,9 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="btn_showAddress">
|
<widget class="QPushButton" name="btn_showQRcode">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Show address</string>
|
<string>Show QR code</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
Loading…
Reference in a new issue