Browse Source

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 .
pull/72/head
Duke Leto 2 years ago
parent
commit
a7b9c89d97
  1. 64
      src/firsttimewizard.cpp
  2. 13
      src/firsttimewizard.h
  3. 5
      src/newwallet.ui
  4. 72
      src/restoreSeed.ui

64
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);

13
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

5
src/newwallet.ui

@ -110,6 +110,9 @@ p, li { white-space: pre-wrap; }
<height>16777215</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">color: red;</string>
</property>
<property name="text">
<string>I accept the Terms of Service</string>
</property>
@ -146,7 +149,7 @@ p, li { white-space: pre-wrap; }
<string notr="true">color: red;</string>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-style:italic;&quot;&gt;Passphrase don't match&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string></string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>

72
src/restoreSeed.ui

@ -1,72 +0,0 @@
<ui version="4.0" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>Dialog</class>
<widget class="QDialog" name="Dialog" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle" >
<string>Dialog</string>
</property>
<widget class="QDialogButtonBox" name="buttonBox" >
<property name="geometry" >
<rect>
<x>30</x>
<y>240</y>
<width>341</width>
<height>32</height>
</rect>
</property>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons" >
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</widget>
<pixmapfunction></pixmapfunction>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>Dialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel" >
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel" >
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>Dialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel" >
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel" >
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
Loading…
Cancel
Save