Wizard: rework seed display

This commit is contained in:
tobtoht 2021-01-20 23:10:12 +01:00
parent aa3d674242
commit 9ddb68c82b
No known key found for this signature in database
GPG key ID: 1CADD27F41F45C3C
2 changed files with 490 additions and 57 deletions

View file

@ -6,6 +6,7 @@
#include "ui_createwalletseed.h" #include "ui_createwalletseed.h"
#include <QFileDialog> #include <QFileDialog>
#include <QMessageBox>
CreateWalletSeedPage::CreateWalletSeedPage(AppContext *ctx, QWidget *parent) : CreateWalletSeedPage::CreateWalletSeedPage(AppContext *ctx, QWidget *parent) :
QWizardPage(parent), QWizardPage(parent),
@ -19,7 +20,9 @@ CreateWalletSeedPage::CreateWalletSeedPage(AppContext *ctx, QWidget *parent) :
this->registerField("mnemonicSeed", ui->hiddenMnemonicSeed); this->registerField("mnemonicSeed", ui->hiddenMnemonicSeed);
ui->hiddenMnemonicSeed->hide(); ui->hiddenMnemonicSeed->hide();
ui->seed->setFont(Utils::relativeFont(1)); ui->seedWord2->setHelpText("In addition to the private spend key, Tevador's 14 word seed scheme also encodes the "
"restore date, cryptocurrency type, and reserves a few bits for future use. "
"The second word is static because the reserved bits remain the same for each seed generation.");
connect(ui->btnRoulette, &QPushButton::clicked, [=]{ connect(ui->btnRoulette, &QPushButton::clicked, [=]{
this->seedRoulette(0); this->seedRoulette(0);
@ -45,7 +48,22 @@ void CreateWalletSeedPage::seedRoulette(int count) {
} }
void CreateWalletSeedPage::displaySeed(const QString &seed){ void CreateWalletSeedPage::displaySeed(const QString &seed){
ui->seed->setPlainText(seed); QStringList seedSplit = seed.split(" ");
ui->seedWord1->setText(seedSplit[0]);
ui->seedWord2->setText(seedSplit[1]);
ui->seedWord3->setText(seedSplit[2]);
ui->seedWord4->setText(seedSplit[3]);
ui->seedWord5->setText(seedSplit[4]);
ui->seedWord6->setText(seedSplit[5]);
ui->seedWord7->setText(seedSplit[6]);
ui->seedWord8->setText(seedSplit[7]);
ui->seedWord9->setText(seedSplit[8]);
ui->seedWord10->setText(seedSplit[9]);
ui->seedWord11->setText(seedSplit[10]);
ui->seedWord12->setText(seedSplit[11]);
ui->seedWord13->setText(seedSplit[12]);
ui->seedWord14->setText(seedSplit[13]);
} }
int CreateWalletSeedPage::nextId() const { int CreateWalletSeedPage::nextId() const {
@ -55,6 +73,16 @@ int CreateWalletSeedPage::nextId() const {
bool CreateWalletSeedPage::validatePage() { bool CreateWalletSeedPage::validatePage() {
if(m_mnemonic.isEmpty()) return false; if(m_mnemonic.isEmpty()) return false;
if(!m_restoreHeight) return false; if(!m_restoreHeight) return false;
QMessageBox seedWarning(this);
seedWarning.setWindowTitle("Warning!");
seedWarning.setText("• Never disclose your seed\n"
"• Never type it on a website\n"
"• Store it safely (offline)\n"
"• Do not lose your seed!");
seedWarning.addButton("I understand", QMessageBox::AcceptRole);
seedWarning.exec();
this->setField("mnemonicSeed", m_mnemonic); this->setField("mnemonicSeed", m_mnemonic);
this->setField("restoreHeight", m_restoreHeight); this->setField("restoreHeight", m_restoreHeight);
emit createWallet(); emit createWallet();

View file

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>438</width> <width>775</width>
<height>444</height> <height>571</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -15,27 +15,458 @@
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<widget class="QPlainTextEdit" name="seed"> <layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="maximumSize"> <item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>1</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="leftMargin">
<number>5</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>5</number>
</property>
<item>
<widget class="QLabel" name="seedWord1">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>2</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<property name="leftMargin">
<number>5</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>5</number>
</property>
<item>
<widget class="HelpLabel" name="seedWord2">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>3</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<property name="leftMargin">
<number>5</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>5</number>
</property>
<item>
<widget class="QLabel" name="seedWord3">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_4">
<property name="title">
<string>4</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="leftMargin">
<number>5</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>5</number>
</property>
<item>
<widget class="QLabel" name="seedWord4">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QGroupBox" name="groupBox_5">
<property name="title">
<string>5</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<property name="leftMargin">
<number>5</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>5</number>
</property>
<item>
<widget class="QLabel" name="seedWord5">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_6">
<property name="title">
<string>6</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_9">
<property name="leftMargin">
<number>5</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>5</number>
</property>
<item>
<widget class="QLabel" name="seedWord6">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_7">
<property name="title">
<string>7</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_10">
<property name="leftMargin">
<number>5</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>5</number>
</property>
<item>
<widget class="QLabel" name="seedWord7">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_8">
<property name="title">
<string>8</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_11">
<property name="leftMargin">
<number>5</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>5</number>
</property>
<item>
<widget class="QLabel" name="seedWord8">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_12">
<item>
<widget class="QGroupBox" name="groupBox_9">
<property name="title">
<string>9</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_16">
<property name="leftMargin">
<number>5</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>5</number>
</property>
<item>
<widget class="QLabel" name="seedWord9">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_10">
<property name="title">
<string>10</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_15">
<property name="leftMargin">
<number>5</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>5</number>
</property>
<item>
<widget class="QLabel" name="seedWord10">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_11">
<property name="title">
<string>11</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_14">
<property name="leftMargin">
<number>5</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>5</number>
</property>
<item>
<widget class="QLabel" name="seedWord11">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_12">
<property name="title">
<string>12</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_13">
<property name="leftMargin">
<number>5</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>5</number>
</property>
<item>
<widget class="QLabel" name="seedWord12">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_17">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_18">
<item>
<widget class="QGroupBox" name="groupBox_13">
<property name="title">
<string>13</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_21">
<property name="leftMargin">
<number>5</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>5</number>
</property>
<item>
<widget class="QLabel" name="seedWord13">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_14">
<property name="title">
<string>14</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_20">
<property name="leftMargin">
<number>5</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>5</number>
</property>
<item>
<widget class="QLabel" name="seedWord14">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_19">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string> </string>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size> <size>
<width>16777215</width> <width>20</width>
<height>90</height> <height>0</height>
</size> </size>
</property> </property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="btnRoulette">
<property name="focusPolicy"> <property name="focusPolicy">
<enum>Qt::NoFocus</enum> <enum>Qt::NoFocus</enum>
</property> </property>
<property name="frameShape"> <property name="text">
<enum>QFrame::Box</enum> <string>Generate</string>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="readOnly">
<bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
</layout>
</item>
</layout>
</item>
</layout>
</item>
<item> <item>
<widget class="QLineEdit" name="hiddenMnemonicSeed"> <widget class="QLineEdit" name="hiddenMnemonicSeed">
<property name="focusPolicy"> <property name="focusPolicy">
@ -58,16 +489,6 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item>
<widget class="QPushButton" name="btnRoulette">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string>Generate</string>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
<item> <item>
@ -86,29 +507,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>WARNING:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;style&gt;p{margin:0}&lt;/style&gt;&lt;p&gt;• Never disclose your seed.&lt;/p&gt;&lt;p&gt;• Never type it on a website.&lt;/p&gt;&lt;p&gt;• Store it safely (offline).&lt;/p&gt;&lt;p&gt;• &lt;b&gt;Do not lose your seed!&lt;/b&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item> <item>
<spacer name="verticalSpacer"> <spacer name="verticalSpacer">
<property name="orientation"> <property name="orientation">
@ -124,6 +522,13 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<customwidgets>
<customwidget>
<class>HelpLabel</class>
<extends>QLabel</extends>
<header>components.h</header>
</customwidget>
</customwidgets>
<resources/> <resources/>
<connections/> <connections/>
</ui> </ui>