diff --git a/contrib/bitcoin-qt.pro b/contrib/bitcoin-qt.pro --- a/contrib/bitcoin-qt.pro +++ b/contrib/bitcoin-qt.pro @@ -16,6 +16,7 @@ ../src/qt/forms/sendcoinsentry.ui \ ../src/qt/forms/signverifymessagedialog.ui \ ../src/qt/forms/transactiondescdialog.ui \ + ../src/qt/forms/createwalletdialog.ui RESOURCES += \ ../src/qt/bitcoin.qrc diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -98,6 +98,7 @@ qt/forms/addressbookpage.ui \ qt/forms/askpassphrasedialog.ui \ qt/forms/coincontroldialog.ui \ + qt/forms/createwalletdialog.ui \ qt/forms/editaddressdialog.ui \ qt/forms/helpmessagedialog.ui \ qt/forms/intro.ui \ @@ -117,6 +118,7 @@ qt/moc_addressbookpage.cpp \ qt/moc_addresstablemodel.cpp \ qt/moc_askpassphrasedialog.cpp \ + qt/moc_createwalletdialog.cpp \ qt/moc_bantablemodel.cpp \ qt/moc_bitcoinaddressvalidator.cpp \ qt/moc_bitcoinamountfield.cpp \ @@ -200,6 +202,7 @@ qt/clientmodel.h \ qt/coincontroldialog.h \ qt/coincontroltreewidget.h \ + qt/createwalletdialog.h \ qt/csvmodelwriter.h \ qt/editaddressdialog.h \ qt/guiconstants.h \ @@ -334,6 +337,7 @@ qt/askpassphrasedialog.cpp \ qt/coincontroldialog.cpp \ qt/coincontroltreewidget.cpp \ + qt/createwalletdialog.cpp \ qt/editaddressdialog.cpp \ qt/openuridialog.cpp \ qt/overviewpage.cpp \ diff --git a/src/qt/CMakeLists.txt b/src/qt/CMakeLists.txt --- a/src/qt/CMakeLists.txt +++ b/src/qt/CMakeLists.txt @@ -56,6 +56,7 @@ forms/addressbookpage.ui forms/askpassphrasedialog.ui forms/coincontroldialog.ui + forms/createwalletdialog.ui forms/editaddressdialog.ui forms/helpmessagedialog.ui forms/intro.ui @@ -290,6 +291,7 @@ askpassphrasedialog.cpp coincontroldialog.cpp coincontroltreewidget.cpp + createwalletdialog.cpp editaddressdialog.cpp openuridialog.cpp overviewpage.cpp diff --git a/src/qt/createwalletdialog.h b/src/qt/createwalletdialog.h new file mode 100644 --- /dev/null +++ b/src/qt/createwalletdialog.h @@ -0,0 +1,35 @@ +// Copyright (c) 2019 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_QT_CREATEWALLETDIALOG_H +#define BITCOIN_QT_CREATEWALLETDIALOG_H + +#include + +class WalletModel; + +namespace Ui { +class CreateWalletDialog; +} + +/** + * Dialog for creating wallets + */ +class CreateWalletDialog : public QDialog { + Q_OBJECT + +public: + explicit CreateWalletDialog(QWidget *parent); + virtual ~CreateWalletDialog(); + + QString walletName() const; + bool encrypt() const; + bool disablePrivateKeys() const; + bool blank() const; + +private: + Ui::CreateWalletDialog *ui; +}; + +#endif // BITCOIN_QT_CREATEWALLETDIALOG_H diff --git a/src/qt/createwalletdialog.cpp b/src/qt/createwalletdialog.cpp new file mode 100644 --- /dev/null +++ b/src/qt/createwalletdialog.cpp @@ -0,0 +1,58 @@ +// Copyright (c) 2019 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#if defined(HAVE_CONFIG_H) +#include +#endif + +#include +#include + +#include + +CreateWalletDialog::CreateWalletDialog(QWidget *parent) + : QDialog(parent), ui(new Ui::CreateWalletDialog) { + ui->setupUi(this); + ui->buttonBox->button(QDialogButtonBox::Ok)->setText("Create"); + ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); + ui->wallet_name_line_edit->setFocus(Qt::ActiveWindowFocusReason); + + connect(ui->wallet_name_line_edit, &QLineEdit::textEdited, + [this](const QString &text) { + ui->buttonBox->button(QDialogButtonBox::Ok) + ->setEnabled(!text.isEmpty()); + }); + + connect(ui->encrypt_wallet_checkbox, &QCheckBox::toggled, + [this](bool checked) { + // Disable disable_privkeys_checkbox when encrypt is set to + // true, enable it when encrypt is false + ui->disable_privkeys_checkbox->setEnabled(!checked); + + // When the disable_privkeys_checkbox is disabled, uncheck it. + if (!ui->disable_privkeys_checkbox->isEnabled()) { + ui->disable_privkeys_checkbox->setChecked(false); + } + }); +} + +CreateWalletDialog::~CreateWalletDialog() { + delete ui; +} + +QString CreateWalletDialog::walletName() const { + return ui->wallet_name_line_edit->text(); +} + +bool CreateWalletDialog::encrypt() const { + return ui->encrypt_wallet_checkbox->isChecked(); +} + +bool CreateWalletDialog::disablePrivateKeys() const { + return ui->disable_privkeys_checkbox->isChecked(); +} + +bool CreateWalletDialog::blank() const { + return ui->blank_wallet_checkbox->isChecked(); +} diff --git a/src/qt/forms/createwalletdialog.ui b/src/qt/forms/createwalletdialog.ui new file mode 100644 --- /dev/null +++ b/src/qt/forms/createwalletdialog.ui @@ -0,0 +1,151 @@ + + + CreateWalletDialog + + + + 0 + 0 + 364 + 185 + + + + Create Wallet + + + + + 10 + 140 + 341 + 32 + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + 120 + 20 + 231 + 24 + + + + + + + 20 + 20 + 101 + 21 + + + + Wallet Name + + + + + + 20 + 50 + 171 + 22 + + + + Encrypt the wallet. The wallet will be encrypted with a password of your choice. + + + Encrypt Wallet + + + true + + + + + false + + + + 20 + 80 + 171 + 22 + + + + Disable private keys for this wallet. Wallets with private keys disabled will have no private keys and cannot have an HD seed or imported private keys. This is ideal for watch-only wallets. + + + Disable Private Keys + + + + + + 20 + 110 + 171 + 22 + + + + Make a blank wallet. Blank wallets do not initially have private keys or scripts. Private keys and addresses can be imported, or an HD seed can be set, at a later time. + + + Make Blank Wallet + + + + + wallet_name_line_edit + encrypt_wallet_checkbox + disable_privkeys_checkbox + blank_wallet_checkbox + + + + + buttonBox + accepted() + CreateWalletDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + CreateWalletDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + +