AUP3: Fix unopened project file
This commit is contained in:
parent
8f1e52c1c2
commit
03762d0ca3
|
@ -13,6 +13,7 @@ Paul Licameli split from AutoRecovery.cpp
|
||||||
#include "ActiveProjects.h"
|
#include "ActiveProjects.h"
|
||||||
#include "FileNames.h"
|
#include "FileNames.h"
|
||||||
#include "ProjectManager.h"
|
#include "ProjectManager.h"
|
||||||
|
#include "ProjectFileIO.h"
|
||||||
#include "ShuttleGui.h"
|
#include "ShuttleGui.h"
|
||||||
#include "widgets/AudacityMessageBox.h"
|
#include "widgets/AudacityMessageBox.h"
|
||||||
#include "widgets/wxPanelWrapper.h"
|
#include "widgets/wxPanelWrapper.h"
|
||||||
|
@ -35,7 +36,7 @@ enum {
|
||||||
class AutoRecoveryDialog final : public wxDialogWrapper
|
class AutoRecoveryDialog final : public wxDialogWrapper
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AutoRecoveryDialog();
|
AutoRecoveryDialog(AudacityProject *proj);
|
||||||
|
|
||||||
bool HasRecoverables() const;
|
bool HasRecoverables() const;
|
||||||
FilePaths GetRecoverables();
|
FilePaths GetRecoverables();
|
||||||
|
@ -50,6 +51,7 @@ private:
|
||||||
|
|
||||||
FilePaths mFiles;
|
FilePaths mFiles;
|
||||||
wxListCtrl *mFileList;
|
wxListCtrl *mFileList;
|
||||||
|
AudacityProject *mProject;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
|
@ -61,10 +63,11 @@ BEGIN_EVENT_TABLE(AutoRecoveryDialog, wxDialogWrapper)
|
||||||
EVT_BUTTON(ID_RECOVER_SELECTED, AutoRecoveryDialog::OnRecoverSelected)
|
EVT_BUTTON(ID_RECOVER_SELECTED, AutoRecoveryDialog::OnRecoverSelected)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
AutoRecoveryDialog::AutoRecoveryDialog()
|
AutoRecoveryDialog::AutoRecoveryDialog(AudacityProject *project)
|
||||||
: wxDialogWrapper(nullptr, wxID_ANY, XO("Automatic Crash Recovery"),
|
: wxDialogWrapper(nullptr, wxID_ANY, XO("Automatic Crash Recovery"),
|
||||||
wxDefaultPosition, wxDefaultSize,
|
wxDefaultPosition, wxDefaultSize,
|
||||||
wxDEFAULT_DIALOG_STYLE & (~wxCLOSE_BOX)) // no close box
|
wxDEFAULT_DIALOG_STYLE & (~wxCLOSE_BOX)), // no close box
|
||||||
|
mProject(project)
|
||||||
{
|
{
|
||||||
SetName();
|
SetName();
|
||||||
ShuttleGui S(this, eIsCreating);
|
ShuttleGui S(this, eIsCreating);
|
||||||
|
@ -138,6 +141,13 @@ void AutoRecoveryDialog::PopulateList()
|
||||||
wxString pattern = wxT("*.") + FileNames::UnsavedProjectExtension();
|
wxString pattern = wxT("*.") + FileNames::UnsavedProjectExtension();
|
||||||
FilePaths files;
|
FilePaths files;
|
||||||
|
|
||||||
|
FilePath activeFile;
|
||||||
|
if (mProject)
|
||||||
|
{
|
||||||
|
auto &projectFileIO = ProjectFileIO::Get(*mProject);
|
||||||
|
activeFile = projectFileIO.GetFileName();
|
||||||
|
}
|
||||||
|
|
||||||
// wxDir::GetAllFiles(tempdir, &files, pattern, wxDIR_FILES);
|
// wxDir::GetAllFiles(tempdir, &files, pattern, wxDIR_FILES);
|
||||||
|
|
||||||
FilePaths active = ActiveProjects::GetAll();
|
FilePaths active = ActiveProjects::GetAll();
|
||||||
|
@ -148,12 +158,15 @@ void AutoRecoveryDialog::PopulateList()
|
||||||
for (auto file : active)
|
for (auto file : active)
|
||||||
{
|
{
|
||||||
wxFileName fn = file;
|
wxFileName fn = file;
|
||||||
if (fn.FileExists())
|
if (fn != activeFile)
|
||||||
{
|
{
|
||||||
FilePath fullPath = fn.GetFullPath();
|
if (fn.FileExists())
|
||||||
if (files.Index(fullPath) == wxNOT_FOUND)
|
|
||||||
{
|
{
|
||||||
files.push_back(fullPath);
|
FilePath fullPath = fn.GetFullPath();
|
||||||
|
if (files.Index(fullPath) == wxNOT_FOUND)
|
||||||
|
{
|
||||||
|
files.push_back(fullPath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -333,7 +346,7 @@ bool ShowAutoRecoveryDialogIfNeeded(AudacityProject **pproj, bool *didRecoverAny
|
||||||
// This must be done before "dlg" is declared.
|
// This must be done before "dlg" is declared.
|
||||||
wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI);
|
wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI);
|
||||||
|
|
||||||
AutoRecoveryDialog dialog;
|
AutoRecoveryDialog dialog(*pproj);
|
||||||
|
|
||||||
if (dialog.HasRecoverables())
|
if (dialog.HasRecoverables())
|
||||||
{
|
{
|
||||||
|
|
|
@ -256,6 +256,11 @@ ProjectFileIO::~ProjectFileIO()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ProjectFileIO::OpenProject()
|
||||||
|
{
|
||||||
|
return OpenConnection();
|
||||||
|
}
|
||||||
|
|
||||||
sqlite3 *ProjectFileIO::DB()
|
sqlite3 *ProjectFileIO::DB()
|
||||||
{
|
{
|
||||||
auto &curConn = CurrConn();
|
auto &curConn = CurrConn();
|
||||||
|
|
|
@ -78,11 +78,13 @@ public:
|
||||||
bool AutoSave(bool recording = false);
|
bool AutoSave(bool recording = false);
|
||||||
bool AutoSaveDelete(sqlite3 *db = nullptr);
|
bool AutoSaveDelete(sqlite3 *db = nullptr);
|
||||||
|
|
||||||
|
bool OpenProject();
|
||||||
|
bool CloseProject();
|
||||||
|
|
||||||
bool ImportProject(const FilePath &fileName);
|
bool ImportProject(const FilePath &fileName);
|
||||||
bool LoadProject(const FilePath &fileName);
|
bool LoadProject(const FilePath &fileName);
|
||||||
bool SaveProject(const FilePath &fileName);
|
bool SaveProject(const FilePath &fileName);
|
||||||
bool SaveCopy(const FilePath& fileName);
|
bool SaveCopy(const FilePath& fileName);
|
||||||
bool CloseProject();
|
|
||||||
|
|
||||||
wxLongLong GetFreeDiskSpace();
|
wxLongLong GetFreeDiskSpace();
|
||||||
|
|
||||||
|
|
|
@ -704,6 +704,14 @@ void ProjectFileManager::VacuumProject()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ProjectFileManager::OpenProject()
|
||||||
|
{
|
||||||
|
auto &project = mProject;
|
||||||
|
auto &projectFileIO = ProjectFileIO::Get(project);
|
||||||
|
|
||||||
|
return projectFileIO.OpenProject();
|
||||||
|
}
|
||||||
|
|
||||||
void ProjectFileManager::CloseProject()
|
void ProjectFileManager::CloseProject()
|
||||||
{
|
{
|
||||||
auto &project = mProject;
|
auto &project = mProject;
|
||||||
|
|
|
@ -50,9 +50,11 @@ public:
|
||||||
};
|
};
|
||||||
ReadProjectResults ReadProjectFile( const FilePath &fileName );
|
ReadProjectResults ReadProjectFile( const FilePath &fileName );
|
||||||
|
|
||||||
void VacuumProject();
|
bool OpenProject();
|
||||||
void CloseProject();
|
void CloseProject();
|
||||||
|
|
||||||
|
void VacuumProject();
|
||||||
|
|
||||||
bool Save();
|
bool Save();
|
||||||
bool SaveAs();
|
bool SaveAs();
|
||||||
bool SaveAs(const FilePath &newFileName, bool addToHistory = true);
|
bool SaveAs(const FilePath &newFileName, bool addToHistory = true);
|
||||||
|
|
|
@ -535,9 +535,9 @@ AudacityProject *ProjectManager::New()
|
||||||
auto &window = ProjectWindow::Get( *p );
|
auto &window = ProjectWindow::Get( *p );
|
||||||
InitProjectWindow( window );
|
InitProjectWindow( window );
|
||||||
|
|
||||||
auto &projectFileIO = ProjectFileIO::Get( *p );
|
auto &projectFileManager = ProjectFileManager::Get( *p );
|
||||||
projectFileIO.SetProjectTitle();
|
projectFileManager.OpenProject();
|
||||||
|
|
||||||
MenuManager::Get( project ).CreateMenusAndCommands( project );
|
MenuManager::Get( project ).CreateMenusAndCommands( project );
|
||||||
|
|
||||||
projectHistory.InitialState();
|
projectHistory.InitialState();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user