1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-24 16:38:07 +02:00

Uses of BasicUI::MakeGenericProgress

This commit is contained in:
Paul Licameli 2021-02-19 12:26:45 -05:00
parent 333aa10624
commit 0c8b4e32fc
3 changed files with 22 additions and 30 deletions

View File

@ -13,8 +13,6 @@
#include <atomic>
#include <thread>
#include <wx/progdlg.h>
#if defined(__WXMSW__)
#include <wx/evtloop.h>
#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();
}

View File

@ -13,10 +13,10 @@ Paul Licameli -- split from ProjectFileIO.cpp
#include "sqlite3.h"
#include <wx/progdlg.h>
#include <wx/string.h>
#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();
}
}

View File

@ -14,7 +14,6 @@ Paul Licameli split from AudacityProject.cpp
#include <sqlite3.h>
#include <wx/crt.h>
#include <wx/frame.h>
#include <wx/progdlg.h>
#include <wx/sstream.h>
#include <wx/xml/xml.h>
@ -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();