Skip to content

Commit

Permalink
Merge pull request bitcoin#15 from lateminer/show-password
Browse files Browse the repository at this point in the history
[ui] Add toggle for unblinding password fields
  • Loading branch information
janko33bd authored Jan 6, 2018
2 parents c71b057 + 3b0604b commit de1a0db
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/qt/askpassphrasedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ AskPassphraseDialog::AskPassphraseDialog(Mode mode, QWidget *parent) :
break;
}
textChanged();
connect(ui->toggleShowPasswordButton, SIGNAL(toggled(bool)), this, SLOT(toggleShowPassword(bool)));
connect(ui->passEdit1, SIGNAL(textChanged(QString)), this, SLOT(textChanged()));
connect(ui->passEdit2, SIGNAL(textChanged(QString)), this, SLOT(textChanged()));
connect(ui->passEdit3, SIGNAL(textChanged(QString)), this, SLOT(textChanged()));
Expand Down Expand Up @@ -237,6 +238,15 @@ bool AskPassphraseDialog::event(QEvent *event)
return QWidget::event(event);
}

void AskPassphraseDialog::toggleShowPassword(bool show)
{
ui->toggleShowPasswordButton->setDown(show);
const auto mode = show ? QLineEdit::Normal : QLineEdit::Password;
ui->passEdit1->setEchoMode(mode);
ui->passEdit2->setEchoMode(mode);
ui->passEdit3->setEchoMode(mode);
}

bool AskPassphraseDialog::eventFilter(QObject *object, QEvent *event)
{
/* Detect Caps Lock.
Expand Down
1 change: 1 addition & 0 deletions src/qt/askpassphrasedialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class AskPassphraseDialog : public QDialog
private Q_SLOTS:
void textChanged();
void secureClearPassFields();
void toggleShowPassword(bool);

protected:
bool event(QEvent *event);
Expand Down
7 changes: 7 additions & 0 deletions src/qt/forms/askpassphrasedialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@
</widget>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="toggleShowPasswordButton">
<property name="text">
<string>Show password</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="capsLabel">
<property name="font">
<font>
Expand Down

0 comments on commit de1a0db

Please sign in to comment.