diff options
author | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2015-09-13 23:49:08 +0200 |
---|---|---|
committer | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2015-09-13 23:51:06 +0200 |
commit | 24f3b5230cc1ea7e6fb084294f04df10ede17e2f (patch) | |
tree | b2efe5d7522a31c7c6cd21db2fcf9af38a4ca6c5 /src/Main/Forms/VolumePasswordPanel.cpp | |
parent | 7e73208e62b441f836f27433a4e297a0e07233b8 (diff) | |
download | VeraCrypt-24f3b5230cc1ea7e6fb084294f04df10ede17e2f.tar.gz VeraCrypt-24f3b5230cc1ea7e6fb084294f04df10ede17e2f.zip |
Linux/MacOSX: Mask/unmask PIM value in GUI the same way as the password
Diffstat (limited to 'src/Main/Forms/VolumePasswordPanel.cpp')
-rw-r--r-- | src/Main/Forms/VolumePasswordPanel.cpp | 39 |
1 files changed, 29 insertions, 10 deletions
diff --git a/src/Main/Forms/VolumePasswordPanel.cpp b/src/Main/Forms/VolumePasswordPanel.cpp index 8d4639bf..03134535 100644 --- a/src/Main/Forms/VolumePasswordPanel.cpp +++ b/src/Main/Forms/VolumePasswordPanel.cpp @@ -66,10 +66,7 @@ namespace VeraCrypt VolumePimTextCtrl->Show (false); VolumePimHelpStaticText->Show (false); - wxTextValidator validator (wxFILTER_INCLUDE_CHAR_LIST); // wxFILTER_NUMERIC does not exclude - . , etc. - const wxChar *valArr[] = { L"0", L"1", L"2", L"3", L"4", L"5", L"6", L"7", L"8", L"9" }; - validator.SetIncludes (wxArrayString (array_capacity (valArr), (const wxChar **) &valArr)); - VolumePimTextCtrl->SetValidator (validator); + SetPimValidator (); ConfirmPasswordStaticText->Show (enableConfirmation); ConfirmPasswordTextCtrl->Show (enableConfirmation); @@ -186,17 +183,27 @@ namespace VeraCrypt UseKeyfilesCheckBox->SetValue (true); } + void VolumePasswordPanel::SetPimValidator () + { + wxTextValidator validator (wxFILTER_INCLUDE_CHAR_LIST); // wxFILTER_NUMERIC does not exclude - . , etc. + const wxChar *valArr[] = { L"0", L"1", L"2", L"3", L"4", L"5", L"6", L"7", L"8", L"9" }; + validator.SetIncludes (wxArrayString (array_capacity (valArr), (const wxChar **) &valArr)); + VolumePimTextCtrl->SetValidator (validator); + } + void VolumePasswordPanel::DisplayPassword (bool display, wxTextCtrl **textCtrl, int row) { FreezeScope freeze (this); + bool isPim = (*textCtrl == VolumePimTextCtrl); + int colspan = isPim? 1 : 2; wxTextCtrl *newTextCtrl = new wxTextCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, display ? 0 : wxTE_PASSWORD); - newTextCtrl->SetMaxLength (VolumePassword::MaxSize); + newTextCtrl->SetMaxLength (isPim? 10 : VolumePassword::MaxSize); newTextCtrl->SetValue ((*textCtrl)->GetValue()); newTextCtrl->SetMinSize ((*textCtrl)->GetSize()); GridBagSizer->Detach ((*textCtrl)); - GridBagSizer->Add (newTextCtrl, wxGBPosition (row, 1), wxGBSpan (1, 2), wxEXPAND|wxBOTTOM|wxALIGN_CENTER_VERTICAL, 5); + GridBagSizer->Add (newTextCtrl, wxGBPosition (row, 1), wxGBSpan (1, colspan), wxEXPAND|wxBOTTOM|wxALIGN_CENTER_VERTICAL, 5); (*textCtrl)->Show (false); WipeTextCtrl (*textCtrl); @@ -204,8 +211,11 @@ namespace VeraCrypt Layout(); newTextCtrl->SetMinSize ((*textCtrl)->GetMinSize()); - newTextCtrl->Connect (wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler (VolumePasswordPanel::OnTextChanged), nullptr, this); + newTextCtrl->Connect (wxEVT_COMMAND_TEXT_UPDATED, isPim? wxCommandEventHandler (VolumePasswordPanel::OnPimChanged): wxCommandEventHandler (VolumePasswordPanel::OnTextChanged), nullptr, this); + delete *textCtrl; *textCtrl = newTextCtrl; + if (isPim) + SetPimValidator (); } shared_ptr <VolumePassword> VolumePasswordPanel::GetPassword () const @@ -369,6 +379,9 @@ namespace VeraCrypt if (ConfirmPasswordTextCtrl->IsShown()) DisplayPassword (event.IsChecked(), &ConfirmPasswordTextCtrl, 2); + + if (VolumePimTextCtrl->IsShown()) + DisplayPassword (event.IsChecked(), &VolumePimTextCtrl, 3); OnUpdate(); } @@ -449,9 +462,15 @@ namespace VeraCrypt VolumePimStaticText->Show (true); VolumePimTextCtrl->Show (true); VolumePimHelpStaticText->Show (true); - - Layout(); - Fit(); + + if (DisplayPasswordCheckBox->IsChecked ()) + DisplayPassword (true, &VolumePimTextCtrl, 3); + else + { + Layout(); + Fit(); + } + GetParent()->Layout(); GetParent()->Fit(); } |