[ui] Add toggle for unblinding password fields

This commit is contained in:
Thomas Snider 2017-10-10 21:50:01 -07:00
parent 5a9da37fb3
commit ff35de8f03
3 changed files with 18 additions and 0 deletions

View file

@ -70,6 +70,7 @@ AskPassphraseDialog::AskPassphraseDialog(Mode _mode, QWidget *parent) :
break; break;
} }
textChanged(); textChanged();
connect(ui->toggleShowPasswordButton, SIGNAL(toggled(bool)), this, SLOT(toggleShowPassword(bool)));
connect(ui->passEdit1, SIGNAL(textChanged(QString)), this, SLOT(textChanged())); connect(ui->passEdit1, SIGNAL(textChanged(QString)), this, SLOT(textChanged()));
connect(ui->passEdit2, SIGNAL(textChanged(QString)), this, SLOT(textChanged())); connect(ui->passEdit2, SIGNAL(textChanged(QString)), this, SLOT(textChanged()));
connect(ui->passEdit3, SIGNAL(textChanged(QString)), this, SLOT(textChanged())); connect(ui->passEdit3, SIGNAL(textChanged(QString)), this, SLOT(textChanged()));
@ -234,6 +235,15 @@ bool AskPassphraseDialog::event(QEvent *event)
return QWidget::event(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) bool AskPassphraseDialog::eventFilter(QObject *object, QEvent *event)
{ {
/* Detect Caps Lock. /* Detect Caps Lock.

View file

@ -43,6 +43,7 @@ private:
private Q_SLOTS: private Q_SLOTS:
void textChanged(); void textChanged();
void secureClearPassFields(); void secureClearPassFields();
void toggleShowPassword(bool);
protected: protected:
bool event(QEvent *event); bool event(QEvent *event);

View file

@ -93,6 +93,13 @@
</widget> </widget>
</item> </item>
<item row="3" column="1"> <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"> <widget class="QLabel" name="capsLabel">
<property name="font"> <property name="font">
<font> <font>