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.
This commit is contained in:
Leland Lucius 2020-07-29 00:08:48 -05:00
parent d4627f0daf
commit 85b4a5376f
7 changed files with 117 additions and 95 deletions

View File

@ -891,16 +891,16 @@ list( APPEND SOURCES
widgets/FileDialog/FileDialog.cpp
widgets/FileDialog/FileDialog.h
$<$<BOOL:${wxIS_WIN}>:
widgets/FileDialog/win/FileDialogPrivate.cpp
widgets/FileDialog/win/FileDialogPrivate.h
widgets/FileDialog/win/FileDialogPrivate.cpp
widgets/FileDialog/win/FileDialogPrivate.h
>
$<$<BOOL:${wxIS_MAC}>:
widgets/FileDialog/mac/FileDialogPrivate.mm
widgets/FileDialog/mac/FileDialogPrivate.h
widgets/FileDialog/mac/FileDialogPrivate.mm
widgets/FileDialog/mac/FileDialogPrivate.h
>
$<$<BOOL:${wxIS_GTK}>:
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

View File

@ -115,6 +115,7 @@ for registering for changes.
#include <wx/bmpbuttn.h>
#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

View File

@ -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;
}

View File

@ -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

View File

@ -809,7 +809,6 @@ void ExportFFmpegCustomOptions::PopulateOrExchange(ShuttleGui & S)
}
S.EndMultiColumn();
}
#
S.EndHorizontalLay();
}
S.EndHorizontalLay();

View File

@ -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());
}
}

View File

@ -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 <wx/textctrl.h>
// 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__