]> Nutra Git (v1) - gamesguru/feather.git/commitdiff
airgap: allow showing address QR code
authortobtoht <tob@featherwallet.org>
Wed, 6 Dec 2023 19:29:24 +0000 (20:29 +0100)
committertobtoht <tob@featherwallet.org>
Wed, 6 Dec 2023 19:29:24 +0000 (20:29 +0100)
src/dialog/AddressCheckerIndexDialog.cpp
src/dialog/AddressCheckerIndexDialog.h
src/dialog/AddressCheckerIndexDialog.ui

index 4c186fbdfa6003a41fc571f564c077ed7f4bc390..bb5d8974c662777a2693c5c418cc72d8cf03e831 100644 (file)
@@ -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
index 1b103e4117d31ca86333cabc19a572463367be1e..2ddc1b1dbee006a08c41a99f4ea971c78389b9aa 100644 (file)
@@ -20,7 +20,8 @@ class AddressCheckerIndexDialog : public WindowModalDialog
     ~AddressCheckerIndexDialog() override;
 
 private:
-    void showAddress(uint32_t index);
+    uint32_t index();
+    QString address();
 
     QScopedPointer<Ui::AddressCheckerIndexDialog> ui;
     Wallet *m_wallet;
index 66210032dcf503ccda741eee0e955e3ef82783e6..0bb50bb74c7d6ccfe701f24641a0223a0583a414 100644 (file)
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>712</width>
-    <height>127</height>
+    <width>458</width>
+    <height>99</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -34,9 +34,9 @@
       </widget>
      </item>
      <item>
-      <widget class="QPushButton" name="btn_showAddress">
+      <widget class="QPushButton" name="btn_showQRcode">
        <property name="text">
-        <string>Show address</string>
+        <string>Show QR code</string>
        </property>
       </widget>
      </item>