diff options
Diffstat (limited to 'src/Main/Forms/PreferencesDialog.cpp')
-rw-r--r-- | src/Main/Forms/PreferencesDialog.cpp | 80 |
1 files changed, 67 insertions, 13 deletions
diff --git a/src/Main/Forms/PreferencesDialog.cpp b/src/Main/Forms/PreferencesDialog.cpp index e2b4f626..90a668e6 100644 --- a/src/Main/Forms/PreferencesDialog.cpp +++ b/src/Main/Forms/PreferencesDialog.cpp @@ -14,6 +14,9 @@ #include <wx/dynlib.h> #ifdef TC_WINDOWS #include <wx/msw/registry.h> +#else +#include <wx/dir.h> +#include <wx/arrstr.h> #endif #include "Common/SecurityToken.h" #include "Main/Main.h" @@ -53,12 +56,10 @@ namespace VeraCrypt FilesystemOptionsTextCtrl->SetValue (Preferences.DefaultMountOptions.FilesystemOptions); - TrueCryptModeCheckBox->SetValidator (wxGenericValidator (&Preferences.DefaultMountOptions.TrueCryptMode)); - int index, prfInitialIndex = 0; Pkcs5PrfChoice->Append (LangString["AUTODETECTION"]); - foreach_ref (const Pkcs5Kdf &kdf, Pkcs5Kdf::GetAvailableAlgorithms(false)) + foreach_ref (const Pkcs5Kdf &kdf, Pkcs5Kdf::GetAvailableAlgorithms()) { index = Pkcs5PrfChoice->Append (kdf.GetName()); if (Preferences.DefaultMountOptions.Kdf @@ -70,6 +71,30 @@ namespace VeraCrypt } Pkcs5PrfChoice->Select (prfInitialIndex); + // Language for non-Windows +#ifndef TC_WINDOWS +#if defined (TC_MACOSX) + wxDir languagesFolder(StringConverter::ToSingle (Application::GetExecutableDirectory()) + "/../Resources/languages/"); +#else + wxDir languagesFolder("/usr/share/veracrypt/languages/"); +#endif + wxArrayString langArray; + LanguageListBox->Append("System default"); + LanguageListBox->Append("English"); + + size_t langCount; + langCount = wxDir::GetAllFiles(languagesFolder.GetName(), &langArray, wxEmptyString, wxDIR_FILES); + for (size_t i = 0; i < langCount; ++i) { + wxFileName filename(langArray[i]); + wxString langId = filename.GetName().AfterLast('.'); + wxString langNative = langEntries[langId]; + if (!langNative.empty()) { + LanguageListBox->Append(langNative); + } + } +#endif + + // Keyfiles TC_CHECK_BOX_VALIDATOR (UseKeyfiles); @@ -87,7 +112,7 @@ namespace VeraCrypt // Encryption AesHwCpuSupportedStaticText->SetLabel ( #ifdef TC_AES_HW_CPU - (is_aes_hw_cpu_supported() ? LangString["UISTR_YES"] : LangString["UISTR_NO"])); + (HasAESNI() ? LangString["UISTR_YES"] : LangString["UISTR_NO"])); #else LangString["NOT_APPLICABLE_OR_NOT_AVAILABLE"]); #endif @@ -96,6 +121,7 @@ namespace VeraCrypt // Security tokens Pkcs11ModulePathTextCtrl->SetValue (wstring (Preferences.SecurityTokenModule)); TC_CHECK_BOX_VALIDATOR (CloseSecurityTokenSessionsAfterMount); + TC_CHECK_BOX_VALIDATOR (EMVSupportEnabled); // System integration TC_CHECK_BOX_VALIDATOR (StartOnLogon); @@ -135,8 +161,8 @@ namespace VeraCrypt #ifdef TC_MACOSX DismountOnScreenSaverCheckBox->Show (false); - DismountOnLogOffCheckBox->SetLabel (_("VeraCrypt quits")); - OpenExplorerWindowAfterMountCheckBox->SetLabel (_("Open Finder window for successfully mounted volume")); + DismountOnLogOffCheckBox->SetLabel (LangString["LINUX_VC_QUITS"]); + OpenExplorerWindowAfterMountCheckBox->SetLabel (LangString["LINUX_OPEN_FINDER"]); MountRemovableCheckBox->Show (false); FilesystemSizer->Show (false); @@ -200,7 +226,7 @@ namespace VeraCrypt Fit(); Center(); - StdButtonsOK->SetDefault(); + OKButton->SetDefault(); #ifdef TC_WINDOWS // Hotkey timer @@ -239,6 +265,15 @@ namespace VeraCrypt } } + void PreferencesDialog::OnSysDefaultLangButtonClick (wxCommandEvent& event) + { + // SetStringSelection()'s Assert currently broken in sorted ListBoxes on macOS, workaround: + int itemIndex = LanguageListBox->FindString("System default", true); + if (itemIndex != wxNOT_FOUND) { + LanguageListBox->SetSelection(itemIndex); + } + } + void PreferencesDialog::OnAssignHotkeyButtonClick (wxCommandEvent& event) { #ifdef TC_WINDOWS @@ -302,20 +337,20 @@ namespace VeraCrypt if (Gui->AskYesNo (LangString["CONFIRM_SETTING_DEGRADES_PERFORMANCE"], true, true)) { #ifdef TC_LINUX - Gui->ShowWarning (_("Please note that this setting takes effect only if use of the kernel cryptographic services is disabled.")); + Gui->ShowWarning (LangString["LINUX_DISABLE_KERNEL_ONLY_SETTING"]); #endif } else NoHardwareCryptoCheckBox->SetValue (false); } - Gui->ShowWarning (_("Please note that any currently mounted volumes need to be remounted before they can use this setting.")); + Gui->ShowWarning (LangString["LINUX_REMOUNT_BECAUSEOF_SETTING"]); } void PreferencesDialog::OnNoKernelCryptoCheckBoxClick (wxCommandEvent& event) { if (event.IsChecked()) - NoKernelCryptoCheckBox->SetValue (Gui->AskYesNo (_("Disabling the use of kernel cryptographic services can degrade performance.\n\nAre you sure?"), false, true)); + NoKernelCryptoCheckBox->SetValue (Gui->AskYesNo (LangString["LINUX_DISABLE_KERNEL_CRYPT_CONFIRM"], false, true)); } void PreferencesDialog::OnClose (wxCloseEvent& event) @@ -356,6 +391,13 @@ namespace VeraCrypt AssignHotkeyButton->Enable (false); } + // Fixes an issue where going through PreferencesNotebook tabs would unintentionally select the first entry + // in the LanguageListBox and thus cause a language change on OKButton press. + void PreferencesDialog::OnPageChanged(wxBookCtrlEvent &event) + { + LanguageListBox->DeselectAll(); + } + void PreferencesDialog::OnOKButtonClick (wxCommandEvent& event) { #ifdef TC_WINDOWS @@ -369,11 +411,10 @@ namespace VeraCrypt { try { - selectedKdf = Pkcs5Kdf::GetAlgorithm (wstring (Pkcs5PrfChoice->GetStringSelection ()), TrueCryptModeCheckBox->IsChecked ()); + selectedKdf = Pkcs5Kdf::GetAlgorithm (wstring (Pkcs5PrfChoice->GetStringSelection ())); } catch (ParameterIncorrect&) { - Gui->ShowWarning ("ALGO_NOT_SUPPORTED_FOR_TRUECRYPT_MODE"); return; } } @@ -390,6 +431,19 @@ namespace VeraCrypt bool securityTokenModuleChanged = (Preferences.SecurityTokenModule != wstring (Pkcs11ModulePathTextCtrl->GetValue())); Preferences.SecurityTokenModule = wstring (Pkcs11ModulePathTextCtrl->GetValue()); + if (LanguageListBox->GetSelection() != wxNOT_FOUND) { + wxString langToFind = LanguageListBox->GetString(LanguageListBox->GetSelection()); + for (const auto &each: langEntries) { + if (each.second == langToFind) { + Preferences.Language = each.first; +#ifdef DEBUG + cout << "Lang set to: " << each.first << endl; +#endif + } + } + Gui->ShowInfo (LangString["LINUX_RESTART_FOR_LANGUAGE_CHANGE"]); + } + Gui->SetPreferences (Preferences); try @@ -424,7 +478,7 @@ namespace VeraCrypt { #ifdef TC_LINUX if (!event.IsChecked()) - Gui->ShowInfo (_("Please note that disabling this option may have no effect on volumes mounted using kernel cryptographic services.")); + Gui->ShowInfo (LangString["LINUX_KERNEL_CRYPT_OPTION_CHANGE_MOUNTED_HINT"]); #endif } |