mirror of
https://github.com/cookiengineer/audacity
synced 2025-04-30 23:59:41 +02:00
Defaulting of file paths to Documents is defined in just one place
This commit is contained in:
parent
d7ac0d30db
commit
a9d4c2c05b
@ -30,6 +30,7 @@ used throughout Audacity into this one place.
|
||||
#include "FileNames.h"
|
||||
#include "Internat.h"
|
||||
#include "PlatformCompatibility.h"
|
||||
#include "wxFileNameWrapper.h"
|
||||
|
||||
#if defined(__WXMAC__) || defined(__WXGTK__)
|
||||
#include <dlfcn.h>
|
||||
@ -315,3 +316,23 @@ 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;
|
||||
}
|
||||
|
@ -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,9 @@ public:
|
||||
// Obtain name of loaded module that contains address
|
||||
static wxString PathFromAddr(void *addr);
|
||||
|
||||
static wxFileNameWrapper DefaultToDocumentsFolder
|
||||
(const wxString &preference);
|
||||
|
||||
private:
|
||||
// Private constructors: No one is ever going to instantiate it.
|
||||
//
|
||||
|
@ -4317,16 +4317,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;
|
||||
|
@ -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"));
|
||||
|
@ -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"));
|
||||
|
Loading…
x
Reference in New Issue
Block a user