From 1bbd7b3b520fa53ba14968a57d1b1428ab11b499 Mon Sep 17 00:00:00 2001 From: Leland Lucius Date: Mon, 27 Jul 2020 16:56:31 -0500 Subject: [PATCH] AUP3: UP-40 Compact Project Done This time it adds the usage info on the initial dialog as well. --- src/menus/FileMenus.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/menus/FileMenus.cpp b/src/menus/FileMenus.cpp index e2db49394..5a1c570f5 100644 --- a/src/menus/FileMenus.cpp +++ b/src/menus/FileMenus.cpp @@ -145,10 +145,20 @@ void OnClose(const CommandContext &context ) void OnCompact(const CommandContext &context) { + auto &project = context.project; + auto &undoManager = UndoManager::Get(project); + auto &projectFileIO = ProjectFileIO::Get(project); + + auto before = wxFileName(projectFileIO.GetFileName()).GetSize() + + wxFileName(projectFileIO.GetFileName() + wxT("-wal")).GetSize(); + int id = AudacityMessageBox( XO("Compacting this project will free up disk space by removing unused bytes within the file.\n\n" + "There is %s of free disk space and this project is currently using %s.\n\n" "NOTE: If you proceed, the current Undo History and clipboard contents will be discarded.\n\n" - "Do you want to continue?"), + "Do you want to continue?") + .Format(Internat::FormatSize(projectFileIO.GetFreeDiskSpace()), + Internat::FormatSize(before.GetValue())), XO("Compact Project"), wxYES_NO); @@ -157,9 +167,6 @@ void OnCompact(const CommandContext &context) return; } - auto &project = context.project; - auto &undoManager = UndoManager::Get(project); - ProjectHistory::Get(project) .PushState(XO("Compacted project file"), XO("Compact"), UndoPush::CONSOLIDATE); @@ -176,19 +183,14 @@ void OnCompact(const CommandContext &context) currentTracks->Add(t->Duplicate()); } - auto &projectFileIO = ProjectFileIO::Get(project); - - auto before = wxFileName(projectFileIO.GetFileName()).GetSize() + - wxFileName(projectFileIO.GetFileName() + wxT("-wal")).GetSize(); - projectFileIO.Vacuum(currentTracks, true); auto after = wxFileName(projectFileIO.GetFileName()).GetSize() + wxFileName(projectFileIO.GetFileName() + wxT("-wal")).GetSize(); - double space = (before - after).GetValue(); AudacityMessageBox( - XO("Compacting freed %s of disk space.").Format(Internat::FormatSize(space)), + XO("Compacting freed %s of disk space.") + .Format(Internat::FormatSize((before - after).GetValue())), XO("Compact Project")); }