From: tobtoht Date: Wed, 25 Oct 2023 15:38:40 +0000 (+0200) Subject: wizard: restore: add option to hide seed X-Git-Url: https://git.nutra.tk/v2?a=commitdiff_plain;h=4e99b53e8791c966a2a5b7b486aeec215b264df7;p=gamesguru%2Ffeather.git wizard: restore: add option to hide seed --- diff --git a/src/wizard/PageWalletRestoreSeed.cpp b/src/wizard/PageWalletRestoreSeed.cpp index 2285edd3..ef97b020 100644 --- a/src/wizard/PageWalletRestoreSeed.cpp +++ b/src/wizard/PageWalletRestoreSeed.cpp @@ -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::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) { diff --git a/src/wizard/PageWalletRestoreSeed.ui b/src/wizard/PageWalletRestoreSeed.ui index 0efe960f..fac68d8f 100644 --- a/src/wizard/PageWalletRestoreSeed.ui +++ b/src/wizard/PageWalletRestoreSeed.ui @@ -78,6 +78,37 @@ + + + + QLineEdit::Password + + + + + + + + + Hide seed + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + +