Skip to content

Commit 5bff825

Browse files
committed
[gui] create wallet: smarter checkbox toggling
1 parent 42b66a6 commit 5bff825

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

src/qt/createwalletdialog.cpp

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,28 @@ CreateWalletDialog::CreateWalletDialog(QWidget* parent) :
3535
}
3636
});
3737

38-
#ifndef USE_SQLITE
39-
ui->descriptor_checkbox->setToolTip(tr("Compiled without sqlite support (required for descriptor wallets)"));
40-
ui->descriptor_checkbox->setEnabled(false);
41-
ui->descriptor_checkbox->setChecked(false);
42-
#endif
38+
connect(ui->disable_privkeys_checkbox, &QCheckBox::toggled, [this](bool checked) {
39+
// Disable the encrypt_wallet_checkbox when isDisablePrivateKeysChecked is
40+
// set to true, enable it when isDisablePrivateKeysChecked is false.
41+
ui->encrypt_wallet_checkbox->setEnabled(!checked);
42+
43+
// Wallets without private keys start out blank
44+
if (checked) {
45+
ui->blank_wallet_checkbox->setChecked(true);
46+
}
47+
48+
// When the encrypt_wallet_checkbox is disabled, uncheck it.
49+
if (!ui->encrypt_wallet_checkbox->isEnabled()) {
50+
ui->encrypt_wallet_checkbox->setChecked(false);
51+
}
52+
});
53+
54+
#ifndef USE_SQLITE
55+
ui->descriptor_checkbox->setToolTip(tr("Compiled without sqlite support (required for descriptor wallets)"));
56+
ui->descriptor_checkbox->setEnabled(false);
57+
ui->descriptor_checkbox->setChecked(false);
58+
#endif
59+
4360
}
4461

4562
CreateWalletDialog::~CreateWalletDialog()

src/qt/forms/createwalletdialog.ui

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@
6868
<string>Encrypt Wallet</string>
6969
</property>
7070
<property name="checked">
71-
<bool>true</bool>
71+
<bool>false</bool>
7272
</property>
7373
</widget>
7474
<widget class="QCheckBox" name="disable_privkeys_checkbox">
7575
<property name="enabled">
76-
<bool>false</bool>
76+
<bool>true</bool>
7777
</property>
7878
<property name="geometry">
7979
<rect>

0 commit comments

Comments
 (0)