mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-15 15:49:36 +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 "FileNames.h"
|
||||||
#include "Internat.h"
|
#include "Internat.h"
|
||||||
#include "PlatformCompatibility.h"
|
#include "PlatformCompatibility.h"
|
||||||
|
#include "wxFileNameWrapper.h"
|
||||||
|
|
||||||
#if defined(__WXMAC__) || defined(__WXGTK__)
|
#if defined(__WXMAC__) || defined(__WXGTK__)
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
@ -315,3 +316,23 @@ wxString FileNames::PathFromAddr(void *addr)
|
|||||||
|
|
||||||
return name.GetFullPath();
|
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"
|
#include "Audacity.h"
|
||||||
|
|
||||||
class wxFileName;
|
class wxFileName;
|
||||||
|
class wxFileNameWrapper;
|
||||||
class wxArrayString;
|
class wxArrayString;
|
||||||
|
|
||||||
// Uh, this is really a namespace rather than a class,
|
// Uh, this is really a namespace rather than a class,
|
||||||
@ -65,6 +66,9 @@ public:
|
|||||||
// Obtain name of loaded module that contains address
|
// Obtain name of loaded module that contains address
|
||||||
static wxString PathFromAddr(void *addr);
|
static wxString PathFromAddr(void *addr);
|
||||||
|
|
||||||
|
static wxFileNameWrapper DefaultToDocumentsFolder
|
||||||
|
(const wxString &preference);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Private constructors: No one is ever going to instantiate it.
|
// 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
|
// Bug 1304: Set a default file path if none was given. For Save/SaveAs
|
||||||
if( filename.GetFullPath().IsEmpty() ){
|
if( filename.GetFullPath().IsEmpty() ){
|
||||||
bHasPath = false;
|
bHasPath = false;
|
||||||
filename.AssignHomeDir();
|
filename = FileNames::DefaultToDocumentsFolder(wxT("/SaveAs/Path"));
|
||||||
#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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString sDialogTitle;
|
wxString sDialogTitle;
|
||||||
|
@ -69,6 +69,7 @@
|
|||||||
#include "../widgets/Warning.h"
|
#include "../widgets/Warning.h"
|
||||||
#include "../AColor.h"
|
#include "../AColor.h"
|
||||||
#include "../Dependencies.h"
|
#include "../Dependencies.h"
|
||||||
|
#include "../FileNames.h"
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// ExportPlugin
|
// ExportPlugin
|
||||||
@ -524,18 +525,7 @@ bool Exporter::GetFilename()
|
|||||||
wxString defext = mPlugins[mFormat]->GetExtension(mSubFormat).Lower();
|
wxString defext = mPlugins[mFormat]->GetExtension(mSubFormat).Lower();
|
||||||
|
|
||||||
//Bug 1304: Set a default path if none was given. For Export.
|
//Bug 1304: Set a default path if none was given. For Export.
|
||||||
#ifdef __WIN32__
|
mFilename = FileNames::DefaultToDocumentsFolder(wxT("/Export/Path"));
|
||||||
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.SetName(mProject->GetName());
|
mFilename.SetName(mProject->GetName());
|
||||||
if (mFilename.GetName().empty())
|
if (mFilename.GetName().empty())
|
||||||
mFilename.SetName(_("untitled"));
|
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.
|
// Bug 1304: Set the default file path. It's used if none stored in config.
|
||||||
wxFileName filename("foo");
|
auto filename = FileNames::DefaultToDocumentsFolder(wxT("/Export/Path"));
|
||||||
filename.AssignHomeDir();
|
|
||||||
#ifdef __WIN32__
|
|
||||||
filename.SetPath(filename.GetPath() + "\\Documents\\Audacity");
|
|
||||||
#else
|
|
||||||
filename.SetPath(filename.GetPath() + "/Documents");
|
|
||||||
#endif
|
|
||||||
wxString DefaultPath = filename.GetPath();
|
wxString DefaultPath = filename.GetPath();
|
||||||
|
|
||||||
if (mPluginIndex == -1)
|
if (mPluginIndex == -1)
|
||||||
@ -268,7 +262,7 @@ void ExportMultiple::PopulateOrExchange(ShuttleGui& S)
|
|||||||
mDir = S.Id(DirID)
|
mDir = S.Id(DirID)
|
||||||
.TieTextBox(_("Folder:"),
|
.TieTextBox(_("Folder:"),
|
||||||
wxT("/Export/MultiplePath"),
|
wxT("/Export/MultiplePath"),
|
||||||
gPrefs->Read(wxT("/Export/Path"), DefaultPath ),
|
DefaultPath,
|
||||||
64);
|
64);
|
||||||
S.Id(ChooseID).AddButton(_("Choose..."));
|
S.Id(ChooseID).AddButton(_("Choose..."));
|
||||||
S.Id(CreateID).AddButton(_("Create"));
|
S.Id(CreateID).AddButton(_("Create"));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user