]> Nutra Git (v1) - gamesguru/feather.git/commitdiff
wizard: restore: add option to hide seed
authortobtoht <tob@featherwallet.org>
Wed, 25 Oct 2023 15:38:40 +0000 (17:38 +0200)
committertobtoht <tob@featherwallet.org>
Wed, 25 Oct 2023 15:38:40 +0000 (17:38 +0200)
src/wizard/PageWalletRestoreSeed.cpp
src/wizard/PageWalletRestoreSeed.ui

index 2285edd3db33d7ac6f481ca3d22f63cc01f176f7..ef97b020cf117000d8a6f7974af4098331f826a8 100644 (file)
@@ -65,6 +65,17 @@ PageWalletRestoreSeed::PageWalletRestoreSeed(WizardFields *fields, QWidget *pare
         dialog.exec();
     });
 
+    ui->seedObscured->hide();
+    connect(ui->check_obscureSeed, &QPushButton::clicked, [this](bool checked){
+        ui->seedEdit->setVisible(!checked);
+        ui->seedObscured->setVisible(checked);
+        if (checked) {
+            ui->seedObscured->setText(ui->seedEdit->toPlainText());
+        } else {
+            ui->seedEdit->setText(ui->seedObscured->text());
+        }
+    });
+
     connect(ui->seedBtnGroup, QOverload<QAbstractButton *>::of(&QButtonGroup::buttonClicked), this, &PageWalletRestoreSeed::onSeedTypeToggled);
     connect(ui->combo_seedLanguage, &QComboBox::currentTextChanged, this, &PageWalletRestoreSeed::onSeedLanguageChanged);
     connect(ui->btnOptions, &QPushButton::clicked, this, &PageWalletRestoreSeed::onOptionsClicked);
@@ -119,6 +130,7 @@ int PageWalletRestoreSeed::nextId() const {
 
 void PageWalletRestoreSeed::initializePage() {
     this->setTitle(m_fields->modeText);
+    ui->seedObscured->setText("");
     ui->seedEdit->setText("");
     ui->seedEdit->setStyleSheet("");
     ui->label_errorString->hide();
@@ -130,8 +142,17 @@ bool PageWalletRestoreSeed::validatePage() {
     ui->label_errorString->hide();
     ui->seedEdit->setStyleSheet("");
 
+    QString seed = [this]{
+        if (ui->check_obscureSeed->isChecked()) {
+            return ui->seedObscured->text();
+        } else {
+            return ui->seedEdit->toPlainText();
+        }
+    }();
+
+    seed = seed.replace("\n", " ").replace("\r", "").trimmed();
+
     auto errStyle = "QTextEdit{border: 1px solid red;}";
-    auto seed = ui->seedEdit->toPlainText().replace("\n", " ").replace("\r", "").trimmed();
     QStringList seedSplit = seed.split(" ", Qt::SkipEmptyParts);
 
     if (seedSplit.length() != m_mode->length) {
index 0efe960f6017cc340d06105ebeea954451caa66e..fac68d8f5b8d076459b6f191a2aaf1a1e9cf5a14 100644 (file)
      </property>
     </widget>
    </item>
+   <item>
+    <widget class="QLineEdit" name="seedObscured">
+     <property name="echoMode">
+      <enum>QLineEdit::Password</enum>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_2">
+     <item>
+      <widget class="QCheckBox" name="check_obscureSeed">
+       <property name="text">
+        <string>Hide seed</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <spacer name="horizontalSpacer_2">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+    </layout>
+   </item>
    <item>
     <spacer name="verticalSpacer_2">
      <property name="orientation">