From 0c8b4e32fcb77a1842be12d67b7a91580ecf51ba Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Fri, 19 Feb 2021 12:26:45 -0500 Subject: [PATCH] Uses of BasicUI::MakeGenericProgress --- src/CrashReport.cpp | 14 ++++++-------- src/DBConnection.cpp | 13 ++++++------- src/ProjectFileIO.cpp | 25 ++++++++++--------------- 3 files changed, 22 insertions(+), 30 deletions(-) diff --git a/src/CrashReport.cpp b/src/CrashReport.cpp index 9041ede35..8fb5959d2 100644 --- a/src/CrashReport.cpp +++ b/src/CrashReport.cpp @@ -13,8 +13,6 @@ #include #include -#include - #if defined(__WXMSW__) #include #endif @@ -22,6 +20,7 @@ #include "wxFileNameWrapper.h" #include "AudacityLogger.h" #include "AudioIOBase.h" +#include "BasicUI.h" #include "FileNames.h" #include "Internat.h" #include "Languages.h" @@ -44,11 +43,10 @@ void Generate(wxDebugReport::Context ctx) { // Provides a progress dialog with indeterminate mode - wxGenericProgressDialog pd(XO("Audacity Support Data").Translation(), - XO("This may take several seconds").Translation(), - 300000, // range - nullptr, // parent - wxPD_APP_MODAL | wxPD_ELAPSED_TIME | wxPD_SMOOTH); + using namespace BasicUI; + auto pd = MakeGenericProgress({}, + XO("Audacity Support Data"), XO("This may take several seconds")); + wxASSERT(pd); std::atomic_bool done = {false}; auto thread = std::thread([&] @@ -87,7 +85,7 @@ void Generate(wxDebugReport::Context ctx) while (!done) { wxMilliSleep(50); - pd.Pulse(); + pd->Pulse(); } thread.join(); } diff --git a/src/DBConnection.cpp b/src/DBConnection.cpp index ca6229329..da9807501 100644 --- a/src/DBConnection.cpp +++ b/src/DBConnection.cpp @@ -13,10 +13,10 @@ Paul Licameli -- split from ProjectFileIO.cpp #include "sqlite3.h" -#include #include #include "AudacityLogger.h" +#include "BasicUI.h" #include "FileNames.h" #include "Internat.h" #include "Project.h" @@ -240,17 +240,16 @@ bool DBConnection::Close() } // Provides a progress dialog with indeterminate mode - wxGenericProgressDialog pd(title.Translation(), - XO("This may take several seconds").Translation(), - 300000, // range - nullptr, // parent - wxPD_APP_MODAL | wxPD_ELAPSED_TIME | wxPD_SMOOTH); + using namespace BasicUI; + auto pd = MakeGenericProgress({}, + title, XO("This may take several seconds")); + wxASSERT(pd); // Wait for the checkpoints to end while (mCheckpointPending || mCheckpointActive) { wxMilliSleep(50); - pd.Pulse(); + pd->Pulse(); } } diff --git a/src/ProjectFileIO.cpp b/src/ProjectFileIO.cpp index 7f7abcf0e..185f110ba 100644 --- a/src/ProjectFileIO.cpp +++ b/src/ProjectFileIO.cpp @@ -14,7 +14,6 @@ Paul Licameli split from AudacityProject.cpp #include #include #include -#include #include #include @@ -1171,20 +1170,17 @@ bool ProjectFileIO::RenameOrWarn(const FilePath &src, const FilePath &dst) done = true; }); - auto &window = GetProjectFrame( mProject ); - // Provides a progress dialog with indeterminate mode - wxGenericProgressDialog pd(XO("Copying Project").Translation(), - XO("This may take several seconds").Translation(), - 300000, // range - &window, // parent - wxPD_APP_MODAL | wxPD_ELAPSED_TIME | wxPD_SMOOTH); + using namespace BasicUI; + auto pd = MakeGenericProgress(*ProjectFramePlacement(&mProject), + XO("Copying Project"), XO("This may take several seconds")); + wxASSERT(pd); // Wait for the checkpoints to end while (!done) { wxMilliSleep(50); - pd.Pulse(); + pd->Pulse(); } thread.join(); @@ -2102,17 +2098,16 @@ bool ProjectFileIO::SaveProject( }); // Provides a progress dialog with indeterminate mode - wxGenericProgressDialog pd(XO("Syncing").Translation(), - XO("This may take several seconds").Translation(), - 300000, // range - nullptr, // parent - wxPD_APP_MODAL | wxPD_ELAPSED_TIME | wxPD_SMOOTH); + using namespace BasicUI; + auto pd = MakeGenericProgress({}, + XO("Syncing"), XO("This may take several seconds")); + wxASSERT(pd); // Wait for the checkpoints to end while (!done) { wxMilliSleep(50); - pd.Pulse(); + pd->Pulse(); } thread.join();