From 0c6cda50c3f6c153a415d02b276f95dd82b3a6d0 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Thu, 6 Jun 2019 11:21:15 -0400 Subject: [PATCH] Split AutoRecoveryDialog.cpp from AutoRecovery.cpp... ... leaving AutoRecovery as a lower-level file, to be used by ProjectHistory for auto-save, and not including ProjectManager. The new file floats to a high level of the graph, but AutoRecovery.cpp remains in the big strongly connected component. --- locale/POTFILES.in | 2 + mac/Audacity.xcodeproj/project.pbxproj | 6 + src/AudacityApp.cpp | 1 + src/AutoRecovery.cpp | 244 ----------------- src/AutoRecovery.h | 16 -- src/AutoRecoveryDialog.cpp | 259 ++++++++++++++++++ src/AutoRecoveryDialog.h | 32 +++ src/Makefile.am | 2 + src/Makefile.in | 174 ++++++------ win/Projects/Audacity/Audacity.vcxproj | 2 + .../Audacity/Audacity.vcxproj.filters | 6 + 11 files changed, 406 insertions(+), 338 deletions(-) create mode 100644 src/AutoRecoveryDialog.cpp create mode 100644 src/AutoRecoveryDialog.h diff --git a/locale/POTFILES.in b/locale/POTFILES.in index 63b279f05..9bf9905cf 100644 --- a/locale/POTFILES.in +++ b/locale/POTFILES.in @@ -44,6 +44,8 @@ src/AudioIO.h src/AudioIOListener.h src/AutoRecovery.cpp src/AutoRecovery.h +src/AutoRecoveryDialog.cpp +src/AutoRecoveryDialog.h src/BatchCommandDialog.cpp src/BatchCommandDialog.h src/BatchCommands.cpp diff --git a/mac/Audacity.xcodeproj/project.pbxproj b/mac/Audacity.xcodeproj/project.pbxproj index 9ece8e502..cd2fb3ce4 100644 --- a/mac/Audacity.xcodeproj/project.pbxproj +++ b/mac/Audacity.xcodeproj/project.pbxproj @@ -1232,6 +1232,7 @@ 5E18CFF02291C31000E75250 /* ProjectFileIORegistry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E18CFEE2291C31000E75250 /* ProjectFileIORegistry.cpp */; }; 5E18CFF322931D3D00E75250 /* AudacityMessageBox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E18CFF222931D3D00E75250 /* AudacityMessageBox.cpp */; }; 5E19D655217D51190024D0B1 /* PluginMenus.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E19D64C217D51190024D0B1 /* PluginMenus.cpp */; }; + 5E19F59922A9665500E3F88E /* AutoRecoveryDialog.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E19F59722A9665500E3F88E /* AutoRecoveryDialog.cpp */; }; 5E2A19941EED688500217B58 /* SelectionState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E2A19921EED688500217B58 /* SelectionState.cpp */; }; 5E36A0A8217FA2430068E082 /* EditMenus.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E36A09F217FA2430068E082 /* EditMenus.cpp */; }; 5E36A0A9217FA2430068E082 /* ExtraMenus.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E36A0A0217FA2430068E082 /* ExtraMenus.cpp */; }; @@ -3222,6 +3223,8 @@ 5E18CFF122931CA900E75250 /* AudacityMessageBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudacityMessageBox.h; sourceTree = ""; }; 5E18CFF222931D3D00E75250 /* AudacityMessageBox.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AudacityMessageBox.cpp; sourceTree = ""; }; 5E19D64C217D51190024D0B1 /* PluginMenus.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PluginMenus.cpp; path = menus/PluginMenus.cpp; sourceTree = ""; }; + 5E19F59722A9665500E3F88E /* AutoRecoveryDialog.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AutoRecoveryDialog.cpp; sourceTree = ""; }; + 5E19F59822A9665500E3F88E /* AutoRecoveryDialog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AutoRecoveryDialog.h; sourceTree = ""; }; 5E2A19921EED688500217B58 /* SelectionState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SelectionState.cpp; sourceTree = ""; }; 5E2A19931EED688500217B58 /* SelectionState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SelectionState.h; sourceTree = ""; }; 5E36A09F217FA2430068E082 /* EditMenus.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = EditMenus.cpp; path = menus/EditMenus.cpp; sourceTree = ""; }; @@ -4328,6 +4331,7 @@ 28C3946B1818356800FDDAC9 /* AudacityLogger.cpp */, 1790AFD209883BFD008A330A /* AudioIO.cpp */, 28560C8F0A75E40F00A3429E /* AutoRecovery.cpp */, + 5E19F59722A9665500E3F88E /* AutoRecoveryDialog.cpp */, 1790AFD409883BFD008A330A /* BatchCommandDialog.cpp */, 1790AFD609883BFD008A330A /* BatchCommands.cpp */, 1790AFD809883BFD008A330A /* BatchProcessDialog.cpp */, @@ -4437,6 +4441,7 @@ 1790AFD309883BFD008A330A /* AudioIO.h */, 28F996D91A2A9261008FEEF3 /* AudioIOListener.h */, 28560C900A75E40F00A3429E /* AutoRecovery.h */, + 5E19F59822A9665500E3F88E /* AutoRecoveryDialog.h */, 1790AFD509883BFD008A330A /* BatchCommandDialog.h */, 1790AFD709883BFD008A330A /* BatchCommands.h */, 1790AFD909883BFD008A330A /* BatchProcessDialog.h */, @@ -8521,6 +8526,7 @@ 5EA0182C1EC7B226001F2996 /* WaveTrackUI.cpp in Sources */, 5E07842E1DEE6B8600CA76EA /* FileException.cpp in Sources */, 2860BA250E0F0D8600A13878 /* TimerRecordDialog.cpp in Sources */, + 5E19F59922A9665500E3F88E /* AutoRecoveryDialog.cpp in Sources */, 2860BA280E0F0DD800A13878 /* ExportFFmpeg.cpp in Sources */, 5E36A0AB217FA2430068E082 /* NavigationMenus.cpp in Sources */, 28D587CB0E264CF4009C7DEA /* LoadLV2.cpp in Sources */, diff --git a/src/AudacityApp.cpp b/src/AudacityApp.cpp index 05d8118a4..cb207e638 100644 --- a/src/AudacityApp.cpp +++ b/src/AudacityApp.cpp @@ -96,6 +96,7 @@ It handles initialization and termination by subclassing wxApp. #include "PlatformCompatibility.h" #include "FileNames.h" #include "AutoRecovery.h" +#include "AutoRecoveryDialog.h" #include "SplashDialog.h" #include "FFT.h" #include "BlockFile.h" diff --git a/src/AutoRecovery.cpp b/src/AutoRecovery.cpp index 59e15ab5a..cb54f2a74 100644 --- a/src/AutoRecovery.cpp +++ b/src/AutoRecovery.cpp @@ -21,261 +21,17 @@ text or binary format to a file. #include "Audacity.h" #include "AutoRecovery.h" #include "DirManager.h" -#include "FileNames.h" #include "blockfile/SimpleBlockFile.h" -#include "ProjectManager.h" #include "Sequence.h" -#include "ShuttleGui.h" -#include #include #include -#include #include #include #include #include "WaveClip.h" #include "WaveTrack.h" -#include "widgets/AudacityMessageBox.h" -#include "widgets/wxPanelWrapper.h" - -enum { - ID_RECOVER_ALL = 10000, - ID_RECOVER_NONE, - ID_QUIT_AUDACITY, - ID_FILE_LIST -}; - -class AutoRecoveryDialog final : public wxDialogWrapper -{ -public: - AutoRecoveryDialog(wxWindow *parent); - -private: - void PopulateList(); - void PopulateOrExchange(ShuttleGui & S); - - void OnQuitAudacity(wxCommandEvent &evt); - void OnRecoverNone(wxCommandEvent &evt); - void OnRecoverAll(wxCommandEvent &evt); - - wxListCtrl *mFileList; - -public: - DECLARE_EVENT_TABLE() -}; - -AutoRecoveryDialog::AutoRecoveryDialog(wxWindow *parent) : - wxDialogWrapper(parent, -1, _("Automatic Crash Recovery"), - wxDefaultPosition, wxDefaultSize, - wxDEFAULT_DIALOG_STYLE & (~wxCLOSE_BOX)) // no close box -{ - SetName(GetTitle()); - ShuttleGui S(this, eIsCreating); - PopulateOrExchange(S); -} - -BEGIN_EVENT_TABLE(AutoRecoveryDialog, wxDialogWrapper) - EVT_BUTTON(ID_RECOVER_ALL, AutoRecoveryDialog::OnRecoverAll) - EVT_BUTTON(ID_RECOVER_NONE, AutoRecoveryDialog::OnRecoverNone) - EVT_BUTTON(ID_QUIT_AUDACITY, AutoRecoveryDialog::OnQuitAudacity) -END_EVENT_TABLE() - -void AutoRecoveryDialog::PopulateOrExchange(ShuttleGui& S) -{ - S.SetBorder(5); - S.StartVerticalLay(); - { - S.AddVariableText(_("Some projects were not saved properly the last time Audacity was run.\nFortunately, the following projects can be automatically recovered:"), false); - - S.StartStatic(_("Recoverable projects")); - { - mFileList = S.Id(ID_FILE_LIST).AddListControlReportMode(); - /*i18n-hint: (noun). It's the name of the project to recover.*/ - mFileList->InsertColumn(0, _("Name")); - mFileList->SetColumnWidth(0, wxLIST_AUTOSIZE); - PopulateList(); - } - S.EndStatic(); - - S.AddVariableText(_("After recovery, save the project to save the changes to disk."), false); - - S.StartHorizontalLay(); - { - S.Id(ID_QUIT_AUDACITY).AddButton(_("Quit Audacity")); - S.Id(ID_RECOVER_NONE).AddButton(_("Discard Projects")); - S.Id(ID_RECOVER_ALL).AddButton(_("Recover Projects")); - } - S.EndHorizontalLay(); - } - S.EndVerticalLay(); - - Layout(); - Fit(); - SetMinSize(GetSize()); - - // Sometimes it centers on wxGTK and sometimes it doesn't. - // Yielding before centering seems to be a good workaround, - // but will leave to implement on a rainy day. - Center(); -} - -void AutoRecoveryDialog::PopulateList() -{ - mFileList->DeleteAllItems(); - - wxDir dir(FileNames::AutoSaveDir()); - if (!dir.IsOpened()) - return; - - wxString filename; - int i = 0; - for (bool c = dir.GetFirst(&filename, wxT("*.autosave"), wxDIR_FILES); - c; c = dir.GetNext(&filename)) - mFileList->InsertItem(i++, wxFileName{ filename }.GetName()); - - mFileList->SetColumnWidth(0, wxLIST_AUTOSIZE); -} - -void AutoRecoveryDialog::OnQuitAudacity(wxCommandEvent & WXUNUSED(event)) -{ - EndModal(ID_QUIT_AUDACITY); -} - -void AutoRecoveryDialog::OnRecoverNone(wxCommandEvent & WXUNUSED(event)) -{ - int ret = AudacityMessageBox( - _("Are you sure you want to discard all recoverable projects?\n\nChoosing \"Yes\" discards all recoverable projects immediately."), - _("Confirm Discard Projects"), wxICON_QUESTION | wxYES_NO | wxNO_DEFAULT, this); - - if (ret == wxYES) - EndModal(ID_RECOVER_NONE); -} - -void AutoRecoveryDialog::OnRecoverAll(wxCommandEvent & WXUNUSED(event)) -{ - EndModal(ID_RECOVER_ALL); -} - -//////////////////////////////////////////////////////////////////////////// - -static bool HaveFilesToRecover() -{ - wxDir dir(FileNames::AutoSaveDir()); - if (!dir.IsOpened()) - { - AudacityMessageBox(_("Could not enumerate files in auto save directory."), - _("Error"), wxICON_STOP); - return false; - } - - wxString filename; - bool c = dir.GetFirst(&filename, wxT("*.autosave"), wxDIR_FILES); - - return c; -} - -static bool RemoveAllAutoSaveFiles() -{ - FilePaths files; - wxDir::GetAllFiles(FileNames::AutoSaveDir(), &files, - wxT("*.autosave"), wxDIR_FILES); - - for (unsigned int i = 0; i < files.size(); i++) - { - if (!wxRemoveFile(files[i])) - { - // I don't think this error message is actually useful. - // -dmazzoni - //AudacityMessageBox(wxT("Could not remove auto save file: " + files[i]), - // _("Error"), wxICON_STOP); - return false; - } - } - - return true; -} - -static bool RecoverAllProjects(AudacityProject** pproj) -{ - wxDir dir(FileNames::AutoSaveDir()); - if (!dir.IsOpened()) - { - AudacityMessageBox(_("Could not enumerate files in auto save directory."), - _("Error"), wxICON_STOP); - return false; - } - - // Open a project window for each auto save file - wxString filename; - - FilePaths files; - wxDir::GetAllFiles(FileNames::AutoSaveDir(), &files, - wxT("*.autosave"), wxDIR_FILES); - - for (unsigned int i = 0; i < files.size(); i++) - { - AudacityProject* proj{}; - if (*pproj) - { - // Reuse existing project window - proj = *pproj; - *pproj = NULL; - } - - // Open project. When an auto-save file has been opened successfully, - // the opened auto-save file is automatically deleted and a NEW one - // is created. - (void) ProjectManager::OpenProject( proj, files[i], false ); - } - - return true; -} - -bool ShowAutoRecoveryDialogIfNeeded(AudacityProject** pproj, - bool *didRecoverAnything) -{ - if (didRecoverAnything) - *didRecoverAnything = false; - if (HaveFilesToRecover()) - { - // Under wxGTK3, the auto recovery dialog will not get - // the focus since the project window hasn't been allowed - // to completely initialize. - // - // Yielding seems to allow the initialization to complete. - // - // Additionally, it also corrects a sizing issue in the dialog - // related to wxWidgets bug: - // - // http://trac.wxwidgets.org/ticket/16440 - // - // This must be done before "dlg" is declared. - wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI); - - int ret = AutoRecoveryDialog{nullptr}.ShowModal(); - - switch (ret) - { - case ID_RECOVER_NONE: - return RemoveAllAutoSaveFiles(); - - case ID_RECOVER_ALL: - if (didRecoverAnything) - *didRecoverAnything = true; - return RecoverAllProjects(pproj); - - default: - // This includes ID_QUIT_AUDACITY - return false; - } - } else - { - // Nothing to recover, move along - return true; - } -} //////////////////////////////////////////////////////////////////////////// /// Recording recovery handler diff --git a/src/AutoRecovery.h b/src/AutoRecovery.h index a79072516..1bc57c521 100644 --- a/src/AutoRecovery.h +++ b/src/AutoRecovery.h @@ -21,22 +21,6 @@ class wxFFile; class AudacityProject; -// -// Show auto recovery dialog if there are projects to recover. Should be -// called once at Audacity startup. -// -// This function possibly opens NEW project windows while it recovers all -// projects. If so, it will re-use *pproj, if != NULL and set it to NULL. -// -// Returns: True, if the start of Audacity should continue as normal -// False if Audacity should be quit immediately -// -// The didRecoverAnything param is strictly for a return value. -// Any value passed in is ignored. -// -bool ShowAutoRecoveryDialogIfNeeded(AudacityProject** pproj, - bool *didRecoverAnything); - // // XML Handler for a tag // diff --git a/src/AutoRecoveryDialog.cpp b/src/AutoRecoveryDialog.cpp new file mode 100644 index 000000000..2aaab046e --- /dev/null +++ b/src/AutoRecoveryDialog.cpp @@ -0,0 +1,259 @@ +/********************************************************************** + +Audacity: A Digital Audio Editor + +AutoRecoveryDialog.cpp + +Paul Licameli split from AutoRecovery.cpp + +**********************************************************************/ + +#include "AutoRecoveryDialog.h" + +#include "FileNames.h" +#include "ProjectManager.h" +#include "ShuttleGui.h" +#include "widgets/AudacityMessageBox.h" +#include "widgets/wxPanelWrapper.h" + +#include +#include +#include +#include + +enum { + ID_RECOVER_ALL = 10000, + ID_RECOVER_NONE, + ID_QUIT_AUDACITY, + ID_FILE_LIST +}; + +class AutoRecoveryDialog final : public wxDialogWrapper +{ +public: + AutoRecoveryDialog(wxWindow *parent); + +private: + void PopulateList(); + void PopulateOrExchange(ShuttleGui & S); + + void OnQuitAudacity(wxCommandEvent &evt); + void OnRecoverNone(wxCommandEvent &evt); + void OnRecoverAll(wxCommandEvent &evt); + + wxListCtrl *mFileList; + +public: + DECLARE_EVENT_TABLE() +}; + +AutoRecoveryDialog::AutoRecoveryDialog(wxWindow *parent) : + wxDialogWrapper(parent, -1, _("Automatic Crash Recovery"), + wxDefaultPosition, wxDefaultSize, + wxDEFAULT_DIALOG_STYLE & (~wxCLOSE_BOX)) // no close box +{ + SetName(GetTitle()); + ShuttleGui S(this, eIsCreating); + PopulateOrExchange(S); +} + +BEGIN_EVENT_TABLE(AutoRecoveryDialog, wxDialogWrapper) + EVT_BUTTON(ID_RECOVER_ALL, AutoRecoveryDialog::OnRecoverAll) + EVT_BUTTON(ID_RECOVER_NONE, AutoRecoveryDialog::OnRecoverNone) + EVT_BUTTON(ID_QUIT_AUDACITY, AutoRecoveryDialog::OnQuitAudacity) +END_EVENT_TABLE() + +void AutoRecoveryDialog::PopulateOrExchange(ShuttleGui& S) +{ + S.SetBorder(5); + S.StartVerticalLay(); + { + S.AddVariableText(_("Some projects were not saved properly the last time Audacity was run.\nFortunately, the following projects can be automatically recovered:"), false); + + S.StartStatic(_("Recoverable projects")); + { + mFileList = S.Id(ID_FILE_LIST).AddListControlReportMode(); + /*i18n-hint: (noun). It's the name of the project to recover.*/ + mFileList->InsertColumn(0, _("Name")); + mFileList->SetColumnWidth(0, wxLIST_AUTOSIZE); + PopulateList(); + } + S.EndStatic(); + + S.AddVariableText(_("After recovery, save the project to save the changes to disk."), false); + + S.StartHorizontalLay(); + { + S.Id(ID_QUIT_AUDACITY).AddButton(_("Quit Audacity")); + S.Id(ID_RECOVER_NONE).AddButton(_("Discard Projects")); + S.Id(ID_RECOVER_ALL).AddButton(_("Recover Projects")); + } + S.EndHorizontalLay(); + } + S.EndVerticalLay(); + + Layout(); + Fit(); + SetMinSize(GetSize()); + + // Sometimes it centers on wxGTK and sometimes it doesn't. + // Yielding before centering seems to be a good workaround, + // but will leave to implement on a rainy day. + Center(); +} + +void AutoRecoveryDialog::PopulateList() +{ + mFileList->DeleteAllItems(); + + wxDir dir(FileNames::AutoSaveDir()); + if (!dir.IsOpened()) + return; + + wxString filename; + int i = 0; + for (bool c = dir.GetFirst(&filename, wxT("*.autosave"), wxDIR_FILES); + c; c = dir.GetNext(&filename)) + mFileList->InsertItem(i++, wxFileName{ filename }.GetName()); + + mFileList->SetColumnWidth(0, wxLIST_AUTOSIZE); +} + +void AutoRecoveryDialog::OnQuitAudacity(wxCommandEvent & WXUNUSED(event)) +{ + EndModal(ID_QUIT_AUDACITY); +} + +void AutoRecoveryDialog::OnRecoverNone(wxCommandEvent & WXUNUSED(event)) +{ + int ret = AudacityMessageBox( + _("Are you sure you want to discard all recoverable projects?\n\nChoosing \"Yes\" discards all recoverable projects immediately."), + _("Confirm Discard Projects"), wxICON_QUESTION | wxYES_NO | wxNO_DEFAULT, this); + + if (ret == wxYES) + EndModal(ID_RECOVER_NONE); +} + +void AutoRecoveryDialog::OnRecoverAll(wxCommandEvent & WXUNUSED(event)) +{ + EndModal(ID_RECOVER_ALL); +} + +//////////////////////////////////////////////////////////////////////////// + +static bool HaveFilesToRecover() +{ + wxDir dir(FileNames::AutoSaveDir()); + if (!dir.IsOpened()) + { + AudacityMessageBox(_("Could not enumerate files in auto save directory."), + _("Error"), wxICON_STOP); + return false; + } + + wxString filename; + bool c = dir.GetFirst(&filename, wxT("*.autosave"), wxDIR_FILES); + + return c; +} + +static bool RemoveAllAutoSaveFiles() +{ + FilePaths files; + wxDir::GetAllFiles(FileNames::AutoSaveDir(), &files, + wxT("*.autosave"), wxDIR_FILES); + + for (unsigned int i = 0; i < files.size(); i++) + { + if (!wxRemoveFile(files[i])) + { + // I don't think this error message is actually useful. + // -dmazzoni + //AudacityMessageBox(wxT("Could not remove auto save file: " + files[i]), + // _("Error"), wxICON_STOP); + return false; + } + } + + return true; +} + +static bool RecoverAllProjects(AudacityProject** pproj) +{ + wxDir dir(FileNames::AutoSaveDir()); + if (!dir.IsOpened()) + { + AudacityMessageBox(_("Could not enumerate files in auto save directory."), + _("Error"), wxICON_STOP); + return false; + } + + // Open a project window for each auto save file + wxString filename; + + FilePaths files; + wxDir::GetAllFiles(FileNames::AutoSaveDir(), &files, + wxT("*.autosave"), wxDIR_FILES); + + for (unsigned int i = 0; i < files.size(); i++) + { + AudacityProject* proj{}; + if (*pproj) + { + // Reuse existing project window + proj = *pproj; + *pproj = NULL; + } + + // Open project. When an auto-save file has been opened successfully, + // the opened auto-save file is automatically deleted and a NEW one + // is created. + (void) ProjectManager::OpenProject( proj, files[i], false ); + } + + return true; +} + +bool ShowAutoRecoveryDialogIfNeeded(AudacityProject** pproj, + bool *didRecoverAnything) +{ + if (didRecoverAnything) + *didRecoverAnything = false; + if (HaveFilesToRecover()) + { + // Under wxGTK3, the auto recovery dialog will not get + // the focus since the project window hasn't been allowed + // to completely initialize. + // + // Yielding seems to allow the initialization to complete. + // + // Additionally, it also corrects a sizing issue in the dialog + // related to wxWidgets bug: + // + // http://trac.wxwidgets.org/ticket/16440 + // + // This must be done before "dlg" is declared. + wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI); + + int ret = AutoRecoveryDialog{nullptr}.ShowModal(); + + switch (ret) + { + case ID_RECOVER_NONE: + return RemoveAllAutoSaveFiles(); + + case ID_RECOVER_ALL: + if (didRecoverAnything) + *didRecoverAnything = true; + return RecoverAllProjects(pproj); + + default: + // This includes ID_QUIT_AUDACITY + return false; + } + } else + { + // Nothing to recover, move along + return true; + } +} diff --git a/src/AutoRecoveryDialog.h b/src/AutoRecoveryDialog.h new file mode 100644 index 000000000..06f20b5ff --- /dev/null +++ b/src/AutoRecoveryDialog.h @@ -0,0 +1,32 @@ +/********************************************************************** + +Audacity: A Digital Audio Editor + +AutoRecoveryDialog.h + +Paul Licameli split from AutoRecovery.h + +**********************************************************************/ + +#ifndef __AUDACITY_AUTO_RECOVERY_DIALOG__ +#define __AUDACITY_AUTO_RECOVERY_DIALOG__ + +class AudacityProject; + +// +// Show auto recovery dialog if there are projects to recover. Should be +// called once at Audacity startup. +// +// This function possibly opens NEW project windows while it recovers all +// projects. If so, it will re-use *pproj, if != NULL and set it to NULL. +// +// Returns: True, if the start of Audacity should continue as normal +// False if Audacity should be quit immediately +// +// The didRecoverAnything param is strictly for a return value. +// Any value passed in is ignored. +// +bool ShowAutoRecoveryDialogIfNeeded(AudacityProject** pproj, + bool *didRecoverAnything); + +#endif diff --git a/src/Makefile.am b/src/Makefile.am index 928fac260..9a2068a46 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -115,6 +115,8 @@ audacity_SOURCES = \ AudioIOListener.h \ AutoRecovery.cpp \ AutoRecovery.h \ + AutoRecoveryDialog.cpp \ + AutoRecoveryDialog.h \ BatchCommandDialog.cpp \ BatchCommandDialog.h \ BatchCommands.cpp \ diff --git a/src/Makefile.in b/src/Makefile.in index aa2d03aed..cf55cba65 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -294,45 +294,46 @@ am__audacity_SOURCES_DIST = BlockFile.cpp BlockFile.h DirManager.cpp \ AudacityApp.cpp AudacityApp.h AudacityException.cpp \ AudacityException.h AudacityLogger.cpp AudacityLogger.h \ AudioIO.cpp AudioIO.h AudioIOListener.h AutoRecovery.cpp \ - AutoRecovery.h BatchCommandDialog.cpp BatchCommandDialog.h \ - BatchCommands.cpp BatchCommands.h BatchProcessDialog.cpp \ - BatchProcessDialog.h Benchmark.cpp Benchmark.h \ - CellularPanel.cpp CellularPanel.h ClientData.h \ - ClientDataHelpers.h Clipboard.cpp Clipboard.h CrashReport.cpp \ - CrashReport.h Dependencies.cpp Dependencies.h DeviceChange.cpp \ - DeviceChange.h DeviceManager.cpp DeviceManager.h Diags.cpp \ - Diags.h Envelope.cpp Envelope.h Experimental.h FFmpeg.cpp \ - FFmpeg.h FFT.cpp FFT.h FileException.cpp FileException.h \ - FileIO.cpp FileIO.h FileNames.cpp FileNames.h float_cast.h \ - FreqWindow.cpp FreqWindow.h HelpText.cpp HelpText.h \ - HistoryWindow.cpp HistoryWindow.h HitTestResult.h \ - ImageManipulation.cpp ImageManipulation.h \ - InconsistencyException.cpp InconsistencyException.h \ - InterpolateAudio.cpp InterpolateAudio.h KeyboardCapture.cpp \ - KeyboardCapture.h LabelDialog.cpp LabelDialog.h LabelTrack.cpp \ - LabelTrack.h LangChoice.cpp LangChoice.h Languages.cpp \ - Languages.h Legacy.cpp Legacy.h Lyrics.cpp Lyrics.h \ - LyricsWindow.cpp LyricsWindow.h MacroMagic.h Matrix.cpp \ - Matrix.h MemoryX.h Menus.cpp Menus.h \ - MissingAliasFileDialog.cpp MissingAliasFileDialog.h Mix.cpp \ - Mix.h MixerBoard.cpp MixerBoard.h ModuleManager.cpp \ - ModuleManager.h NumberScale.h PitchName.cpp PitchName.h \ - PlatformCompatibility.cpp PlatformCompatibility.h \ - PluginManager.cpp PluginManager.h Printing.cpp Printing.h \ - Profiler.cpp Profiler.h Project.cpp Project.h \ - ProjectAudioIO.cpp ProjectAudioIO.h ProjectAudioManager.cpp \ - ProjectAudioManager.h ProjectFileIO.cpp ProjectFileIO.h \ - ProjectFileIORegistry.cpp ProjectFileIORegistry.h \ - ProjectFSCK.cpp ProjectFSCK.h ProjectHistory.cpp \ - ProjectHistory.h ProjectManager.cpp ProjectManager.h \ - ProjectSettings.cpp ProjectSettings.h ProjectWindow.cpp \ - ProjectWindow.h RealFFTf.cpp RealFFTf.h RealFFTf48x.cpp \ - RealFFTf48x.h RefreshCode.h Resample.cpp Resample.h \ - RevisionIdent.h RingBuffer.cpp RingBuffer.h Screenshot.cpp \ - Screenshot.h SelectedRegion.cpp SelectedRegion.h \ - SelectionState.cpp SelectionState.h Shuttle.cpp Shuttle.h \ - ShuttleGetDefinition.cpp ShuttleGetDefinition.h ShuttleGui.cpp \ - ShuttleGui.h ShuttlePrefs.cpp ShuttlePrefs.h Snap.cpp Snap.h \ + AutoRecovery.h AutoRecoveryDialog.cpp AutoRecoveryDialog.h \ + BatchCommandDialog.cpp BatchCommandDialog.h BatchCommands.cpp \ + BatchCommands.h BatchProcessDialog.cpp BatchProcessDialog.h \ + Benchmark.cpp Benchmark.h CellularPanel.cpp CellularPanel.h \ + ClientData.h ClientDataHelpers.h Clipboard.cpp Clipboard.h \ + CrashReport.cpp CrashReport.h Dependencies.cpp Dependencies.h \ + DeviceChange.cpp DeviceChange.h DeviceManager.cpp \ + DeviceManager.h Diags.cpp Diags.h Envelope.cpp Envelope.h \ + Experimental.h FFmpeg.cpp FFmpeg.h FFT.cpp FFT.h \ + FileException.cpp FileException.h FileIO.cpp FileIO.h \ + FileNames.cpp FileNames.h float_cast.h FreqWindow.cpp \ + FreqWindow.h HelpText.cpp HelpText.h HistoryWindow.cpp \ + HistoryWindow.h HitTestResult.h ImageManipulation.cpp \ + ImageManipulation.h InconsistencyException.cpp \ + InconsistencyException.h InterpolateAudio.cpp \ + InterpolateAudio.h KeyboardCapture.cpp KeyboardCapture.h \ + LabelDialog.cpp LabelDialog.h LabelTrack.cpp LabelTrack.h \ + LangChoice.cpp LangChoice.h Languages.cpp Languages.h \ + Legacy.cpp Legacy.h Lyrics.cpp Lyrics.h LyricsWindow.cpp \ + LyricsWindow.h MacroMagic.h Matrix.cpp Matrix.h MemoryX.h \ + Menus.cpp Menus.h MissingAliasFileDialog.cpp \ + MissingAliasFileDialog.h Mix.cpp Mix.h MixerBoard.cpp \ + MixerBoard.h ModuleManager.cpp ModuleManager.h NumberScale.h \ + PitchName.cpp PitchName.h PlatformCompatibility.cpp \ + PlatformCompatibility.h PluginManager.cpp PluginManager.h \ + Printing.cpp Printing.h Profiler.cpp Profiler.h Project.cpp \ + Project.h ProjectAudioIO.cpp ProjectAudioIO.h \ + ProjectAudioManager.cpp ProjectAudioManager.h \ + ProjectFileIO.cpp ProjectFileIO.h ProjectFileIORegistry.cpp \ + ProjectFileIORegistry.h ProjectFSCK.cpp ProjectFSCK.h \ + ProjectHistory.cpp ProjectHistory.h ProjectManager.cpp \ + ProjectManager.h ProjectSettings.cpp ProjectSettings.h \ + ProjectWindow.cpp ProjectWindow.h RealFFTf.cpp RealFFTf.h \ + RealFFTf48x.cpp RealFFTf48x.h RefreshCode.h Resample.cpp \ + Resample.h RevisionIdent.h RingBuffer.cpp RingBuffer.h \ + Screenshot.cpp Screenshot.h SelectedRegion.cpp \ + SelectedRegion.h SelectionState.cpp SelectionState.h \ + Shuttle.cpp Shuttle.h ShuttleGetDefinition.cpp \ + ShuttleGetDefinition.h ShuttleGui.cpp ShuttleGui.h \ + ShuttlePrefs.cpp ShuttlePrefs.h Snap.cpp Snap.h \ SoundActivatedRecord.cpp SoundActivatedRecord.h Spectrum.cpp \ Spectrum.h SplashDialog.cpp SplashDialog.h SseMathFuncs.cpp \ SseMathFuncs.h Tags.cpp Tags.h Theme.cpp Theme.h \ @@ -640,6 +641,7 @@ am_audacity_OBJECTS = $(am__objects_1) audacity-AboutDialog.$(OBJEXT) \ audacity-AudacityException.$(OBJEXT) \ audacity-AudacityLogger.$(OBJEXT) audacity-AudioIO.$(OBJEXT) \ audacity-AutoRecovery.$(OBJEXT) \ + audacity-AutoRecoveryDialog.$(OBJEXT) \ audacity-BatchCommandDialog.$(OBJEXT) \ audacity-BatchCommands.$(OBJEXT) \ audacity-BatchProcessDialog.$(OBJEXT) \ @@ -1367,45 +1369,46 @@ audacity_SOURCES = $(libaudacity_la_SOURCES) AboutDialog.cpp \ AudacityApp.cpp AudacityApp.h AudacityException.cpp \ AudacityException.h AudacityLogger.cpp AudacityLogger.h \ AudioIO.cpp AudioIO.h AudioIOListener.h AutoRecovery.cpp \ - AutoRecovery.h BatchCommandDialog.cpp BatchCommandDialog.h \ - BatchCommands.cpp BatchCommands.h BatchProcessDialog.cpp \ - BatchProcessDialog.h Benchmark.cpp Benchmark.h \ - CellularPanel.cpp CellularPanel.h ClientData.h \ - ClientDataHelpers.h Clipboard.cpp Clipboard.h CrashReport.cpp \ - CrashReport.h Dependencies.cpp Dependencies.h DeviceChange.cpp \ - DeviceChange.h DeviceManager.cpp DeviceManager.h Diags.cpp \ - Diags.h Envelope.cpp Envelope.h Experimental.h FFmpeg.cpp \ - FFmpeg.h FFT.cpp FFT.h FileException.cpp FileException.h \ - FileIO.cpp FileIO.h FileNames.cpp FileNames.h float_cast.h \ - FreqWindow.cpp FreqWindow.h HelpText.cpp HelpText.h \ - HistoryWindow.cpp HistoryWindow.h HitTestResult.h \ - ImageManipulation.cpp ImageManipulation.h \ - InconsistencyException.cpp InconsistencyException.h \ - InterpolateAudio.cpp InterpolateAudio.h KeyboardCapture.cpp \ - KeyboardCapture.h LabelDialog.cpp LabelDialog.h LabelTrack.cpp \ - LabelTrack.h LangChoice.cpp LangChoice.h Languages.cpp \ - Languages.h Legacy.cpp Legacy.h Lyrics.cpp Lyrics.h \ - LyricsWindow.cpp LyricsWindow.h MacroMagic.h Matrix.cpp \ - Matrix.h MemoryX.h Menus.cpp Menus.h \ - MissingAliasFileDialog.cpp MissingAliasFileDialog.h Mix.cpp \ - Mix.h MixerBoard.cpp MixerBoard.h ModuleManager.cpp \ - ModuleManager.h NumberScale.h PitchName.cpp PitchName.h \ - PlatformCompatibility.cpp PlatformCompatibility.h \ - PluginManager.cpp PluginManager.h Printing.cpp Printing.h \ - Profiler.cpp Profiler.h Project.cpp Project.h \ - ProjectAudioIO.cpp ProjectAudioIO.h ProjectAudioManager.cpp \ - ProjectAudioManager.h ProjectFileIO.cpp ProjectFileIO.h \ - ProjectFileIORegistry.cpp ProjectFileIORegistry.h \ - ProjectFSCK.cpp ProjectFSCK.h ProjectHistory.cpp \ - ProjectHistory.h ProjectManager.cpp ProjectManager.h \ - ProjectSettings.cpp ProjectSettings.h ProjectWindow.cpp \ - ProjectWindow.h RealFFTf.cpp RealFFTf.h RealFFTf48x.cpp \ - RealFFTf48x.h RefreshCode.h Resample.cpp Resample.h \ - RevisionIdent.h RingBuffer.cpp RingBuffer.h Screenshot.cpp \ - Screenshot.h SelectedRegion.cpp SelectedRegion.h \ - SelectionState.cpp SelectionState.h Shuttle.cpp Shuttle.h \ - ShuttleGetDefinition.cpp ShuttleGetDefinition.h ShuttleGui.cpp \ - ShuttleGui.h ShuttlePrefs.cpp ShuttlePrefs.h Snap.cpp Snap.h \ + AutoRecovery.h AutoRecoveryDialog.cpp AutoRecoveryDialog.h \ + BatchCommandDialog.cpp BatchCommandDialog.h BatchCommands.cpp \ + BatchCommands.h BatchProcessDialog.cpp BatchProcessDialog.h \ + Benchmark.cpp Benchmark.h CellularPanel.cpp CellularPanel.h \ + ClientData.h ClientDataHelpers.h Clipboard.cpp Clipboard.h \ + CrashReport.cpp CrashReport.h Dependencies.cpp Dependencies.h \ + DeviceChange.cpp DeviceChange.h DeviceManager.cpp \ + DeviceManager.h Diags.cpp Diags.h Envelope.cpp Envelope.h \ + Experimental.h FFmpeg.cpp FFmpeg.h FFT.cpp FFT.h \ + FileException.cpp FileException.h FileIO.cpp FileIO.h \ + FileNames.cpp FileNames.h float_cast.h FreqWindow.cpp \ + FreqWindow.h HelpText.cpp HelpText.h HistoryWindow.cpp \ + HistoryWindow.h HitTestResult.h ImageManipulation.cpp \ + ImageManipulation.h InconsistencyException.cpp \ + InconsistencyException.h InterpolateAudio.cpp \ + InterpolateAudio.h KeyboardCapture.cpp KeyboardCapture.h \ + LabelDialog.cpp LabelDialog.h LabelTrack.cpp LabelTrack.h \ + LangChoice.cpp LangChoice.h Languages.cpp Languages.h \ + Legacy.cpp Legacy.h Lyrics.cpp Lyrics.h LyricsWindow.cpp \ + LyricsWindow.h MacroMagic.h Matrix.cpp Matrix.h MemoryX.h \ + Menus.cpp Menus.h MissingAliasFileDialog.cpp \ + MissingAliasFileDialog.h Mix.cpp Mix.h MixerBoard.cpp \ + MixerBoard.h ModuleManager.cpp ModuleManager.h NumberScale.h \ + PitchName.cpp PitchName.h PlatformCompatibility.cpp \ + PlatformCompatibility.h PluginManager.cpp PluginManager.h \ + Printing.cpp Printing.h Profiler.cpp Profiler.h Project.cpp \ + Project.h ProjectAudioIO.cpp ProjectAudioIO.h \ + ProjectAudioManager.cpp ProjectAudioManager.h \ + ProjectFileIO.cpp ProjectFileIO.h ProjectFileIORegistry.cpp \ + ProjectFileIORegistry.h ProjectFSCK.cpp ProjectFSCK.h \ + ProjectHistory.cpp ProjectHistory.h ProjectManager.cpp \ + ProjectManager.h ProjectSettings.cpp ProjectSettings.h \ + ProjectWindow.cpp ProjectWindow.h RealFFTf.cpp RealFFTf.h \ + RealFFTf48x.cpp RealFFTf48x.h RefreshCode.h Resample.cpp \ + Resample.h RevisionIdent.h RingBuffer.cpp RingBuffer.h \ + Screenshot.cpp Screenshot.h SelectedRegion.cpp \ + SelectedRegion.h SelectionState.cpp SelectionState.h \ + Shuttle.cpp Shuttle.h ShuttleGetDefinition.cpp \ + ShuttleGetDefinition.h ShuttleGui.cpp ShuttleGui.h \ + ShuttlePrefs.cpp ShuttlePrefs.h Snap.cpp Snap.h \ SoundActivatedRecord.cpp SoundActivatedRecord.h Spectrum.cpp \ Spectrum.h SplashDialog.cpp SplashDialog.h SseMathFuncs.cpp \ SseMathFuncs.h Tags.cpp Tags.h Theme.cpp Theme.h \ @@ -2522,6 +2525,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audacity-AudacityLogger.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audacity-AudioIO.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audacity-AutoRecovery.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audacity-AutoRecoveryDialog.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audacity-BatchCommandDialog.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audacity-BatchCommands.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audacity-BatchProcessDialog.Po@am__quote@ @@ -3380,6 +3384,20 @@ audacity-AutoRecovery.obj: AutoRecovery.cpp @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(audacity_CPPFLAGS) $(CPPFLAGS) $(audacity_CXXFLAGS) $(CXXFLAGS) -c -o audacity-AutoRecovery.obj `if test -f 'AutoRecovery.cpp'; then $(CYGPATH_W) 'AutoRecovery.cpp'; else $(CYGPATH_W) '$(srcdir)/AutoRecovery.cpp'; fi` +audacity-AutoRecoveryDialog.o: AutoRecoveryDialog.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(audacity_CPPFLAGS) $(CPPFLAGS) $(audacity_CXXFLAGS) $(CXXFLAGS) -MT audacity-AutoRecoveryDialog.o -MD -MP -MF $(DEPDIR)/audacity-AutoRecoveryDialog.Tpo -c -o audacity-AutoRecoveryDialog.o `test -f 'AutoRecoveryDialog.cpp' || echo '$(srcdir)/'`AutoRecoveryDialog.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/audacity-AutoRecoveryDialog.Tpo $(DEPDIR)/audacity-AutoRecoveryDialog.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='AutoRecoveryDialog.cpp' object='audacity-AutoRecoveryDialog.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(audacity_CPPFLAGS) $(CPPFLAGS) $(audacity_CXXFLAGS) $(CXXFLAGS) -c -o audacity-AutoRecoveryDialog.o `test -f 'AutoRecoveryDialog.cpp' || echo '$(srcdir)/'`AutoRecoveryDialog.cpp + +audacity-AutoRecoveryDialog.obj: AutoRecoveryDialog.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(audacity_CPPFLAGS) $(CPPFLAGS) $(audacity_CXXFLAGS) $(CXXFLAGS) -MT audacity-AutoRecoveryDialog.obj -MD -MP -MF $(DEPDIR)/audacity-AutoRecoveryDialog.Tpo -c -o audacity-AutoRecoveryDialog.obj `if test -f 'AutoRecoveryDialog.cpp'; then $(CYGPATH_W) 'AutoRecoveryDialog.cpp'; else $(CYGPATH_W) '$(srcdir)/AutoRecoveryDialog.cpp'; fi` +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/audacity-AutoRecoveryDialog.Tpo $(DEPDIR)/audacity-AutoRecoveryDialog.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='AutoRecoveryDialog.cpp' object='audacity-AutoRecoveryDialog.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(audacity_CPPFLAGS) $(CPPFLAGS) $(audacity_CXXFLAGS) $(CXXFLAGS) -c -o audacity-AutoRecoveryDialog.obj `if test -f 'AutoRecoveryDialog.cpp'; then $(CYGPATH_W) 'AutoRecoveryDialog.cpp'; else $(CYGPATH_W) '$(srcdir)/AutoRecoveryDialog.cpp'; fi` + audacity-BatchCommandDialog.o: BatchCommandDialog.cpp @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(audacity_CPPFLAGS) $(CPPFLAGS) $(audacity_CXXFLAGS) $(CXXFLAGS) -MT audacity-BatchCommandDialog.o -MD -MP -MF $(DEPDIR)/audacity-BatchCommandDialog.Tpo -c -o audacity-BatchCommandDialog.o `test -f 'BatchCommandDialog.cpp' || echo '$(srcdir)/'`BatchCommandDialog.cpp @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/audacity-BatchCommandDialog.Tpo $(DEPDIR)/audacity-BatchCommandDialog.Po diff --git a/win/Projects/Audacity/Audacity.vcxproj b/win/Projects/Audacity/Audacity.vcxproj index 1dd573c3d..f2717a946 100755 --- a/win/Projects/Audacity/Audacity.vcxproj +++ b/win/Projects/Audacity/Audacity.vcxproj @@ -130,6 +130,7 @@ + @@ -504,6 +505,7 @@ + diff --git a/win/Projects/Audacity/Audacity.vcxproj.filters b/win/Projects/Audacity/Audacity.vcxproj.filters index e1f8a590b..96c1645ad 100755 --- a/win/Projects/Audacity/Audacity.vcxproj.filters +++ b/win/Projects/Audacity/Audacity.vcxproj.filters @@ -131,6 +131,9 @@ src + + src + src @@ -1204,6 +1207,9 @@ src + + src + src