1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-08-05 22:59:29 +02:00

Bug1704: should default file dialogs to Documents, not program path

This commit is contained in:
Paul Licameli 2017-08-03 08:07:28 -04:00
commit 3288f8d7a0
25 changed files with 206 additions and 142 deletions

View File

@ -774,9 +774,7 @@ bool AudacityApp::MRUOpen(const wxString &fullPathStr) {
// verify that the file exists
if (wxFile::Exists(fullPathStr))
{
if (!gPrefs->Write(wxT("/DefaultOpenPath"), wxPathOnly(fullPathStr)) ||
!gPrefs->Flush())
return false;
FileNames::UpdateDefaultPath(FileNames::Operation::Open, fullPathStr);
// Make sure it isn't already open.
// Test here even though AudacityProject::OpenFile() also now checks, because

View File

@ -16,9 +16,10 @@ Provides thread-safe logging based on the wxWidgets log facility.
#include "Audacity.h" // This should always be included first
#include "AudacityLogger.h"
#include "FileDialog.h"
#include "FileNames.h"
#include "ShuttleGui.h"
#include <wx/filedlg.h>
#include <wx/log.h>
#include <wx/frame.h>
#include <wx/icon.h>
@ -292,7 +293,8 @@ void AudacityLogger::OnSave(wxCommandEvent & WXUNUSED(e))
{
wxString fName = _("log.txt");
fName = FileSelector(_("Save log to:"),
fName = FileNames::SelectFile(FileNames::Operation::Export,
_("Save log to:"),
wxEmptyString,
fName,
wxT("txt"),

View File

@ -434,7 +434,7 @@ wxString BatchCommands::BuildCleanFileName(const wxString &fileName, const wxStr
// double endTime = project->mTracks->GetEndTime();
// double startTime = 0.0;
//OnSelectAll();
pathName = gPrefs->Read(wxT("/DefaultOpenPath"), ::wxGetCwd());
pathName = FileNames::FindDefaultPath(FileNames::Operation::Export);
::wxMessageBox(wxString::Format(_("Export recording to %s\n/%s/%s%s"),
pathName.c_str(), cleanedString.c_str(), justName.c_str(), extension.c_str()),
_("Export recording"),

View File

@ -50,6 +50,7 @@
#include "AllThemeResources.h"
#include "FileDialog.h"
#include "FileNames.h"
#include "import/Import.h"
#define ChainsListID 7001
@ -237,7 +238,6 @@ void BatchProcessDialog::OnApplyToFiles(wxCommandEvent & WXUNUSED(event))
return;
}
wxString path = gPrefs->Read(wxT("/DefaultOpenPath"), ::wxGetCwd());
wxString prompt = _("Select file(s) for batch processing...");
FormatList l;
@ -279,6 +279,7 @@ void BatchProcessDialog::OnApplyToFiles(wxCommandEvent & WXUNUSED(event))
}
}
auto path = FileNames::FindDefaultPath(FileNames::Operation::Open);
FileDialog dlog(this,
prompt,
path,
@ -290,7 +291,7 @@ void BatchProcessDialog::OnApplyToFiles(wxCommandEvent & WXUNUSED(event))
if (dlog.ShowModal() != wxID_OK) {
return;
}
wxArrayString files;
dlog.GetPaths(files);

View File

@ -41,7 +41,7 @@ of the BlockFile system.
#include "Sequence.h"
#include "Prefs.h"
#include "FileDialog.h"
#include "FileNames.h"
class BenchmarkDialog final : public wxDialogWrapper
{
@ -248,7 +248,8 @@ void BenchmarkDialog::OnSave( wxCommandEvent & WXUNUSED(event))
{
wxString fName = wxT("benchmark.txt");
fName = FileSelector(wxT("Export Benchmark Data As:"),
fName = FileNames::SelectFile(FileNames::Operation::Export,
wxT("Export Benchmark Data As:"),
wxEmptyString,
fName,
wxT("txt"),

View File

@ -24,6 +24,7 @@ License: GPL v2. See License.txt.
#include "widgets/HelpSystem.h"
#include <wx/file.h>
#include <wx/filedlg.h>
#include "Experimental.h"
@ -518,7 +519,8 @@ public:
"Where would I find the file '%s'?" instead if you want. */
question.Printf(_("Where is '%s'?"), mName.c_str());
wxString path = FileSelector(question,
wxString path = FileNames::SelectFile(FileNames::Operation::None,
question,
mLibPath.GetPath(),
mLibPath.GetName(),
wxT(""),

View File

@ -140,7 +140,6 @@ extern "C" {
#include <wx/msgdlg.h> // for wxMessageBox
#include <wx/utils.h>
#include "widgets/LinkingHtmlWindow.h"
#include "FileDialog.h"
#include "ShuttleGui.h"
#include "Prefs.h"
#include <wx/checkbox.h>

View File

@ -30,6 +30,8 @@ used throughout Audacity into this one place.
#include "FileNames.h"
#include "Internat.h"
#include "PlatformCompatibility.h"
#include "wxFileNameWrapper.h"
#include "../lib-src/FileDialog/FileDialog.h"
#if defined(__WXMAC__) || defined(__WXGTK__)
#include <dlfcn.h>
@ -315,3 +317,77 @@ wxString FileNames::PathFromAddr(void *addr)
return name.GetFullPath();
}
wxFileNameWrapper FileNames::DefaultToDocumentsFolder
(const wxString &preference)
{
wxFileNameWrapper result;
result.AssignHomeDir();
#ifdef __WIN32__
result.SetPath(gPrefs->Read(
preference, result.GetPath(wxPATH_GET_VOLUME) + "\\Documents\\Audacity"));
// The path might not exist.
// There is no error if the path could not be created. That's OK.
// The dialog that Audacity offers will allow the user to select a valid directory.
result.Mkdir(0755, wxPATH_MKDIR_FULL);
#else
result.SetPath(gPrefs->Read( preference, result.GetPath() + "/Documents"));
#endif
return result;
}
namespace {
wxString PreferenceKey(FileNames::Operation op)
{
wxString key;
switch (op) {
case FileNames::Operation::Open:
key = wxT("/DefaultOpenPath"); break;
case FileNames::Operation::Export:
key = wxT("/DefaultExportPath"); break;
case FileNames::Operation::None:
default:
break;
}
return key;
}
}
wxString FileNames::FindDefaultPath(Operation op)
{
auto key = PreferenceKey(op);
if (key.empty())
return wxString{};
else
return DefaultToDocumentsFolder(key).GetPath();
}
void FileNames::UpdateDefaultPath(Operation op, const wxString &path)
{
if (path.empty())
return;
auto key = PreferenceKey(op);
if (!key.empty()) {
gPrefs->Write(key, ::wxPathOnly(path));
gPrefs->Flush();
}
}
wxString
FileNames::SelectFile(Operation op,
const wxString& message,
const wxString& default_path,
const wxString& default_filename,
const wxString& default_extension,
const wxString& wildcard,
int flags,
wxWindow *parent)
{
return WithDefaultPath(op, default_path, [&](const wxString &path) {
return FileSelector(
message, path, default_filename, default_extension,
wildcard, flags, parent, wxDefaultCoord, wxDefaultCoord);
});
}

View File

@ -15,6 +15,7 @@
#include "Audacity.h"
class wxFileName;
class wxFileNameWrapper;
class wxArrayString;
// Uh, this is really a namespace rather than a class,
@ -65,6 +66,43 @@ public:
// Obtain name of loaded module that contains address
static wxString PathFromAddr(void *addr);
static wxFileNameWrapper DefaultToDocumentsFolder
(const wxString &preference);
// If not None, determines a preference key (for the default path string) to
// be read and updated
enum class Operation {
None,
Open,
Export
};
static wxString FindDefaultPath(Operation op);
static void UpdateDefaultPath(Operation op, const wxString &path);
// F is a function taking a wxString, returning wxString
template<typename F>
static wxString WithDefaultPath
(Operation op, const wxString &defaultPath, F function)
{
auto path = defaultPath;
if (path.empty())
path = FileNames::FindDefaultPath(op);
auto result = function(path);
FileNames::UpdateDefaultPath(op, result);
return result;
}
static wxString
SelectFile(Operation op, // op matters only when default_path is empty
const wxString& message,
const wxString& default_path,
const wxString& default_filename,
const wxString& default_extension,
const wxString& wildcard,
int flags,
wxWindow *parent);
private:
// Private constructors: No one is ever going to instantiate it.
//

View File

@ -76,7 +76,7 @@ and in the spectrogram spectral selection.
#include "Theme.h"
#include "AllThemeResources.h"
#include "FileDialog.h"
#include "FileNames.h"
#include "WaveTrack.h"
@ -1027,7 +1027,8 @@ void FreqWindow::OnExport(wxCommandEvent & WXUNUSED(event))
{
wxString fName = _("spectrum.txt");
fName = FileSelector(_("Export Spectral Data As:"),
fName = FileNames::SelectFile(FileNames::Operation::Export,
_("Export Spectral Data As:"),
wxEmptyString, fName, wxT("txt"), wxT("*.txt"), wxFD_SAVE | wxRESIZE_BORDER, this);
if (fName == wxT(""))

View File

@ -29,7 +29,6 @@ and on Mac OS X for the filesystem.
#include <math.h> // for pow()
#include "Internat.h"
#include "FileDialog.h"
#include "Experimental.h"
// in order for the static member variables to exist, they must appear here
@ -246,7 +245,8 @@ char *Internat::VerifyFilename(const wxString &s, bool input)
wxMessageBox(_("The specified filename could not be converted due to Unicode character use."));
ext = ff.GetExt();
name = FileSelector(_("Specify New Filename:"),
name = FileNames::SelectFile(FileNames::Operation::None,
_("Specify New Filename:"),
wxEmptyString,
name,
ext,

View File

@ -38,7 +38,7 @@
#include "ViewInfo.h"
#include "widgets/NumericTextCtrl.h"
#include "FileDialog.h"
#include "FileNames.h"
#include <limits>
enum Column
@ -585,12 +585,11 @@ void LabelDialog::OnRemove(wxCommandEvent & WXUNUSED(event))
void LabelDialog::OnImport(wxCommandEvent & WXUNUSED(event))
{
wxString path = gPrefs->Read(wxT("/DefaultOpenPath"),::wxGetCwd());
// Ask user for a filename
wxString fileName =
FileSelector(_("Select a text file containing labels"),
path, // Path
FileNames::SelectFile(FileNames::Operation::Open,
_("Select a text file containing labels"),
wxEmptyString, // Path
wxT(""), // Name
wxT(".txt"), // Extension
_("Text files (*.txt)|*.txt|All files|*"),
@ -599,10 +598,6 @@ void LabelDialog::OnImport(wxCommandEvent & WXUNUSED(event))
// They gave us one...
if (fileName != wxT("")) {
path =::wxPathOnly(fileName);
gPrefs->Write(wxT("/DefaultOpenPath"), path);
gPrefs->Flush();
wxTextFile f;
// Get at the data
@ -640,7 +635,8 @@ void LabelDialog::OnExport(wxCommandEvent & WXUNUSED(event))
// Extract the actual name.
wxString fName = mTrackNames[mTrackNames.GetCount() - 1].AfterFirst(wxT('-')).Mid(1);
fName = FileSelector(_("Export Labels As:"),
fName = FileNames::SelectFile(FileNames::Operation::Export,
_("Export Labels As:"),
wxEmptyString,
fName.c_str(),
wxT("txt"),

View File

@ -117,7 +117,6 @@ simplifies construction of menu items.
#include "SoundActivatedRecord.h"
#include "LabelDialog.h"
#include "FileDialog.h"
#include "SplashDialog.h"
#include "widgets/HelpSystem.h"
#include "DeviceManager.h"
@ -4424,7 +4423,8 @@ void AudacityProject::OnExportLabels()
return;
}
fName = FileSelector(_("Export Labels As:"),
fName = FileNames::SelectFile(FileNames::Operation::Export,
_("Export Labels As:"),
wxEmptyString,
fName,
wxT("txt"),
@ -4505,7 +4505,8 @@ void AudacityProject::OnExportMIDI(){
wxString fName = wxT("");
fName = FileSelector(_("Export MIDI As:"),
fName = FileNames::SelectFile(FileNames::Operation::Export,
_("Export MIDI As:"),
wxEmptyString,
fName,
wxT(".mid|.gro"),
@ -6730,8 +6731,7 @@ void AudacityProject::OnImport()
for (size_t ff = 0; ff < selectedFiles.GetCount(); ff++) {
wxString fileName = selectedFiles[ff];
wxString path = ::wxPathOnly(fileName);
gPrefs->Write(wxT("/DefaultOpenPath"), path);
FileNames::UpdateDefaultPath(FileNames::Operation::Open, fileName);
Import(fileName);
}
@ -6741,11 +6741,10 @@ void AudacityProject::OnImport()
void AudacityProject::OnImportLabels()
{
wxString path = gPrefs->Read(wxT("/DefaultOpenPath"),::wxGetCwd());
wxString fileName =
FileSelector(_("Select a text file containing labels"),
path, // Path
FileNames::SelectFile(FileNames::Operation::Open,
_("Select a text file containing labels"),
wxEmptyString, // Path
wxT(""), // Name
wxT(".txt"), // Extension
_("Text files (*.txt)|*.txt|All files|*"),
@ -6753,10 +6752,6 @@ void AudacityProject::OnImportLabels()
this); // Parent
if (fileName != wxT("")) {
path =::wxPathOnly(fileName);
gPrefs->Write(wxT("/DefaultOpenPath"), path);
gPrefs->Flush();
wxTextFile f;
f.Open(fileName);
@ -6787,23 +6782,17 @@ void AudacityProject::OnImportLabels()
#ifdef USE_MIDI
void AudacityProject::OnImportMIDI()
{
wxString path = gPrefs->Read(wxT("/DefaultOpenPath"),::wxGetCwd());
wxString fileName = FileSelector(_("Select a MIDI file"),
path, // Path
wxString fileName = FileNames::SelectFile(FileNames::Operation::Open,
_("Select a MIDI file"),
wxEmptyString, // Path
wxT(""), // Name
wxT(""), // Extension
_("MIDI and Allegro files (*.mid;*.midi;*.gro)|*.mid;*.midi;*.gro|MIDI files (*.mid;*.midi)|*.mid;*.midi|Allegro files (*.gro)|*.gro|All files|*"),
wxRESIZE_BORDER, // Flags
this); // Parent
if (fileName != wxT("")) {
path =::wxPathOnly(fileName);
gPrefs->Write(wxT("/DefaultOpenPath"), path);
gPrefs->Flush();
if (fileName != wxT(""))
AudacityProject::DoImportMIDI(this, fileName);
}
}
AudacityProject *AudacityProject::DoImportMIDI(
@ -6839,11 +6828,10 @@ AudacityProject *AudacityProject::DoImportMIDI(
void AudacityProject::OnImportRaw()
{
wxString path = gPrefs->Read(wxT("/DefaultOpenPath"),::wxGetCwd());
wxString fileName =
FileSelector(_("Select any uncompressed audio file"),
path, // Path
FileNames::SelectFile(FileNames::Operation::Open,
_("Select any uncompressed audio file"),
wxEmptyString, // Path
wxT(""), // Name
wxT(""), // Extension
_("All files|*"),
@ -6853,10 +6841,6 @@ void AudacityProject::OnImportRaw()
if (fileName == wxT(""))
return;
path =::wxPathOnly(fileName);
gPrefs->Write(wxT("/DefaultOpenPath"), path);
gPrefs->Flush();
TrackHolders newTracks;
::ImportRaw(this, fileName, GetTrackFactory(), newTracks);
@ -8231,7 +8215,8 @@ void AudacityProject::OnAudioDeviceInfo()
if (dlg.ShowModal() == wxID_OK)
{
wxString fName = FileSelector(_("Save Device Info"),
wxString fName = FileNames::SelectFile(FileNames::Operation::Export,
_("Save Device Info"),
wxEmptyString,
wxT("deviceinfo.txt"),
wxT("txt"),
@ -8271,7 +8256,8 @@ void AudacityProject::OnMidiDeviceInfo()
if (dlg.ShowModal() == wxID_OK)
{
wxString fName = FileSelector(_("Save MIDI Device Info"),
wxString fName = FileNames::SelectFile(FileNames::Operation::Export,
_("Save MIDI Device Info"),
wxEmptyString,
wxT("midideviceinfo.txt"),
wxT("txt"),

View File

@ -2830,7 +2830,7 @@ wxArrayString AudacityProject::ShowOpenDialog(const wxString &extraformat, const
// we built up earlier into the mask
// Retrieve saved path and type
wxString path = gPrefs->Read(wxT("/DefaultOpenPath"),::wxGetCwd());
auto path = FileNames::FindDefaultPath(FileNames::Operation::Open);
wxString type = gPrefs->Read(wxT("/DefaultOpenType"),mask.BeforeFirst(wxT('|')));
// Convert the type to the filter index
@ -2927,8 +2927,7 @@ void AudacityProject::OpenFiles(AudacityProject *proj)
if (AudacityProject::IsAlreadyOpen(fileName))
continue; // Skip ones that are already open.
gPrefs->Write(wxT("/DefaultOpenPath"), wxPathOnly(fileName));
gPrefs->Flush();
FileNames::UpdateDefaultPath(FileNames::Operation::Open, fileName);
// DMM: If the project is dirty, that means it's been touched at
// all, and it's not safe to open a NEW project directly in its
@ -4317,16 +4316,7 @@ bool AudacityProject::SaveAs(bool bWantSaveCompressed /*= false*/)
// Bug 1304: Set a default file path if none was given. For Save/SaveAs
if( filename.GetFullPath().IsEmpty() ){
bHasPath = false;
filename.AssignHomeDir();
#ifdef __WIN32__
filename.SetPath(gPrefs->Read( wxT("/SaveAs/Path"), filename.GetPath() + "\\Documents\\Audacity"));
// The path might not exist.
// There is no error if the path could not be created. That's OK.
// The dialog that Audacity offers will allow the user to select a valid directory.
filename.Mkdir(0755, wxPATH_MKDIR_FULL);
#else
filename.SetPath(gPrefs->Read( wxT("/SaveAs/Path"), filename.GetPath() + "/Documents"));
#endif
filename = FileNames::DefaultToDocumentsFolder(wxT("/SaveAs/Path"));
}
wxString sDialogTitle;
@ -4361,7 +4351,8 @@ For an audio file that will open in other apps, use 'Export'.\n"),
// for overwrite ourselves later, and we disallow it.
// We disallow overwrite because we would have to DELETE the many
// smaller files too, or prompt to move them.
wxString fName = FileSelector(sDialogTitle,
wxString fName = FileNames::SelectFile(FileNames::Operation::Export,
sDialogTitle,
filename.GetPath(),
filename.GetFullName(),
wxT("aup"),

View File

@ -41,7 +41,6 @@
#include <wx/window.h>
#endif
#include "FileDialog.h"
#include "FileNames.h"
#include "Internat.h"
#include "Prefs.h"
@ -51,6 +50,7 @@
#include <wx/button.h>
#include <wx/choice.h>
#include <wx/filedlg.h>
#include <wx/filename.h>
#include <wx/intl.h>
#include <wx/listctrl.h>
@ -1152,7 +1152,8 @@ void TagsEditor::OnLoad(wxCommandEvent & WXUNUSED(event))
wxString fn;
// Ask the user for the real name
fn = FileSelector(_("Load Metadata As:"),
fn = FileNames::SelectFile(FileNames::Operation::None,
_("Load Metadata As:"),
FileNames::DataDir(),
wxT("Tags.xml"),
wxT("xml"),
@ -1206,7 +1207,8 @@ void TagsEditor::OnSave(wxCommandEvent & WXUNUSED(event))
TransferDataFromWindow();
// Ask the user for the real name
fn = FileSelector(_("Save Metadata As:"),
fn = FileNames::SelectFile(FileNames::Operation::None,
_("Save Metadata As:"),
FileNames::DataDir(),
wxT("Tags.xml"),
wxT("xml"),

View File

@ -25,6 +25,7 @@
#include <wx/defs.h>
#include <wx/dir.h>
#include <wx/datetime.h>
#include <wx/filedlg.h>
#include <wx/intl.h>
#include <wx/progdlg.h>
#include <wx/sizer.h>
@ -291,7 +292,8 @@ void TimerRecordDialog::OnTimeText_Duration(wxCommandEvent& WXUNUSED(event))
// New events for timer recording automation
void TimerRecordDialog::OnAutoSavePathButton_Click(wxCommandEvent& WXUNUSED(event))
{
wxString fName = FileSelector(_("Save Timer Recording As"),
wxString fName = FileNames::SelectFile(FileNames::Operation::Export,
_("Save Timer Recording As"),
m_fnAutoSaveFile.GetPath(),
m_fnAutoSaveFile.GetFullName(),
wxT("aup"),

View File

@ -20,7 +20,6 @@
#include "../widgets/LinkingHtmlWindow.h"
#include "../widgets/HelpSystem.h"
#include "../widgets/NumericTextCtrl.h"
#include "../lib-src/FileDialog/FileDialog.h"
#include <cmath>
#include <limits>
@ -30,6 +29,7 @@
#define finite(x) _finite(x)
#endif
#include <wx/filedlg.h>
#include <wx/valtext.h>
#include <wx/log.h>
@ -489,7 +489,8 @@ void ContrastDialog::OnExport(wxCommandEvent & WXUNUSED(event))
AudacityProject * project = GetActiveProject();
wxString fName = wxT("contrast.txt");
fName = FileSelector(_("Export Contrast Result As:"),
fName = FileNames::SelectFile(FileNames::Operation::Export,
_("Export Contrast Result As:"),
wxEmptyString,
fName,
wxT("txt"),

View File

@ -78,7 +78,6 @@
// TODO: Unfortunately we have some dependencies on Audacity provided
// dialogs, widgets and other stuff. This will need to be cleaned up.
#include "FileDialog.h"
#include "../../FileNames.h"
#include "../../Internat.h"
#include "../../PlatformCompatibility.h"
@ -1798,8 +1797,9 @@ void VSTEffect::ExportPresets()
// Ask the user for the real name
//
// Passing a valid parent will cause some effects dialogs to malfunction
// upon returning from the FileSelector().
path = FileSelector(_("Save VST Preset As:"),
// upon returning from the FileNames::SelectFile().
path = FileNames::SelectFile(FileNames::Operation::None,
_("Save VST Preset As:"),
FileNames::DataDir(),
wxEmptyString,
wxT("xml"),
@ -1850,7 +1850,8 @@ void VSTEffect::ImportPresets()
wxString path;
// Ask the user for the real name
path = FileSelector(_("Load VST Preset:"),
path = FileNames::SelectFile(FileNames::Operation::None,
_("Load VST Preset:"),
FileNames::DataDir(),
wxEmptyString,
wxT("xml"),

View File

@ -69,6 +69,7 @@
#include "../widgets/Warning.h"
#include "../AColor.h"
#include "../Dependencies.h"
#include "../FileNames.h"
//----------------------------------------------------------------------------
// ExportPlugin
@ -524,18 +525,7 @@ bool Exporter::GetFilename()
wxString defext = mPlugins[mFormat]->GetExtension(mSubFormat).Lower();
//Bug 1304: Set a default path if none was given. For Export.
#ifdef __WIN32__
wxFileName tmpFile;
tmpFile.AssignHomeDir();
wxString tmpDirLoc = tmpFile.GetPath(wxPATH_GET_VOLUME);
mFilename.SetPath(gPrefs->Read(wxT("/Export/Path"), tmpDirLoc + "\\Documents\\Audacity"));
// The path might not exist.
// There is no error if the path could not be created. That's OK.
// The dialog that Audacity offers will allow the user to select a valid directory.
mFilename.Mkdir(0755, wxPATH_MKDIR_FULL);
#else
mFilename.SetPath(gPrefs->Read(wxT("/Export/Path"), wxT("~/Documents")));
#endif
mFilename = FileNames::DefaultToDocumentsFolder(wxT("/Export/Path"));
mFilename.SetName(mProject->GetName());
if (mFilename.GetName().empty())
mFilename.SetName(_("untitled"));

View File

@ -21,8 +21,8 @@
#include "../SampleFormat.h"
#include "../widgets/wxPanelWrapper.h"
#include "FileDialog.h"
class FileDialog;
class wxFileCtrlEvent;
class wxMemoryDC;
class wxStaticText;
class AudacityProject;

View File

@ -18,12 +18,13 @@
#include <wx/app.h>
#include <wx/button.h>
#include <wx/combobox.h>
#include <wx/filedlg.h>
#include <wx/log.h>
#include <wx/msgdlg.h>
#include <wx/process.h>
#include <wx/sizer.h>
#include <wx/textctrl.h>
#include <FileDialog.h>
#include "FileNames.h"
#include "Export.h"
#include "../Mix.h"
@ -169,7 +170,8 @@ void ExportCLOptions::OnBrowse(wxCommandEvent& WXUNUSED(event))
ext = wxT(".exe");
#endif
path = FileSelector(_("Find path to command"),
path = FileNames::SelectFile(FileNames::Operation::Open,
_("Find path to command"),
wxEmptyString,
wxEmptyString,
ext,

View File

@ -53,6 +53,7 @@
#include <wx/spinctrl.h>
#include <wx/combobox.h>
#include <wx/listimpl.cpp>
#include <FileDialog.h>
#include "../FileFormats.h"
#include "../Internat.h"

View File

@ -69,6 +69,7 @@
#include <wx/checkbox.h>
#include <wx/dynlib.h>
#include <wx/ffile.h>
#include <wx/filedlg.h>
#include <wx/intl.h>
#include <wx/log.h>
#include <wx/mimetype.h>
@ -91,8 +92,6 @@
#include "../Track.h"
#include "../widgets/LinkingHtmlWindow.h"
#include "FileDialog.h"
#include "Export.h"
#include <lame/lame.h>
@ -661,7 +660,8 @@ public:
* "Where would I find the file %s" instead if you want. */
question.Printf(_("Where is %s?"), mName.c_str());
wxString path = FileSelector(question,
wxString path = FileNames::SelectFile(FileNames::Operation::None,
question,
mLibPath.GetPath(),
mLibPath.GetName(),
wxT(""),

View File

@ -241,13 +241,7 @@ void ExportMultiple::PopulateOrExchange(ShuttleGui& S)
// Bug 1304: Set the default file path. It's used if none stored in config.
wxFileName filename("foo");
filename.AssignHomeDir();
#ifdef __WIN32__
filename.SetPath(filename.GetPath() + "\\Documents\\Audacity");
#else
filename.SetPath(filename.GetPath() + "/Documents");
#endif
auto filename = FileNames::DefaultToDocumentsFolder(wxT("/Export/Path"));
wxString DefaultPath = filename.GetPath();
if (mPluginIndex == -1)
@ -268,7 +262,7 @@ void ExportMultiple::PopulateOrExchange(ShuttleGui& S)
mDir = S.Id(DirID)
.TieTextBox(_("Folder:"),
wxT("/Export/MultiplePath"),
gPrefs->Read(wxT("/Export/Path"), DefaultPath ),
DefaultPath,
64);
S.Id(ChooseID).AddButton(_("Choose..."));
S.Id(CreateID).AddButton(_("Create"));

View File

@ -39,7 +39,7 @@ KeyConfigPrefs and MousePrefs use.
#include "../Internat.h"
#include "../ShuttleGui.h"
#include "FileDialog.h"
#include "FileNames.h"
#if defined(EXPERIMENTAL_KEY_VIEW)
@ -333,11 +333,10 @@ void KeyConfigPrefs::RefreshBindings(bool bSort)
void KeyConfigPrefs::OnImport(wxCommandEvent & WXUNUSED(event))
{
wxString file = wxT("Audacity-keys.xml");
wxString path = gPrefs->Read(wxT("/DefaultOpenPath"),
::wxGetCwd());
file = FileSelector(_("Select an XML file containing Audacity keyboard shortcuts..."),
path,
file = FileNames::SelectFile(FileNames::Operation::Open,
_("Select an XML file containing Audacity keyboard shortcuts..."),
wxEmptyString,
file,
wxT(""),
_("XML files (*.xml)|*.xml|All files|*"),
@ -348,10 +347,6 @@ void KeyConfigPrefs::OnImport(wxCommandEvent & WXUNUSED(event))
return;
}
path = wxPathOnly(file);
gPrefs->Write(wxT("/DefaultOpenPath"), path);
gPrefs->Flush();
XMLFileReader reader;
if (!reader.Parse(mManager, file)) {
wxMessageBox(reader.GetErrorStr(),
@ -365,11 +360,10 @@ void KeyConfigPrefs::OnImport(wxCommandEvent & WXUNUSED(event))
void KeyConfigPrefs::OnExport(wxCommandEvent & WXUNUSED(event))
{
wxString file = wxT("Audacity-keys.xml");
wxString path = gPrefs->Read(wxT("/DefaultExportPath"),
::wxGetCwd());
file = FileSelector(_("Export Keyboard Shortcuts As:"),
path,
file = FileNames::SelectFile(FileNames::Operation::Export,
_("Export Keyboard Shortcuts As:"),
wxEmptyString,
file,
wxT("xml"),
_("XML files (*.xml)|*.xml|All files|*"),
@ -380,10 +374,6 @@ void KeyConfigPrefs::OnExport(wxCommandEvent & WXUNUSED(event))
return;
}
path = wxPathOnly(file);
gPrefs->Write(wxT("/DefaultExportPath"), path);
gPrefs->Flush();
GuardedCall< void >( [&] {
XMLFileWriter prefFile{ file, _("Error Exporting Keyboard Shortcuts") };
mManager->WriteXML(prefFile);
@ -993,11 +983,10 @@ void KeyConfigPrefs::RepopulateBindingsList()
void KeyConfigPrefs::OnImport(wxCommandEvent & WXUNUSED(event))
{
wxString file = wxT("Audacity-keys.xml");
wxString path = gPrefs->Read(wxT("/DefaultOpenPath"),
::wxGetCwd());
file = FileSelector(_("Select an XML file containing Audacity keyboard shortcuts..."),
path,
file = FileNames::SelectFile(FileNames::Operation::Open,
_("Select an XML file containing Audacity keyboard shortcuts..."),
wxEmptyString,
file,
wxT(""),
_("XML files (*.xml)|*.xml|All files|*"),
@ -1008,10 +997,6 @@ void KeyConfigPrefs::OnImport(wxCommandEvent & WXUNUSED(event))
return;
}
path = wxPathOnly(file);
gPrefs->Write(wxT("/DefaultOpenPath"), path);
gPrefs->Flush();
XMLFileReader reader;
if (!reader.Parse(mManager, file)) {
wxMessageBox(reader.GetErrorStr(),
@ -1025,10 +1010,9 @@ void KeyConfigPrefs::OnImport(wxCommandEvent & WXUNUSED(event))
void KeyConfigPrefs::OnExport(wxCommandEvent & WXUNUSED(event))
{
wxString file = wxT("Audacity-keys.xml");
wxString path = gPrefs->Read(wxT("/DefaultExportPath"),
::wxGetCwd());
file = FileSelector(_("Export Keyboard Shortcuts As:"),
file = FileNames::SelectFile(FileNames::Operation::Export,
_("Export Keyboard Shortcuts As:"),
path,
file,
wxT("xml"),
@ -1040,10 +1024,6 @@ void KeyConfigPrefs::OnExport(wxCommandEvent & WXUNUSED(event))
return;
}
path = wxPathOnly(file);
gPrefs->Write(wxT("/DefaultExportPath"), path);
gPrefs->Flush();
GuardedCall< void >( [&] {
XMLFileWriter prefFile{ file, _("Error Exporting Keyboard Shortcuts") };
mManager->WriteXML(prefFile);