From 85b4a5376fa69daeafa0f1c0ff8289b5f67f8a65 Mon Sep 17 00:00:00 2001 From: Leland Lucius Date: Wed, 29 Jul 2020 00:08:48 -0500 Subject: [PATCH] AUP3: Make suggested directory preferences changes In addition, I've extracted the wxTextCtrl wrapper from the TimerRecordDialog intto widgets/wxTextCtrlWrapper.h and made it the default for ShuttleGui::AddTextBox(). This way readonly text controls are always included in the tab order. --- src/CMakeLists.txt | 13 ++-- src/ShuttleGui.cpp | 3 +- src/TimerRecordDialog.cpp | 7 +- src/TimerRecordDialog.h | 31 ++------ src/export/ExportFFmpegDialogs.cpp | 1 - src/prefs/DirectoriesPrefs.cpp | 111 ++++++++++++++--------------- src/widgets/wxTextCtrlWrapper.h | 46 ++++++++++++ 7 files changed, 117 insertions(+), 95 deletions(-) create mode 100644 src/widgets/wxTextCtrlWrapper.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 12e27202d..5662c33cd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -891,16 +891,16 @@ list( APPEND SOURCES widgets/FileDialog/FileDialog.cpp widgets/FileDialog/FileDialog.h $<$: - widgets/FileDialog/win/FileDialogPrivate.cpp - widgets/FileDialog/win/FileDialogPrivate.h + widgets/FileDialog/win/FileDialogPrivate.cpp + widgets/FileDialog/win/FileDialogPrivate.h > $<$: - widgets/FileDialog/mac/FileDialogPrivate.mm - widgets/FileDialog/mac/FileDialogPrivate.h + widgets/FileDialog/mac/FileDialogPrivate.mm + widgets/FileDialog/mac/FileDialogPrivate.h > $<$: - widgets/FileDialog/gtk/FileDialogPrivate.cpp - widgets/FileDialog/gtk/FileDialogPrivate.h + widgets/FileDialog/gtk/FileDialogPrivate.cpp + widgets/FileDialog/gtk/FileDialogPrivate.h > widgets/FileHistory.cpp widgets/FileHistory.h @@ -944,6 +944,7 @@ list( APPEND SOURCES widgets/valnum.h widgets/wxPanelWrapper.cpp widgets/wxPanelWrapper.h + widgets/wxTextCtrlWrapper.h # XML handling xml/XMLFileReader.cpp diff --git a/src/ShuttleGui.cpp b/src/ShuttleGui.cpp index 043a6e829..f680bdcd2 100644 --- a/src/ShuttleGui.cpp +++ b/src/ShuttleGui.cpp @@ -115,6 +115,7 @@ for registering for changes. #include #include "../include/audacity/ComponentInterface.h" #include "widgets/wxPanelWrapper.h" +#include "widgets/wxTextCtrlWrapper.h" #include "AllThemeResources.h" #if wxUSE_ACCESSIBILITY @@ -630,7 +631,7 @@ wxTextCtrl * ShuttleGuiBase::AddTextBox( long flags = wxTE_LEFT; #endif - mpWind = pTextCtrl = safenew wxTextCtrl(GetParent(), miId, Value, + mpWind = pTextCtrl = safenew wxTextCtrlWrapper(GetParent(), miId, Value, wxDefaultPosition, Size, GetStyle( flags )); #if wxUSE_ACCESSIBILITY // so that name can be set on a standard control diff --git a/src/TimerRecordDialog.cpp b/src/TimerRecordDialog.cpp index cae558d99..13f99086a 100644 --- a/src/TimerRecordDialog.cpp +++ b/src/TimerRecordDialog.cpp @@ -52,6 +52,7 @@ #include "widgets/AudacityMessageBox.h" #include "widgets/ErrorDialog.h" #include "widgets/ProgressDialog.h" +#include "widgets/wxTextCtrlWrapper.h" #if wxUSE_ACCESSIBILITY #include "widgets/WindowAccessible.h" @@ -721,13 +722,13 @@ wxPrintf(wxT("%s\n"), dt.Format()); return Verbatim( dt.FormatDate() + wxT(" ") + dt.FormatTime() ); } -TimerRecordPathCtrl * TimerRecordDialog::NewPathControl( +wxTextCtrlWrapper * TimerRecordDialog::NewPathControl( wxWindow *wParent, const int iID, const TranslatableString &sCaption, const TranslatableString &sValue) { - TimerRecordPathCtrl * pTextCtrl; + wxTextCtrlWrapper * pTextCtrl; wxASSERT(wParent); // to justify safenew - pTextCtrl = safenew TimerRecordPathCtrl(wParent, iID, sValue); + pTextCtrl = safenew wxTextCtrlWrapper(wParent, iID, sValue.Translation()); pTextCtrl->SetName(sCaption.Translation()); return pTextCtrl; } diff --git a/src/TimerRecordDialog.h b/src/TimerRecordDialog.h index 12e973661..ebdf5c217 100644 --- a/src/TimerRecordDialog.h +++ b/src/TimerRecordDialog.h @@ -28,7 +28,7 @@ class wxTimerEvent; class NumericTextCtrl; class ShuttleGui; -class TimerRecordPathCtrl; +class wxTextCtrlWrapper; enum TimerRecordCompletedActions { TR_ACTION_NOTHING = 0x00000000, @@ -52,29 +52,6 @@ enum { class AudacityProject; -class TimerRecordPathCtrl final : public wxTextCtrl -{ - // MY: Class that inherits from the wxTextCtrl class. - // We override AcceptsFocusFromKeyboard in order to add - // the text controls to the Tab Order. -public: - TimerRecordPathCtrl(wxWindow * parent, wxWindowID id, - const TranslatableString &value = {}, - const wxPoint &pos = wxDefaultPosition, - const wxSize &size = wxDefaultSize, - long style = 0, - const wxValidator &validator = wxDefaultValidator, - const wxString &name = wxTextCtrlNameStr) - :wxTextCtrl(parent, id, value.Translation(), pos, size, style, validator, name) - { - }; - ~TimerRecordPathCtrl() {}; - - virtual bool AcceptsFocusFromKeyboard() const override { - return true; - } -}; - class TimerRecordDialog final : public wxDialogWrapper { public: @@ -118,7 +95,7 @@ private: void UpdateTextBoxControls(); // Add Path Controls to Form - TimerRecordPathCtrl *NewPathControl( + wxTextCtrlWrapper *NewPathControl( wxWindow *wParent, const int iID, const TranslatableString &sCaption, const TranslatableString &sValue); @@ -145,10 +122,10 @@ private: // Controls for Auto Save/Export wxCheckBox *m_pTimerAutoSaveCheckBoxCtrl; - TimerRecordPathCtrl *m_pTimerSavePathTextCtrl; + wxTextCtrlWrapper *m_pTimerSavePathTextCtrl; wxButton *m_pTimerSavePathButtonCtrl; wxCheckBox *m_pTimerAutoExportCheckBoxCtrl; - TimerRecordPathCtrl *m_pTimerExportPathTextCtrl; + wxTextCtrlWrapper *m_pTimerExportPathTextCtrl; wxButton *m_pTimerExportPathButtonCtrl; // After Timer Record Options Choice diff --git a/src/export/ExportFFmpegDialogs.cpp b/src/export/ExportFFmpegDialogs.cpp index cb61f7166..a2ef2a5df 100644 --- a/src/export/ExportFFmpegDialogs.cpp +++ b/src/export/ExportFFmpegDialogs.cpp @@ -809,7 +809,6 @@ void ExportFFmpegCustomOptions::PopulateOrExchange(ShuttleGui & S) } S.EndMultiColumn(); } -# S.EndHorizontalLay(); } S.EndHorizontalLay(); diff --git a/src/prefs/DirectoriesPrefs.cpp b/src/prefs/DirectoriesPrefs.cpp index 1068b817d..61cbdc5e0 100644 --- a/src/prefs/DirectoriesPrefs.cpp +++ b/src/prefs/DirectoriesPrefs.cpp @@ -113,6 +113,50 @@ void DirectoriesPrefs::PopulateOrExchange(ShuttleGui &S) S.SetBorder(2); S.StartScroller(); + S.StartStatic(XO("Default folders")); + { + S.AddSpace(4); + S.AddFixedText( + XO("The last directory referenced in each of the categories " + "below will be used if the values are left empty.")); + S.AddSpace(4); + + S.StartMultiColumn(3, wxEXPAND); + { + S.SetStretchyCol(1); + + S.Id(OpenTextID); + mOpenText = S.TieTextBox(XXO("O&pen:"), + {PreferenceKey(Operation::Open, PathType::User), + wxT("")}, + 30); + S.Id(OpenButtonID).AddButton(XXO("&Browse...")); + + S.Id(SaveTextID); + mSaveText = S.TieTextBox(XXO("S&ave:"), + {PreferenceKey(Operation::Save, PathType::User), + wxT("")}, + 30); + S.Id(SaveButtonID).AddButton(XXO("B&rowse...")); + + S.Id(ImportTextID); + mImportText = S.TieTextBox(XXO("&Import:"), + {PreferenceKey(Operation::Import, PathType::User), + wxT("")}, + 30); + S.Id(ImportButtonID).AddButton(XXO("Br&owse...")); + + S.Id(ExportTextID); + mExportText = S.TieTextBox(XXO("&Export:"), + {PreferenceKey(Operation::Export, PathType::User), + wxT("")}, + 30); + S.Id(ExportButtonID).AddButton(XXO("Bro&wse...")); + } + S.EndMultiColumn(); + } + S.EndStatic(); + S.StartStatic(XO("Temporary files directory")); { S.StartMultiColumn(3, wxEXPAND); @@ -124,9 +168,9 @@ void DirectoriesPrefs::PopulateOrExchange(ShuttleGui &S) {PreferenceKey(Operation::Temp, PathType::_None), wxT("")}, 30); - S.Id(TempButtonID).AddButton(XXO("B&rowse...")); + S.Id(TempButtonID).AddButton(XXO("Brow&se...")); - S.AddPrompt(XXO("Free Space:")); + S.AddPrompt(XXO("&Free Space:")); mFreeSpace = S.Style(wxTE_READONLY).AddTextBox({}, wxT(""), 30); mFreeSpace->SetName(XO("Free Space").Translation()); } @@ -134,44 +178,6 @@ void DirectoriesPrefs::PopulateOrExchange(ShuttleGui &S) } S.EndStatic(); - S.StartStatic(XO("Default folders (\"last used\" if not specified)")); - { - S.StartMultiColumn(3, wxEXPAND); - { - S.SetStretchyCol(1); - - S.Id(OpenTextID); - mOpenText = S.TieTextBox(XXO("&Open:"), - {PreferenceKey(Operation::Open, PathType::User), - wxT("")}, - 30); - S.Id(OpenButtonID).AddButton(XXO("Browse...")); - - S.Id(SaveTextID); - mSaveText = S.TieTextBox(XXO("&Save:"), - {PreferenceKey(Operation::Save, PathType::User), - wxT("")}, - 30); - S.Id(SaveButtonID).AddButton(XXO("Browse...")); - - S.Id(ImportTextID); - mImportText = S.TieTextBox(XXO("&Import:"), - {PreferenceKey(Operation::Import, PathType::User), - wxT("")}, - 30); - S.Id(ImportButtonID).AddButton(XXO("Browse...")); - - S.Id(ExportTextID); - mExportText = S.TieTextBox(XXO("&Export:"), - {PreferenceKey(Operation::Export, PathType::User), - wxT("")}, - 30); - S.Id(ExportButtonID).AddButton(XXO("Browse...")); - } - S.EndMultiColumn(); - } - S.EndStatic(); - S.EndScroller(); } @@ -231,29 +237,20 @@ void DirectoriesPrefs::OnTempBrowse(wxCommandEvent &evt) void DirectoriesPrefs::OnTempText(wxCommandEvent & WXUNUSED(evt)) { - wxString Temp; TranslatableString label; - if (mTempText != NULL) + if (mTempText && mFreeSpace) { - Temp = mTempText->GetValue(); - } + FilePath path = mTempText->GetValue(); - if (wxDirExists(Temp)) - { wxLongLong space; - wxGetDiskSpace(Temp, NULL, &space); - label = Internat::FormatSize(space); - } - else - { - label = XO("unavailable - above location doesn't exist"); - } + wxGetDiskSpace(path, NULL, &space); - if (mFreeSpace != NULL) - { - mFreeSpace->SetLabel(label.Translation()); - mFreeSpace->SetName(label.Translation()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs) + label = wxDirExists(path) + ? Internat::FormatSize(space) + : XO("unavailable - above location doesn't exist"); + + mFreeSpace->SetValue(label.Translation()); } } diff --git a/src/widgets/wxTextCtrlWrapper.h b/src/widgets/wxTextCtrlWrapper.h new file mode 100644 index 000000000..17488d48e --- /dev/null +++ b/src/widgets/wxTextCtrlWrapper.h @@ -0,0 +1,46 @@ +/********************************************************************** + + Audacity: A Digital Audio Editor + + wxTextCtrlWrapper.h + + (Extracted from TimerRecordDialog.h) + +**********************************************************************/ + +#ifndef __AUDACITY_WXTEXTCTRLWRAPPER__ +#define __AUDACITY_WXTEXTCTRLWRAPPER__ + +#include "../Audacity.h" + +#include + +// MY: Class that inherits from the wxTextCtrl class. +// We override AcceptsFocusFromKeyboard in order to add +// the text controls to the Tab Order since wxTextCtrls +// with the wxTE_READONLY style are normally skipped. +class wxTextCtrlWrapper final : public wxTextCtrl +{ +public: + wxTextCtrlWrapper(wxWindow * parent, wxWindowID id, + const wxString &value = {}, + const wxPoint &pos = wxDefaultPosition, + const wxSize &size = wxDefaultSize, + long style = 0, + const wxValidator &validator = wxDefaultValidator, + const wxString &name = wxTextCtrlNameStr) + : wxTextCtrl(parent, id, value, pos, size, style, validator, name) + { + }; + + ~wxTextCtrlWrapper() + { + }; + + virtual bool AcceptsFocusFromKeyboard() const override + { + return true; + } +}; + +#endif // __AUDACITY_WXTEXTCTRLWRAPPER__