Bitcoin Core  21.99.0
P2P Digital Currency
createwalletdialog.cpp
Go to the documentation of this file.
1 // Copyright (c) 2019-2020 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #if defined(HAVE_CONFIG_H)
7 #endif
8 
10 #include <qt/forms/ui_createwalletdialog.h>
11 
12 #include <qt/guiutil.h>
13 
14 #include <QPushButton>
15 
17  QDialog(parent, GUIUtil::dialog_flags),
18  ui(new Ui::CreateWalletDialog)
19 {
20  ui->setupUi(this);
21  ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Create"));
22  ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
23  ui->wallet_name_line_edit->setFocus(Qt::ActiveWindowFocusReason);
24 
25  connect(ui->wallet_name_line_edit, &QLineEdit::textEdited, [this](const QString& text) {
26  ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!text.isEmpty());
27  });
28 
29  connect(ui->encrypt_wallet_checkbox, &QCheckBox::toggled, [this](bool checked) {
30  // Disable the disable_privkeys_checkbox when isEncryptWalletChecked is
31  // set to true, enable it when isEncryptWalletChecked is false.
32  ui->disable_privkeys_checkbox->setEnabled(!checked);
33 
34  // When the disable_privkeys_checkbox is disabled, uncheck it.
35  if (!ui->disable_privkeys_checkbox->isEnabled()) {
36  ui->disable_privkeys_checkbox->setChecked(false);
37  }
38  });
39 
40  connect(ui->disable_privkeys_checkbox, &QCheckBox::toggled, [this](bool checked) {
41  // Disable the encrypt_wallet_checkbox when isDisablePrivateKeysChecked is
42  // set to true, enable it when isDisablePrivateKeysChecked is false.
43  ui->encrypt_wallet_checkbox->setEnabled(!checked);
44 
45  // Wallets without private keys start out blank
46  if (checked) {
47  ui->blank_wallet_checkbox->setChecked(true);
48  }
49 
50  // When the encrypt_wallet_checkbox is disabled, uncheck it.
51  if (!ui->encrypt_wallet_checkbox->isEnabled()) {
52  ui->encrypt_wallet_checkbox->setChecked(false);
53  }
54  });
55 
56  connect(ui->blank_wallet_checkbox, &QCheckBox::toggled, [this](bool checked) {
57  if (!checked) {
58  ui->disable_privkeys_checkbox->setChecked(false);
59  }
60  });
61 
62 #ifndef USE_SQLITE
63  ui->descriptor_checkbox->setToolTip(tr("Compiled without sqlite support (required for descriptor wallets)"));
64  ui->descriptor_checkbox->setEnabled(false);
65  ui->descriptor_checkbox->setChecked(false);
66 #endif
67 #ifndef USE_BDB
68  ui->descriptor_checkbox->setEnabled(false);
69  ui->descriptor_checkbox->setChecked(true);
70 #endif
71 }
72 
74 {
75  delete ui;
76 }
77 
79 {
80  return ui->wallet_name_line_edit->text();
81 }
82 
84 {
85  return ui->encrypt_wallet_checkbox->isChecked();
86 }
87 
89 {
90  return ui->disable_privkeys_checkbox->isChecked();
91 }
92 
94 {
95  return ui->blank_wallet_checkbox->isChecked();
96 }
97 
99 {
100  return ui->descriptor_checkbox->isChecked();
101 }
CreateWalletDialog::isMakeBlankWalletChecked
bool isMakeBlankWalletChecked() const
Definition: createwalletdialog.cpp:93
CreateWalletDialog::isDisablePrivateKeysChecked
bool isDisablePrivateKeysChecked() const
Definition: createwalletdialog.cpp:88
GUIUtil
Utility functions used by the Bitcoin Qt UI.
Definition: bitcoingui.h:58
bitcoin-config.h
GUIUtil::dialog_flags
constexpr auto dialog_flags
Definition: guiutil.h:56
CreateWalletDialog::isEncryptWalletChecked
bool isEncryptWalletChecked() const
Definition: createwalletdialog.cpp:83
createwalletdialog.h
guiutil.h
CreateWalletDialog::ui
Ui::CreateWalletDialog * ui
Definition: createwalletdialog.h:33
Ui
Definition: addressbookpage.h:14
CreateWalletDialog
Dialog for creating wallets.
Definition: createwalletdialog.h:18
CreateWalletDialog::isDescriptorWalletChecked
bool isDescriptorWalletChecked() const
Definition: createwalletdialog.cpp:98
CreateWalletDialog::~CreateWalletDialog
virtual ~CreateWalletDialog()
Definition: createwalletdialog.cpp:73
if
if(expired !=0)
Definition: validation.cpp:350
CreateWalletDialog::walletName
QString walletName() const
Definition: createwalletdialog.cpp:78
CreateWalletDialog::CreateWalletDialog
CreateWalletDialog(QWidget *parent)
Definition: createwalletdialog.cpp:16