Wizard: copy seed to clipboard

remotes/1691844314220217825/master
tobtoht 3 years ago
parent c379456221
commit 3d47b453a8
Signed by untrusted user: tobtoht
GPG Key ID: 1CADD27F41F45C3C

@ -27,26 +27,36 @@ CreateWalletSeedPage::CreateWalletSeedPage(AppContext *ctx, QWidget *parent) :
connect(ui->btnRoulette, &QPushButton::clicked, [=]{
this->seedRoulette(0);
});
connect(ui->btnCopy, &QPushButton::clicked, [this]{
Utils::copyToClipboard(m_mnemonic);
});
this->setButtonText(QWizard::FinishButton, "Create/Open wallet");
}
// generate new seed
this->seedRoulette(m_rouletteSpin - 1);
void CreateWalletSeedPage::initializePage() {
this->generateSeed();
}
void CreateWalletSeedPage::seedRoulette(int count) {
count += 1;
if(count > m_rouletteSpin) return;
FeatherSeed seed = FeatherSeed(m_ctx->restoreHeights[m_ctx->networkType], m_ctx->coinName, m_ctx->seedLanguage);
m_mnemonic = seed.mnemonic.join(" ");
m_restoreHeight = seed.restoreHeight;
if (count > m_rouletteSpin)
return;
this->generateSeed();
this->displaySeed(m_mnemonic);
QTimer::singleShot(10, [=] {
this->seedRoulette(count);
});
}
void CreateWalletSeedPage::generateSeed() {
FeatherSeed seed = FeatherSeed(m_ctx->restoreHeights[m_ctx->networkType], m_ctx->coinName, m_ctx->seedLanguage);
m_mnemonic = seed.mnemonic.join(" ");
m_restoreHeight = seed.restoreHeight;
this->displaySeed(m_mnemonic);
}
void CreateWalletSeedPage::displaySeed(const QString &seed){
QStringList seedSplit = seed.split(" ");

@ -21,6 +21,7 @@ class CreateWalletSeedPage : public QWizardPage
public:
explicit CreateWalletSeedPage(AppContext *ctx, QWidget *parent = nullptr);
void initializePage() override;
bool validatePage() override;
int nextId() const override;
@ -29,6 +30,7 @@ public slots:
private:
void seedRoulette(int count);
void generateSeed();
signals:
void createWallet();

@ -7,13 +7,21 @@
<x>0</x>
<y>0</y>
<width>775</width>
<height>571</height>
<height>529</height>
</rect>
</property>
<property name="windowTitle">
<string>WizardPage</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="topMargin">
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>2</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
@ -427,30 +435,43 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_19">
<item>
<widget class="QLabel" name="label_2">
<widget class="QLabel" name="label">
<property name="text">
<string> </string>
<string/>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="verticalSpacer_2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="btnCopy">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string>Copy</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnRoulette">
<property name="focusPolicy">
@ -463,10 +484,6 @@
</item>
</layout>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QLineEdit" name="hiddenMnemonicSeed">
<property name="focusPolicy">
@ -474,23 +491,6 @@
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="sizePolicy">
@ -500,7 +500,7 @@
</sizepolicy>
</property>
<property name="text">
<string>Please save these 14 words on paper (order is important). This seed will allow you to recover your wallet in case of computer failure.</string>
<string>Please save these 14 words on paper. This seed will allow you to recover your wallet in case of computer failure.</string>
</property>
<property name="wordWrap">
<bool>true</bool>

Loading…
Cancel
Save