1
0
mirror of https://github.com/veracrypt/VeraCrypt.git synced 2025-11-11 11:08:02 -06:00

MacOSX: support pasting values to password fields using keyboard (CMD+V and CMD+A now working properly). This make using password managers with VeraCrypt easier.

This commit is contained in:
Mounir IDRASSI
2018-04-29 17:33:33 +02:00
parent 7a842266b3
commit e39f5fa5d6
8 changed files with 107 additions and 0 deletions

View File

@@ -18,6 +18,17 @@
namespace VeraCrypt namespace VeraCrypt
{ {
#ifdef TC_MACOSX
bool ChangePasswordDialog::ProcessEvent(wxEvent& event)
{
if(GraphicUserInterface::HandlePasswordEntryCustomEvent (event))
return true;
else
return ChangePasswordDialogBase::ProcessEvent(event);
}
#endif
ChangePasswordDialog::ChangePasswordDialog (wxWindow* parent, shared_ptr <VolumePath> volumePath, Mode::Enum mode, shared_ptr <VolumePassword> password, shared_ptr <KeyfileList> keyfiles, shared_ptr <VolumePassword> newPassword, shared_ptr <KeyfileList> newKeyfiles) ChangePasswordDialog::ChangePasswordDialog (wxWindow* parent, shared_ptr <VolumePath> volumePath, Mode::Enum mode, shared_ptr <VolumePassword> password, shared_ptr <KeyfileList> keyfiles, shared_ptr <VolumePassword> newPassword, shared_ptr <KeyfileList> newKeyfiles)
: ChangePasswordDialogBase (parent), DialogMode (mode), Path (volumePath) : ChangePasswordDialogBase (parent), DialogMode (mode), Path (volumePath)
{ {
@@ -57,6 +68,10 @@ namespace VeraCrypt
default: default:
throw ParameterIncorrect (SRC_POS); throw ParameterIncorrect (SRC_POS);
} }
#ifdef TC_MACOSX
GraphicUserInterface::InstallPasswordEntryCustomKeyboardShortcuts (this);
#endif
CurrentPasswordPanel = new VolumePasswordPanel (this, NULL, password, false, keyfiles, false, true, true, false, true, true); CurrentPasswordPanel = new VolumePasswordPanel (this, NULL, password, false, keyfiles, false, true, true, false, true, true);
CurrentPasswordPanel->UpdateEvent.Connect (EventConnector <ChangePasswordDialog> (this, &ChangePasswordDialog::OnPasswordPanelUpdate)); CurrentPasswordPanel->UpdateEvent.Connect (EventConnector <ChangePasswordDialog> (this, &ChangePasswordDialog::OnPasswordPanelUpdate));

View File

@@ -35,6 +35,10 @@ namespace VeraCrypt
ChangePasswordDialog (wxWindow* parent, shared_ptr <VolumePath> volumePath, Mode::Enum mode = Mode::ChangePasswordAndKeyfiles, shared_ptr <VolumePassword> password = shared_ptr <VolumePassword> (), shared_ptr <KeyfileList> keyfiles = shared_ptr <KeyfileList> (), shared_ptr <VolumePassword> newPassword = shared_ptr <VolumePassword> (), shared_ptr <KeyfileList> newKeyfiles = shared_ptr <KeyfileList> ()); ChangePasswordDialog (wxWindow* parent, shared_ptr <VolumePath> volumePath, Mode::Enum mode = Mode::ChangePasswordAndKeyfiles, shared_ptr <VolumePassword> password = shared_ptr <VolumePassword> (), shared_ptr <KeyfileList> keyfiles = shared_ptr <KeyfileList> (), shared_ptr <VolumePassword> newPassword = shared_ptr <VolumePassword> (), shared_ptr <KeyfileList> newKeyfiles = shared_ptr <KeyfileList> ());
virtual ~ChangePasswordDialog (); virtual ~ChangePasswordDialog ();
#ifdef TC_MACOSX
virtual bool ProcessEvent(wxEvent& event);
#endif
protected: protected:
void OnOKButtonClick (wxCommandEvent& event); void OnOKButtonClick (wxCommandEvent& event);

View File

@@ -17,6 +17,17 @@
namespace VeraCrypt namespace VeraCrypt
{ {
#ifdef TC_MACOSX
bool MountOptionsDialog::ProcessEvent(wxEvent& event)
{
if(GraphicUserInterface::HandlePasswordEntryCustomEvent (event))
return true;
else
return MountOptionsDialogBase::ProcessEvent(event);
}
#endif
MountOptionsDialog::MountOptionsDialog (wxWindow *parent, MountOptions &options, const wxString &title, bool disableMountOptions) MountOptionsDialog::MountOptionsDialog (wxWindow *parent, MountOptions &options, const wxString &title, bool disableMountOptions)
: MountOptionsDialogBase (parent, wxID_ANY, wxString() : MountOptionsDialogBase (parent, wxID_ANY, wxString()
#ifdef __WXGTK__ // GTK apparently needs wxRESIZE_BORDER to support dynamic resizing #ifdef __WXGTK__ // GTK apparently needs wxRESIZE_BORDER to support dynamic resizing
@@ -33,6 +44,11 @@ namespace VeraCrypt
if (disableMountOptions) if (disableMountOptions)
OptionsButton->Show (false); OptionsButton->Show (false);
#ifdef TC_MACOSX
GraphicUserInterface::InstallPasswordEntryCustomKeyboardShortcuts (this);
#endif
PasswordPanel = new VolumePasswordPanel (this, &options, options.Password, disableMountOptions, options.Keyfiles, !disableMountOptions, true, true, false, true, true); PasswordPanel = new VolumePasswordPanel (this, &options, options.Password, disableMountOptions, options.Keyfiles, !disableMountOptions, true, true, false, true, true);
PasswordPanel->SetCacheCheckBoxValidator (wxGenericValidator (&Options.CachePassword)); PasswordPanel->SetCacheCheckBoxValidator (wxGenericValidator (&Options.CachePassword));

View File

@@ -24,6 +24,10 @@ namespace VeraCrypt
public: public:
MountOptionsDialog (wxWindow* parent, MountOptions &options, const wxString &title = wxEmptyString, bool disableMountOptions = false); MountOptionsDialog (wxWindow* parent, MountOptions &options, const wxString &title = wxEmptyString, bool disableMountOptions = false);
void OnShow (); void OnShow ();
#ifdef TC_MACOSX
virtual bool ProcessEvent(wxEvent& event);
#endif
protected: protected:
void OnInitDialog (wxInitDialogEvent& event); void OnInitDialog (wxInitDialogEvent& event);

View File

@@ -36,6 +36,17 @@
namespace VeraCrypt namespace VeraCrypt
{ {
#ifdef TC_MACOSX
bool VolumeCreationWizard::ProcessEvent(wxEvent& event)
{
if(GraphicUserInterface::HandlePasswordEntryCustomEvent (event))
return true;
else
return WizardFrame::ProcessEvent(event);
}
#endif
VolumeCreationWizard::VolumeCreationWizard (wxWindow* parent) VolumeCreationWizard::VolumeCreationWizard (wxWindow* parent)
: WizardFrame (parent), : WizardFrame (parent),
CrossPlatformSupport (true), CrossPlatformSupport (true),
@@ -55,6 +66,10 @@ namespace VeraCrypt
SetTitle (LangString["INTRO_TITLE"]); SetTitle (LangString["INTRO_TITLE"]);
SetImage (Resources::GetVolumeCreationWizardBitmap (Gui->GetCharHeight (this) * 21)); SetImage (Resources::GetVolumeCreationWizardBitmap (Gui->GetCharHeight (this) * 21));
SetMaxStaticTextWidth (55); SetMaxStaticTextWidth (55);
#ifdef TC_MACOSX
GraphicUserInterface::InstallPasswordEntryCustomKeyboardShortcuts (this);
#endif
SetStep (Step::VolumeHostType); SetStep (Step::VolumeHostType);

View File

@@ -24,6 +24,10 @@ namespace VeraCrypt
VolumeCreationWizard (wxWindow* parent); VolumeCreationWizard (wxWindow* parent);
~VolumeCreationWizard (); ~VolumeCreationWizard ();
#ifdef TC_MACOSX
virtual bool ProcessEvent(wxEvent& event);
#endif
protected: protected:
struct Step struct Step
{ {

View File

@@ -37,6 +37,11 @@
namespace VeraCrypt namespace VeraCrypt
{ {
#ifdef TC_MACOSX
int GraphicUserInterface::g_customIdCmdV = 0;
int GraphicUserInterface::g_customIdCmdA = 0;
#endif
GraphicUserInterface::GraphicUserInterface () : GraphicUserInterface::GraphicUserInterface () :
ActiveFrame (nullptr), ActiveFrame (nullptr),
BackgroundMode (false), BackgroundMode (false),
@@ -51,6 +56,8 @@ namespace VeraCrypt
#endif #endif
#ifdef TC_MACOSX #ifdef TC_MACOSX
g_customIdCmdV = wxNewId();
g_customIdCmdA = wxNewId();
wxApp::s_macHelpMenuTitleName = _("&Help"); wxApp::s_macHelpMenuTitleName = _("&Help");
#endif #endif
} }
@@ -657,6 +664,41 @@ namespace VeraCrypt
{ {
SetBackgroundMode (false); SetBackgroundMode (false);
} }
bool GraphicUserInterface::HandlePasswordEntryCustomEvent (wxEvent& event)
{
bool bHandled = false;
if ( (event.GetEventType() == wxEVT_MENU)
&& ((event.GetId() == g_customIdCmdV) || (event.GetId() == g_customIdCmdA)))
{
wxWindow* focusedCtrl = wxWindow::FindFocus();
if (focusedCtrl
&& (focusedCtrl->IsKindOf(wxCLASSINFO(wxTextCtrl)))
&& (focusedCtrl->GetWindowStyle() & wxTE_PASSWORD))
{
wxTextCtrl* passwordCtrl = (wxTextCtrl*) focusedCtrl;
if (event.GetId() == g_customIdCmdV)
passwordCtrl->Paste ();
else if (event.GetId() == g_customIdCmdA)
passwordCtrl->SelectAll ();
bHandled = true;
}
}
return bHandled;
}
void GraphicUserInterface::InstallPasswordEntryCustomKeyboardShortcuts (wxWindow* window)
{
// we manually handle CMD+V and CMD+A on password fields in order to support
// pasting password values into them. By default, wxWidgets doesn't handle this
// for password entry fields.
wxAcceleratorEntry entries[2];
entries[0].Set(wxACCEL_CMD, (int) 'V', g_customIdCmdV);
entries[1].Set(wxACCEL_CMD, (int) 'A', g_customIdCmdA);
wxAcceleratorTable accel(sizeof(entries) / sizeof(wxAcceleratorEntry), entries);
window->SetAcceleratorTable(accel);
}
#endif #endif
void GraphicUserInterface::MoveListCtrlItem (wxListCtrl *listCtrl, long itemIndex, long newItemIndex) const void GraphicUserInterface::MoveListCtrlItem (wxListCtrl *listCtrl, long itemIndex, long newItemIndex) const

View File

@@ -100,6 +100,8 @@ namespace VeraCrypt
#ifdef TC_MACOSX #ifdef TC_MACOSX
virtual void MacOpenFiles (const wxArrayString &fileNames); virtual void MacOpenFiles (const wxArrayString &fileNames);
virtual void MacReopenApp (); virtual void MacReopenApp ();
static bool HandlePasswordEntryCustomEvent (wxEvent& event);
static void InstallPasswordEntryCustomKeyboardShortcuts (wxWindow* window);
#endif #endif
template <class T> template <class T>
@@ -133,6 +135,11 @@ namespace VeraCrypt
auto_ptr <wxSingleInstanceChecker> SingleInstanceChecker; auto_ptr <wxSingleInstanceChecker> SingleInstanceChecker;
mutable WaitDialog* mWaitDialog; mutable WaitDialog* mWaitDialog;
public:
#ifdef TC_MACOSX
static int g_customIdCmdV;
static int g_customIdCmdA;
#endif
private: private:
GraphicUserInterface (const GraphicUserInterface &); GraphicUserInterface (const GraphicUserInterface &);