diff --git a/src/firsttimewizard.cpp b/src/firsttimewizard.cpp index b897b23..2362523 100644 --- a/src/firsttimewizard.cpp +++ b/src/firsttimewizard.cpp @@ -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); diff --git a/src/firsttimewizard.h b/src/firsttimewizard.h index b9934f7..8af3510 100644 --- a/src/firsttimewizard.h +++ b/src/firsttimewizard.h @@ -1,4 +1,4 @@ -// Copyright 2019-2020 The Hush developers +// Copyright 2019-2022 The Hush developers // Released under the GPLv3 #ifndef FIRSTTIMEWIZARD_H #define FIRSTTIMEWIZARD_H @@ -31,8 +31,10 @@ public slots: protected: int nextId() const; + virtual void initializePage(); private: + FirstTimeWizard* parent; enum { Page_NewOrRestore, Page_New, @@ -49,10 +51,17 @@ private: }; class NewOrRestorePage: public QWizardPage { + public: NewOrRestorePage(FirstTimeWizard* parent); +protected: + virtual void initializePage(); + +private: + FirstTimeWizard* parent; + }; @@ -83,6 +92,4 @@ private: Ui_RestoreSeedForm form; }; - - #endif // FIRSTTIMEWIZARD_H diff --git a/src/newwallet.ui b/src/newwallet.ui index f1ab614..e208d4e 100644 --- a/src/newwallet.ui +++ b/src/newwallet.ui @@ -110,6 +110,9 @@ p, li { white-space: pre-wrap; } 16777215 + + color: red; + I accept the Terms of Service @@ -146,7 +149,7 @@ p, li { white-space: pre-wrap; } color: red; - <html><head/><body><p><span style=" font-style:italic;">Passphrase don't match</span></p></body></html> + Qt::AlignCenter diff --git a/src/restoreSeed.ui b/src/restoreSeed.ui deleted file mode 100644 index fb923db..0000000 --- a/src/restoreSeed.ui +++ /dev/null @@ -1,72 +0,0 @@ - - - - - Dialog - - - - 0 - 0 - 400 - 300 - - - - Dialog - - - - - 30 - 240 - 341 - 32 - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - buttonBox - accepted() - Dialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - Dialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - - -