Fix some issues related to #65
This commit prevents the basic bug of allowing a user to click "Next" without entering any information. This is done by telling QT which fields are mandatory. I am not sure if it fixes the "Cancel button does a coredump" because I cannot reproduce that. I also made various strings use the translation file. I removed the "Back" button from the first page, because that makes no sense. I removed the "Passphrase don't match" red text that is shown by default, because it was ugly and immediately shows users a negative "you did something wrong" as their very first visual of the wallet. That seemed like bad UI/UX. Now we only show red text there if passwords are too short or do not match. I made the TOS button text red, which makes it more clear that it's necessary to click it. As a consequence of these changes, you cannot input ANY values until the TOS radio button is clicked, so it seemed important to highlight it in red. Otherwise users may click other areas and it seems like nothing works. I deleted an unused file restoreSeed.ui .
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2021 The Hush developers
|
||||
// Copyright 2019-2022 The Hush developers
|
||||
// Released under the GPLv3
|
||||
#include "firsttimewizard.h"
|
||||
#include "ui_newseed.h"
|
||||
@@ -7,7 +7,6 @@
|
||||
#include "ui_newwallet.h"
|
||||
#include "mainwindow.h"
|
||||
#include "DataStore/DataStore.h"
|
||||
|
||||
#include "../lib/silentdragonlitelib.h"
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
@@ -52,6 +51,7 @@ void FirstTimeWizard::slot_change_theme(const QString& theme_name) {
|
||||
|
||||
FirstTimeWizard::FirstTimeWizard(bool dangerous, QString server)
|
||||
{
|
||||
qDebug() << __func__ << ": dangerous=" << dangerous << " server=" << server;
|
||||
// Include css
|
||||
QString theme_name;
|
||||
try
|
||||
@@ -64,12 +64,11 @@ FirstTimeWizard::FirstTimeWizard(bool dangerous, QString server)
|
||||
}
|
||||
this->slot_change_theme(theme_name);
|
||||
|
||||
setWindowTitle("New wallet wizard");
|
||||
setWindowTitle(tr("New wallet wizard"));
|
||||
this->dangerous = dangerous;
|
||||
this->server = server;
|
||||
|
||||
|
||||
////backup addresslabels.dat if there is one, to restore it later
|
||||
//backup addresslabels.dat if there is one, to restore it later
|
||||
|
||||
auto dir = QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation));
|
||||
QString addressbook = dir.filePath("addresslabels.dat.enc");
|
||||
@@ -103,68 +102,72 @@ int FirstTimeWizard::nextId() const {
|
||||
|
||||
QString FirstTimeWizard::getSeed()
|
||||
{
|
||||
|
||||
return _seed;
|
||||
}
|
||||
|
||||
void FirstTimeWizard::setSeed(QString seed)
|
||||
{
|
||||
|
||||
_seed = seed;
|
||||
}
|
||||
|
||||
QString FirstTimeWizard::getBirthday()
|
||||
{
|
||||
|
||||
return _birthday;
|
||||
}
|
||||
|
||||
void FirstTimeWizard::setBirthday(QString birthday)
|
||||
{
|
||||
|
||||
_birthday = birthday;
|
||||
}
|
||||
|
||||
void FirstTimeWizard::initializePage() {
|
||||
qDebug() << "FirstTimeWizard:" <<__func__;
|
||||
|
||||
}
|
||||
|
||||
void NewOrRestorePage::initializePage() {
|
||||
qDebug() << "NewOrRestorePage:" <<__func__;
|
||||
|
||||
}
|
||||
|
||||
NewOrRestorePage::NewOrRestorePage(FirstTimeWizard *parent) : QWizardPage(parent) {
|
||||
setTitle("Create or Restore wallet.");
|
||||
qDebug() << __func__;
|
||||
setTitle(tr("Create or Restore wallet."));
|
||||
|
||||
QWidget* pageWidget = new QWidget();
|
||||
Ui_CreateWalletForm form;
|
||||
form.setupUi(pageWidget);
|
||||
|
||||
QGraphicsScene* scene = new QGraphicsScene();
|
||||
//QGraphicsView* view = new QGraphicsView(scene);
|
||||
form.Logo->setScene(scene);
|
||||
QPixmap pixmap(":/icons/res/dark-01.png");
|
||||
scene->addPixmap(pixmap);
|
||||
form.Logo->show();
|
||||
|
||||
setButtonText(QWizard::CommitButton, tr("Next"));
|
||||
|
||||
parent->setOption(QWizard::NoBackButtonOnStartPage);
|
||||
|
||||
parent->button(QWizard::CommitButton)->setEnabled(false);
|
||||
setButtonText(QWizard::CommitButton, "Next");
|
||||
form.txtPassword->setEnabled(false);
|
||||
form.txtConfirmPassword->setEnabled(false);
|
||||
|
||||
QObject::connect(form.TOS, &QRadioButton::clicked, [=](bool checked) {
|
||||
qDebug() << __func__ << ": TOS radio button clicked";
|
||||
if (checked) {
|
||||
|
||||
form.txtPassword->setEnabled(true);
|
||||
form.txtConfirmPassword->setEnabled(true);
|
||||
|
||||
}else{
|
||||
qDebug() << __func__ << ": disabling next/commit buttons";
|
||||
parent->button(QWizard::CommitButton)->setEnabled(false);
|
||||
parent->button(QWizard::NextButton)->setEnabled(false);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
auto fnPasswordEdited = [=](const QString&) {
|
||||
auto fnPasswordEdited = [=](const QString&) {
|
||||
// Enable the Finish button if the passwords match.
|
||||
QString passphraseBlank = form.txtPassword->text();
|
||||
|
||||
QString passphrase = QString("HUSH3") + passphraseBlank + QString("SDL");
|
||||
|
||||
|
||||
if (!form.txtPassword->text().isEmpty() &&
|
||||
form.txtPassword->text() == form.txtConfirmPassword->text() && passphraseBlank.size() >= 16 ){
|
||||
|
||||
@@ -210,6 +213,7 @@ NewOrRestorePage::NewOrRestorePage(FirstTimeWizard *parent) : QWizardPage(parent
|
||||
// Exclusive buttons
|
||||
QObject::connect(form.radioNewWallet, &QRadioButton::clicked, [=](bool checked) {
|
||||
if (checked) {
|
||||
qDebug() << __func__ << ": new wallet radio button clicked";
|
||||
form.radioRestoreWallet->setChecked(false);
|
||||
parent->button(QWizard::CommitButton)->setEnabled(true);
|
||||
|
||||
@@ -218,6 +222,7 @@ NewOrRestorePage::NewOrRestorePage(FirstTimeWizard *parent) : QWizardPage(parent
|
||||
|
||||
QObject::connect(form.radioRestoreWallet, &QRadioButton::clicked, [=](bool checked) {
|
||||
if (checked) {
|
||||
qDebug() << __func__ << ": restore wallet radio button clicked";
|
||||
form.radioNewWallet->setChecked(false);
|
||||
parent->button(QWizard::CommitButton)->setEnabled(true);
|
||||
|
||||
@@ -225,6 +230,7 @@ NewOrRestorePage::NewOrRestorePage(FirstTimeWizard *parent) : QWizardPage(parent
|
||||
});
|
||||
|
||||
} else {
|
||||
qDebug() << __func__ << ": passphrases do not match";
|
||||
form.lblPasswordMatch->setText(tr("Passphrase don't match or You have entered too few letters (16 minimum)"));
|
||||
|
||||
parent->button(QWizard::CommitButton)->setEnabled(false);
|
||||
@@ -240,17 +246,31 @@ NewOrRestorePage::NewOrRestorePage(FirstTimeWizard *parent) : QWizardPage(parent
|
||||
|
||||
QObject::connect(form.txtConfirmPassword, &QLineEdit::textChanged, fnPasswordEdited);
|
||||
QObject::connect(form.txtPassword, &QLineEdit::textChanged, fnPasswordEdited);
|
||||
|
||||
registerField("intro.new", form.radioNewWallet);
|
||||
registerField("intro.restore", form.radioRestoreWallet);
|
||||
|
||||
// A trailing * means these are REQUIRED fields and "Next" button will be disabled
|
||||
// until they are filled
|
||||
registerField("TOS*", form.TOS);
|
||||
registerField("txtPassword*", form.txtPassword);
|
||||
registerField("txtConfirmPassword*", form.txtPassword);
|
||||
|
||||
form.radioRestoreWallet->setEnabled(false);
|
||||
form.radioNewWallet->setEnabled(false);
|
||||
|
||||
qDebug() << __func__ << ": disabling next/commit buttons";
|
||||
setCommitPage(true);
|
||||
|
||||
parent->button(QWizard::CommitButton)->setEnabled(false);
|
||||
parent->button(QWizard::NextButton)->setEnabled(false);
|
||||
}
|
||||
|
||||
NewSeedPage::NewSeedPage(FirstTimeWizard *parent) : QWizardPage(parent) {
|
||||
qDebug() << __func__;
|
||||
this->parent = parent;
|
||||
|
||||
setTitle("Your new wallet");
|
||||
setTitle(tr("Your new wallet"));
|
||||
|
||||
QWidget* pageWidget = new QWidget();
|
||||
form.setupUi(pageWidget);
|
||||
@@ -609,13 +629,15 @@ bool NewSeedPage::validatePage() {
|
||||
return false;
|
||||
this->validatePage();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
RestoreSeedPage::RestoreSeedPage(FirstTimeWizard *parent) : QWizardPage(parent) {
|
||||
this->parent = parent;
|
||||
|
||||
setTitle("Restore wallet from seed");
|
||||
setTitle(tr("Restore wallet from seed"));
|
||||
|
||||
QWidget* pageWidget = new QWidget();
|
||||
form.setupUi(pageWidget);
|
||||
|
||||
Reference in New Issue
Block a user