23#include <wx/evtloop.h>
25#include <wx/filename.h>
26#include <wx/listctrl.h>
52 void OnSkip(wxCommandEvent &evt);
76 wxDefaultPosition, wxDefaultSize,
77 (wxDEFAULT_DIALOG_STYLE & (~wxCLOSE_BOX)) | wxRESIZE_BORDER),
82 PopulateOrExchange(
S);
98 S.StartVerticalLay(wxEXPAND, 1);
101 XO(
"The following projects were not saved properly the last time Audacity was run and "
102 "can be automatically recovered.\n\n"
103 "After recovery, save the projects to ensure changes are written to disk."),
107 S.StartStatic(
XO(
"Recoverable &projects"), 1);
111 .AddListControlReportMode(
123 S.StartHorizontalLay(wxALIGN_CENTRE, 0);
133 S.EndHorizontalLay();
139 SetMinSize(GetSize());
153 wxDir::GetAllFiles(tempdir, &files, pattern, wxDIR_FILES);
157 for (
auto file : active)
159 wxFileName
fn = file;
163 if (files.Index(fullPath) == wxNOT_FOUND)
165 files.push_back(fullPath);
178 activeFile = projectFileIO.GetFileName();
185 for (
auto file : files)
187 wxFileName
fn = file;
188 if (
fn != activeFile)
198 mFileList->SetColumnWidth(0, wxLIST_AUTOSIZE_USEHEADER);
204 wxLIST_STATE_FOCUSED | wxLIST_STATE_SELECTED,
205 wxLIST_STATE_FOCUSED | wxLIST_STATE_SELECTED);
215 item =
mFileList->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_DONTCARE);
216 if (item == wxNOT_FOUND)
244 bool selectedTemporary =
false;
245 while (!selectedTemporary)
247 item =
mFileList->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_DONTCARE);
248 if (item == wxNOT_FOUND)
253 wxFileName file(fileName);
255 selectedTemporary =
true;
260 if (selectedTemporary) {
262 XO(
"Are you sure you want to discard the selected projects?\n\n"
263 "Choosing \"Yes\" permanently deletes the selected projects immediately."),
264 XO(
"Automatic Crash Recovery"),
265 wxICON_QUESTION | wxYES_NO | wxNO_DEFAULT,
this);
275 item =
mFileList->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_DONTCARE);
276 if (item == wxNOT_FOUND)
283 files.push_back(
mFiles[item]);
289 wxFileName file(fileName);
292 file.SetFullName(
wxT(
""));
301 files.push_back(fileName);
326 bool selected =
false;
330 item =
mFileList->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_DONTCARE);
331 if (item == wxNOT_FOUND)
346 files.push_back(
mFiles[item]);
361 if (evt.GetColumn() != 0)
369 item =
mFileList->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_DONTCARE);
370 if (item == wxNOT_FOUND)
380 long item = evt.GetIndex();
386 switch (evt.GetKeyCode())
390 bool selected =
false;
394 item =
mFileList->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
395 if (item == wxNOT_FOUND)
408 EmulateButtonClickIfPresent(GetAffirmativeId());
426 for (
auto &file: files)
446 for (
auto &file: files)
452 if (didRecoverAnything)
454 *didRecoverAnything =
false;
471 wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI | wxEVT_CATEGORY_USER_INPUT);
477 int ret = dialog.ShowModal();
494 if (didRecoverAnything)
496 *didRecoverAnything =
true;
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
bool ShowAutoRecoveryDialogIfNeeded(AudacityProject *&pproj, bool *didRecoverAnything)
static void DiscardAllProjects(const FilePaths &files)
static bool RecoverAllProjects(const FilePaths &files, AudacityProject *&pproj)
EVT_BUTTON(wxID_NO, DependencyDialog::OnNo) EVT_BUTTON(wxID_YES
XXO("&Cut/Copy/Paste Toolbar")
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
AutoRecoveryDialog(AudacityProject *proj)
void OnQuitAudacity(wxCommandEvent &evt)
void OnItemActivated(wxListEvent &evt)
void OnListKeyDown(wxKeyEvent &evt)
bool HasRecoverables() const
void PopulateOrExchange(ShuttleGui &S)
void OnDiscardSelected(wxCommandEvent &evt)
FilePaths GetRecoverables()
void OnRecoverSelected(wxCommandEvent &evt)
AudacityProject * mProject
void OnColumnClicked(wxListEvent &evt)
void OnSkip(wxCommandEvent &evt)
static bool RemoveProject(const FilePath &filename)
Remove any files associated with a project at given path; return true if successful.
static ProjectFileIO & Get(AudacityProject &project)
static void DiscardAutosave(const FilePath &filename)
static AudacityProject * OpenProject(AudacityProject *pGivenProject, const FilePath &fileNameArg, bool addtohistory, bool reuseNonemptyProject)
Open a file into an AudacityProject, returning the project, or nullptr for failure.
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.
PROJECT_FILE_IO_API void Remove(const FilePath &path)
PROJECT_FILE_IO_API FilePaths GetAll()
FILES_API wxString UnsavedProjectExtension()
FILES_API wxString TempDir()
void swap(std::unique_ptr< Alg_seq > &a, std::unique_ptr< Alg_seq > &b)