Skip to content

Commit ffc0b11

Browse files
committed
Merge #11480: [ui] Add toggle for unblinding password fields
ff35de8 [ui] Add toggle for unblinding password fields (Thomas Snider) Pull request description: Proposed change for adding the ability to toggle password visibility in the password dialog. This is similar to functionality in most password managers and is specifically added with the use case of password managers in mind - the password in that case is likely pasted twice into both the new password and confirm password fields. If this is a welcome change, I am open to suggestions on rearranging the layout. Tree-SHA512: 1823f356f8f941cc584c44de264433e9a573cb8a358efa300a412c4458b5564d8d193969be40859195cf9c8d6768eee895ee22440d51db4f09175f9b4e28bced
2 parents 0e70791 + ff35de8 commit ffc0b11

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

src/qt/askpassphrasedialog.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ AskPassphraseDialog::AskPassphraseDialog(Mode _mode, QWidget *parent) :
7070
break;
7171
}
7272
textChanged();
73+
connect(ui->toggleShowPasswordButton, SIGNAL(toggled(bool)), this, SLOT(toggleShowPassword(bool)));
7374
connect(ui->passEdit1, SIGNAL(textChanged(QString)), this, SLOT(textChanged()));
7475
connect(ui->passEdit2, SIGNAL(textChanged(QString)), this, SLOT(textChanged()));
7576
connect(ui->passEdit3, SIGNAL(textChanged(QString)), this, SLOT(textChanged()));
@@ -234,6 +235,15 @@ bool AskPassphraseDialog::event(QEvent *event)
234235
return QWidget::event(event);
235236
}
236237

238+
void AskPassphraseDialog::toggleShowPassword(bool show)
239+
{
240+
ui->toggleShowPasswordButton->setDown(show);
241+
const auto mode = show ? QLineEdit::Normal : QLineEdit::Password;
242+
ui->passEdit1->setEchoMode(mode);
243+
ui->passEdit2->setEchoMode(mode);
244+
ui->passEdit3->setEchoMode(mode);
245+
}
246+
237247
bool AskPassphraseDialog::eventFilter(QObject *object, QEvent *event)
238248
{
239249
/* Detect Caps Lock.

src/qt/askpassphrasedialog.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class AskPassphraseDialog : public QDialog
4343
private Q_SLOTS:
4444
void textChanged();
4545
void secureClearPassFields();
46+
void toggleShowPassword(bool);
4647

4748
protected:
4849
bool event(QEvent *event);

src/qt/forms/askpassphrasedialog.ui

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,13 @@
9393
</widget>
9494
</item>
9595
<item row="3" column="1">
96+
<widget class="QCheckBox" name="toggleShowPasswordButton">
97+
<property name="text">
98+
<string>Show password</string>
99+
</property>
100+
</widget>
101+
</item>
102+
<item row="4" column="1">
96103
<widget class="QLabel" name="capsLabel">
97104
<property name="font">
98105
<font>

0 commit comments

Comments
 (0)