Bug 1600: Should keep progress dialog visible throughout Exp. Multi
This commit is contained in:
parent
f5737be02c
commit
d4b21bb33e
|
@ -256,6 +256,18 @@ std::unique_ptr<Mixer> ExportPlugin::CreateMixer(const WaveTrackConstArray &inpu
|
||||||
highQuality, mixerSpec);
|
highQuality, mixerSpec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ExportPlugin::InitProgress(std::unique_ptr<ProgressDialog> &pDialog,
|
||||||
|
const wxString &title, const wxString &message)
|
||||||
|
{
|
||||||
|
if (!pDialog)
|
||||||
|
pDialog = std::make_unique<ProgressDialog>( title, message );
|
||||||
|
else {
|
||||||
|
pDialog->SetTitle( title );
|
||||||
|
pDialog->SetMessage( message );
|
||||||
|
pDialog->Reinit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// Export
|
// Export
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
@ -849,7 +861,9 @@ bool Exporter::ExportTracks()
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
std::unique_ptr<ProgressDialog> pDialog;
|
||||||
auto result = mPlugins[mFormat]->Export(mProject,
|
auto result = mPlugins[mFormat]->Export(mProject,
|
||||||
|
pDialog,
|
||||||
mChannels,
|
mChannels,
|
||||||
mActualName.GetFullPath(),
|
mActualName.GetFullPath(),
|
||||||
mSelectedOnly,
|
mSelectedOnly,
|
||||||
|
|
|
@ -30,6 +30,7 @@ class DirManager;
|
||||||
class WaveTrack;
|
class WaveTrack;
|
||||||
class TrackList;
|
class TrackList;
|
||||||
class MixerSpec;
|
class MixerSpec;
|
||||||
|
class ProgressDialog;
|
||||||
class TimeTrack;
|
class TimeTrack;
|
||||||
class Mixer;
|
class Mixer;
|
||||||
using WaveTrackConstArray = std::vector < std::shared_ptr < const WaveTrack > >;
|
using WaveTrackConstArray = std::vector < std::shared_ptr < const WaveTrack > >;
|
||||||
|
@ -97,6 +98,9 @@ public:
|
||||||
|
|
||||||
/** \brief called to export audio into a file.
|
/** \brief called to export audio into a file.
|
||||||
*
|
*
|
||||||
|
* @param pDialog To be initialized with pointer to a NEW ProgressDialog if
|
||||||
|
* it was null, otherwise gives an existing dialog to be reused
|
||||||
|
* (working around a problem in wxWidgets for Mac; see bug 1600)
|
||||||
* @param selectedOnly Set to true if all tracks should be mixed, to false
|
* @param selectedOnly Set to true if all tracks should be mixed, to false
|
||||||
* if only the selected tracks should be mixed and exported.
|
* if only the selected tracks should be mixed and exported.
|
||||||
* @param metadata A Tags object that will over-ride the one in *project and
|
* @param metadata A Tags object that will over-ride the one in *project and
|
||||||
|
@ -114,6 +118,7 @@ public:
|
||||||
* ProgressResult::Stopped
|
* ProgressResult::Stopped
|
||||||
*/
|
*/
|
||||||
virtual ProgressResult Export(AudacityProject *project,
|
virtual ProgressResult Export(AudacityProject *project,
|
||||||
|
std::unique_ptr<ProgressDialog> &pDialog,
|
||||||
unsigned channels,
|
unsigned channels,
|
||||||
const wxString &fName,
|
const wxString &fName,
|
||||||
bool selectedOnly,
|
bool selectedOnly,
|
||||||
|
@ -131,6 +136,10 @@ protected:
|
||||||
double outRate, sampleFormat outFormat,
|
double outRate, sampleFormat outFormat,
|
||||||
bool highQuality = true, MixerSpec *mixerSpec = NULL);
|
bool highQuality = true, MixerSpec *mixerSpec = NULL);
|
||||||
|
|
||||||
|
// Create or recycle a dialog.
|
||||||
|
static void InitProgress(std::unique_ptr<ProgressDialog> &pDialog,
|
||||||
|
const wxString &title, const wxString &message);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FormatInfoArray mFormatInfos;
|
FormatInfoArray mFormatInfos;
|
||||||
};
|
};
|
||||||
|
|
|
@ -287,6 +287,7 @@ public:
|
||||||
wxWindow *OptionsCreate(wxWindow *parent, int format) override;
|
wxWindow *OptionsCreate(wxWindow *parent, int format) override;
|
||||||
|
|
||||||
ProgressResult Export(AudacityProject *project,
|
ProgressResult Export(AudacityProject *project,
|
||||||
|
std::unique_ptr<ProgressDialog> &pDialog,
|
||||||
unsigned channels,
|
unsigned channels,
|
||||||
const wxString &fName,
|
const wxString &fName,
|
||||||
bool selectedOnly,
|
bool selectedOnly,
|
||||||
|
@ -309,6 +310,7 @@ ExportCL::ExportCL()
|
||||||
}
|
}
|
||||||
|
|
||||||
ProgressResult ExportCL::Export(AudacityProject *project,
|
ProgressResult ExportCL::Export(AudacityProject *project,
|
||||||
|
std::unique_ptr<ProgressDialog> &pDialog,
|
||||||
unsigned channels,
|
unsigned channels,
|
||||||
const wxString &fName,
|
const wxString &fName,
|
||||||
bool selectionOnly,
|
bool selectionOnly,
|
||||||
|
@ -448,10 +450,11 @@ ProgressResult ExportCL::Export(AudacityProject *project,
|
||||||
} );
|
} );
|
||||||
|
|
||||||
// Prepare the progress display
|
// Prepare the progress display
|
||||||
ProgressDialog progress(_("Export"),
|
InitProgress( pDialog, _("Export"),
|
||||||
selectionOnly ?
|
selectionOnly
|
||||||
_("Exporting the selected audio using command-line encoder") :
|
? _("Exporting the selected audio using command-line encoder")
|
||||||
_("Exporting the audio using command-line encoder"));
|
: _("Exporting the audio using command-line encoder") );
|
||||||
|
auto &progress = *pDialog;
|
||||||
|
|
||||||
// Start piping the mixed data to the command
|
// Start piping the mixed data to the command
|
||||||
while (updateResult == ProgressResult::Success && process.IsActive() && os->IsOk()) {
|
while (updateResult == ProgressResult::Success && process.IsActive() && os->IsOk()) {
|
||||||
|
|
|
@ -141,6 +141,7 @@ public:
|
||||||
///\param subformat index of export type
|
///\param subformat index of export type
|
||||||
///\return true if export succeded
|
///\return true if export succeded
|
||||||
ProgressResult Export(AudacityProject *project,
|
ProgressResult Export(AudacityProject *project,
|
||||||
|
std::unique_ptr<ProgressDialog> &pDialog,
|
||||||
unsigned channels,
|
unsigned channels,
|
||||||
const wxString &fName,
|
const wxString &fName,
|
||||||
bool selectedOnly,
|
bool selectedOnly,
|
||||||
|
@ -849,8 +850,10 @@ bool ExportFFmpeg::EncodeAudioFrame(int16_t *pFrame, size_t frameSize)
|
||||||
|
|
||||||
|
|
||||||
ProgressResult ExportFFmpeg::Export(AudacityProject *project,
|
ProgressResult ExportFFmpeg::Export(AudacityProject *project,
|
||||||
unsigned channels, const wxString &fName,
|
std::unique_ptr<ProgressDialog> &pDialog,
|
||||||
bool selectionOnly, double t0, double t1, MixerSpec *mixerSpec, const Tags *metadata, int subformat)
|
unsigned channels, const wxString &fName,
|
||||||
|
bool selectionOnly, double t0, double t1,
|
||||||
|
MixerSpec *mixerSpec, const Tags *metadata, int subformat)
|
||||||
{
|
{
|
||||||
if (!CheckFFmpegPresence())
|
if (!CheckFFmpegPresence())
|
||||||
return ProgressResult::Cancelled;
|
return ProgressResult::Cancelled;
|
||||||
|
@ -901,10 +904,13 @@ ProgressResult ExportFFmpeg::Export(AudacityProject *project,
|
||||||
|
|
||||||
auto updateResult = ProgressResult::Success;
|
auto updateResult = ProgressResult::Success;
|
||||||
{
|
{
|
||||||
ProgressDialog progress(wxFileName(fName).GetName(),
|
InitProgress( pDialog, wxFileName(fName).GetName(),
|
||||||
selectionOnly ?
|
selectionOnly
|
||||||
wxString::Format(_("Exporting selected audio as %s"), ExportFFmpegOptions::fmts[mSubFormat].Description()) :
|
? wxString::Format(_("Exporting selected audio as %s"),
|
||||||
wxString::Format(_("Exporting the audio as %s"), ExportFFmpegOptions::fmts[mSubFormat].Description()));
|
ExportFFmpegOptions::fmts[mSubFormat].Description())
|
||||||
|
: wxString::Format(_("Exporting the audio as %s"),
|
||||||
|
ExportFFmpegOptions::fmts[mSubFormat].Description()) );
|
||||||
|
auto &progress = *pDialog;
|
||||||
|
|
||||||
while (updateResult == ProgressResult::Success) {
|
while (updateResult == ProgressResult::Success) {
|
||||||
auto pcmNumSamples = mixer->Process(pcmBufferSize);
|
auto pcmNumSamples = mixer->Process(pcmBufferSize);
|
||||||
|
|
|
@ -191,6 +191,7 @@ public:
|
||||||
|
|
||||||
wxWindow *OptionsCreate(wxWindow *parent, int format) override;
|
wxWindow *OptionsCreate(wxWindow *parent, int format) override;
|
||||||
ProgressResult Export(AudacityProject *project,
|
ProgressResult Export(AudacityProject *project,
|
||||||
|
std::unique_ptr<ProgressDialog> &pDialog,
|
||||||
unsigned channels,
|
unsigned channels,
|
||||||
const wxString &fName,
|
const wxString &fName,
|
||||||
bool selectedOnly,
|
bool selectedOnly,
|
||||||
|
@ -222,6 +223,7 @@ ExportFLAC::ExportFLAC()
|
||||||
}
|
}
|
||||||
|
|
||||||
ProgressResult ExportFLAC::Export(AudacityProject *project,
|
ProgressResult ExportFLAC::Export(AudacityProject *project,
|
||||||
|
std::unique_ptr<ProgressDialog> &pDialog,
|
||||||
unsigned numChannels,
|
unsigned numChannels,
|
||||||
const wxString &fName,
|
const wxString &fName,
|
||||||
bool selectionOnly,
|
bool selectionOnly,
|
||||||
|
@ -354,10 +356,11 @@ ProgressResult ExportFLAC::Export(AudacityProject *project,
|
||||||
|
|
||||||
ArraysOf<FLAC__int32> tmpsmplbuf{ numChannels, SAMPLES_PER_RUN, true };
|
ArraysOf<FLAC__int32> tmpsmplbuf{ numChannels, SAMPLES_PER_RUN, true };
|
||||||
|
|
||||||
ProgressDialog progress(wxFileName(fName).GetName(),
|
InitProgress( pDialog, wxFileName(fName).GetName(),
|
||||||
selectionOnly ?
|
selectionOnly
|
||||||
_("Exporting the selected audio as FLAC") :
|
? _("Exporting the selected audio as FLAC")
|
||||||
_("Exporting the audio as FLAC"));
|
: _("Exporting the audio as FLAC") );
|
||||||
|
auto &progress = *pDialog;
|
||||||
|
|
||||||
while (updateResult == ProgressResult::Success) {
|
while (updateResult == ProgressResult::Success) {
|
||||||
auto samplesThisRun = mixer->Process(SAMPLES_PER_RUN);
|
auto samplesThisRun = mixer->Process(SAMPLES_PER_RUN);
|
||||||
|
|
|
@ -174,6 +174,7 @@ public:
|
||||||
|
|
||||||
wxWindow *OptionsCreate(wxWindow *parent, int format) override;
|
wxWindow *OptionsCreate(wxWindow *parent, int format) override;
|
||||||
ProgressResult Export(AudacityProject *project,
|
ProgressResult Export(AudacityProject *project,
|
||||||
|
std::unique_ptr<ProgressDialog> &pDialog,
|
||||||
unsigned channels,
|
unsigned channels,
|
||||||
const wxString &fName,
|
const wxString &fName,
|
||||||
bool selectedOnly,
|
bool selectedOnly,
|
||||||
|
@ -204,6 +205,7 @@ ExportMP2::ExportMP2()
|
||||||
}
|
}
|
||||||
|
|
||||||
ProgressResult ExportMP2::Export(AudacityProject *project,
|
ProgressResult ExportMP2::Export(AudacityProject *project,
|
||||||
|
std::unique_ptr<ProgressDialog> &pDialog,
|
||||||
unsigned channels, const wxString &fName,
|
unsigned channels, const wxString &fName,
|
||||||
bool selectionOnly, double t0, double t1, MixerSpec *mixerSpec, const Tags *metadata,
|
bool selectionOnly, double t0, double t1, MixerSpec *mixerSpec, const Tags *metadata,
|
||||||
int WXUNUSED(subformat))
|
int WXUNUSED(subformat))
|
||||||
|
@ -272,10 +274,13 @@ ProgressResult ExportMP2::Export(AudacityProject *project,
|
||||||
stereo ? 2 : 1, pcmBufferSize, true,
|
stereo ? 2 : 1, pcmBufferSize, true,
|
||||||
rate, int16Sample, true, mixerSpec);
|
rate, int16Sample, true, mixerSpec);
|
||||||
|
|
||||||
ProgressDialog progress(wxFileName(fName).GetName(),
|
InitProgress( pDialog, wxFileName(fName).GetName(),
|
||||||
selectionOnly ?
|
selectionOnly
|
||||||
wxString::Format(_("Exporting selected audio at %ld kbps"), bitrate) :
|
? wxString::Format(_("Exporting selected audio at %ld kbps"),
|
||||||
wxString::Format(_("Exporting the audio at %ld kbps"), bitrate));
|
bitrate)
|
||||||
|
: wxString::Format(_("Exporting the audio at %ld kbps"),
|
||||||
|
bitrate) );
|
||||||
|
auto &progress = *pDialog;
|
||||||
|
|
||||||
while (updateResult == ProgressResult::Success) {
|
while (updateResult == ProgressResult::Success) {
|
||||||
auto pcmNumSamples = mixer->Process(pcmBufferSize);
|
auto pcmNumSamples = mixer->Process(pcmBufferSize);
|
||||||
|
|
|
@ -1610,6 +1610,7 @@ public:
|
||||||
|
|
||||||
wxWindow *OptionsCreate(wxWindow *parent, int format) override;
|
wxWindow *OptionsCreate(wxWindow *parent, int format) override;
|
||||||
ProgressResult Export(AudacityProject *project,
|
ProgressResult Export(AudacityProject *project,
|
||||||
|
std::unique_ptr<ProgressDialog> &pDialog,
|
||||||
unsigned channels,
|
unsigned channels,
|
||||||
const wxString &fName,
|
const wxString &fName,
|
||||||
bool selectedOnly,
|
bool selectedOnly,
|
||||||
|
@ -1670,6 +1671,7 @@ int ExportMP3::SetNumExportChannels()
|
||||||
|
|
||||||
|
|
||||||
ProgressResult ExportMP3::Export(AudacityProject *project,
|
ProgressResult ExportMP3::Export(AudacityProject *project,
|
||||||
|
std::unique_ptr<ProgressDialog> &pDialog,
|
||||||
unsigned channels,
|
unsigned channels,
|
||||||
const wxString &fName,
|
const wxString &fName,
|
||||||
bool selectionOnly,
|
bool selectionOnly,
|
||||||
|
@ -1858,7 +1860,8 @@ ProgressResult ExportMP3::Export(AudacityProject *project,
|
||||||
brate);
|
brate);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProgressDialog progress(wxFileName(fName).GetName(), title);
|
InitProgress( pDialog, wxFileName(fName).GetName(), title );
|
||||||
|
auto &progress = *pDialog;
|
||||||
|
|
||||||
while (updateResult == ProgressResult::Success) {
|
while (updateResult == ProgressResult::Success) {
|
||||||
auto blockLen = mixer->Process(inSamples);
|
auto blockLen = mixer->Process(inSamples);
|
||||||
|
|
|
@ -749,6 +749,7 @@ ProgressResult ExportMultiple::ExportMultipleByLabel(bool byName,
|
||||||
ExportKit activeSetting; // pointer to the settings in use for this export
|
ExportKit activeSetting; // pointer to the settings in use for this export
|
||||||
/* Go round again and do the exporting (so this run is slow but
|
/* Go round again and do the exporting (so this run is slow but
|
||||||
* non-interactive) */
|
* non-interactive) */
|
||||||
|
std::unique_ptr<ProgressDialog> pDialog;
|
||||||
for (count = 0; count < numFiles; count++) {
|
for (count = 0; count < numFiles; count++) {
|
||||||
/* get the settings to use for the export from the array */
|
/* get the settings to use for the export from the array */
|
||||||
activeSetting = exportSettings[count];
|
activeSetting = exportSettings[count];
|
||||||
|
@ -757,7 +758,8 @@ ProgressResult ExportMultiple::ExportMultipleByLabel(bool byName,
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Export it
|
// Export it
|
||||||
ok = DoExport(channels, activeSetting.destfile, false, activeSetting.t0, activeSetting.t1, activeSetting.filetags);
|
ok = DoExport(pDialog, channels, activeSetting.destfile, false,
|
||||||
|
activeSetting.t0, activeSetting.t1, activeSetting.filetags);
|
||||||
if (ok != ProgressResult::Success && ok != ProgressResult::Stopped) {
|
if (ok != ProgressResult::Success && ok != ProgressResult::Stopped) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -887,6 +889,7 @@ ProgressResult ExportMultiple::ExportMultipleByTrack(bool byName,
|
||||||
// loop
|
// loop
|
||||||
int count = 0; // count the number of sucessful runs
|
int count = 0; // count the number of sucessful runs
|
||||||
ExportKit activeSetting; // pointer to the settings in use for this export
|
ExportKit activeSetting; // pointer to the settings in use for this export
|
||||||
|
std::unique_ptr<ProgressDialog> pDialog;
|
||||||
for (tr = iter.First(mTracks); tr != NULL; tr = iter.Next()) {
|
for (tr = iter.First(mTracks); tr != NULL; tr = iter.Next()) {
|
||||||
|
|
||||||
// Want only non-muted wave tracks.
|
// Want only non-muted wave tracks.
|
||||||
|
@ -918,7 +921,9 @@ ProgressResult ExportMultiple::ExportMultipleByTrack(bool byName,
|
||||||
tr2->SetSelected(true);
|
tr2->SetSelected(true);
|
||||||
|
|
||||||
// Export the data. "channels" are per track.
|
// Export the data. "channels" are per track.
|
||||||
ok = DoExport(activeSetting.channels, activeSetting.destfile, true, activeSetting.t0, activeSetting.t1, activeSetting.filetags);
|
ok = DoExport(pDialog,
|
||||||
|
activeSetting.channels, activeSetting.destfile, true,
|
||||||
|
activeSetting.t0, activeSetting.t1, activeSetting.filetags);
|
||||||
|
|
||||||
// Stop if an error occurred
|
// Stop if an error occurred
|
||||||
if (ok != ProgressResult::Success && ok != ProgressResult::Stopped) {
|
if (ok != ProgressResult::Success && ok != ProgressResult::Stopped) {
|
||||||
|
@ -932,7 +937,8 @@ ProgressResult ExportMultiple::ExportMultipleByTrack(bool byName,
|
||||||
return ok ;
|
return ok ;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProgressResult ExportMultiple::DoExport(unsigned channels,
|
ProgressResult ExportMultiple::DoExport(std::unique_ptr<ProgressDialog> &pDialog,
|
||||||
|
unsigned channels,
|
||||||
const wxFileName &inName,
|
const wxFileName &inName,
|
||||||
bool selectedOnly,
|
bool selectedOnly,
|
||||||
double t0,
|
double t0,
|
||||||
|
@ -1001,6 +1007,7 @@ ProgressResult ExportMultiple::DoExport(unsigned channels,
|
||||||
|
|
||||||
// Call the format export routine
|
// Call the format export routine
|
||||||
success = mPlugins[mPluginIndex]->Export(mProject,
|
success = mPlugins[mPluginIndex]->Export(mProject,
|
||||||
|
pDialog,
|
||||||
channels,
|
channels,
|
||||||
fullPath,
|
fullPath,
|
||||||
selectedOnly,
|
selectedOnly,
|
||||||
|
|
|
@ -75,7 +75,8 @@ private:
|
||||||
* @param t1 End time for export
|
* @param t1 End time for export
|
||||||
* @param tags Metadata to include in the file (if possible).
|
* @param tags Metadata to include in the file (if possible).
|
||||||
*/
|
*/
|
||||||
ProgressResult DoExport(unsigned channels,
|
ProgressResult DoExport(std::unique_ptr<ProgressDialog> &pDialog,
|
||||||
|
unsigned channels,
|
||||||
const wxFileName &name,
|
const wxFileName &name,
|
||||||
bool selectedOnly,
|
bool selectedOnly,
|
||||||
double t0,
|
double t0,
|
||||||
|
|
|
@ -133,6 +133,7 @@ public:
|
||||||
wxWindow *OptionsCreate(wxWindow *parent, int format) override;
|
wxWindow *OptionsCreate(wxWindow *parent, int format) override;
|
||||||
|
|
||||||
ProgressResult Export(AudacityProject *project,
|
ProgressResult Export(AudacityProject *project,
|
||||||
|
std::unique_ptr<ProgressDialog> &pDialog,
|
||||||
unsigned channels,
|
unsigned channels,
|
||||||
const wxString &fName,
|
const wxString &fName,
|
||||||
bool selectedOnly,
|
bool selectedOnly,
|
||||||
|
@ -159,6 +160,7 @@ ExportOGG::ExportOGG()
|
||||||
}
|
}
|
||||||
|
|
||||||
ProgressResult ExportOGG::Export(AudacityProject *project,
|
ProgressResult ExportOGG::Export(AudacityProject *project,
|
||||||
|
std::unique_ptr<ProgressDialog> &pDialog,
|
||||||
unsigned numChannels,
|
unsigned numChannels,
|
||||||
const wxString &fName,
|
const wxString &fName,
|
||||||
bool selectionOnly,
|
bool selectionOnly,
|
||||||
|
@ -281,10 +283,11 @@ ProgressResult ExportOGG::Export(AudacityProject *project,
|
||||||
numChannels, SAMPLES_PER_RUN, false,
|
numChannels, SAMPLES_PER_RUN, false,
|
||||||
rate, floatSample, true, mixerSpec);
|
rate, floatSample, true, mixerSpec);
|
||||||
|
|
||||||
ProgressDialog progress(wxFileName(fName).GetName(),
|
InitProgress( pDialog, wxFileName(fName).GetName(),
|
||||||
selectionOnly ?
|
selectionOnly
|
||||||
_("Exporting the selected audio as Ogg Vorbis") :
|
? _("Exporting the selected audio as Ogg Vorbis")
|
||||||
_("Exporting the audio as Ogg Vorbis"));
|
: _("Exporting the audio as Ogg Vorbis") );
|
||||||
|
auto &progress = *pDialog;
|
||||||
|
|
||||||
while (updateResult == ProgressResult::Success && !eos) {
|
while (updateResult == ProgressResult::Success && !eos) {
|
||||||
float **vorbis_buffer = vorbis_analysis_buffer(&dsp, SAMPLES_PER_RUN);
|
float **vorbis_buffer = vorbis_analysis_buffer(&dsp, SAMPLES_PER_RUN);
|
||||||
|
|
|
@ -319,6 +319,7 @@ public:
|
||||||
|
|
||||||
wxWindow *OptionsCreate(wxWindow *parent, int format) override;
|
wxWindow *OptionsCreate(wxWindow *parent, int format) override;
|
||||||
ProgressResult Export(AudacityProject *project,
|
ProgressResult Export(AudacityProject *project,
|
||||||
|
std::unique_ptr<ProgressDialog> &pDialog,
|
||||||
unsigned channels,
|
unsigned channels,
|
||||||
const wxString &fName,
|
const wxString &fName,
|
||||||
bool selectedOnly,
|
bool selectedOnly,
|
||||||
|
@ -390,6 +391,7 @@ ExportPCM::ExportPCM()
|
||||||
* file type, or giving the user full control over libsndfile.
|
* file type, or giving the user full control over libsndfile.
|
||||||
*/
|
*/
|
||||||
ProgressResult ExportPCM::Export(AudacityProject *project,
|
ProgressResult ExportPCM::Export(AudacityProject *project,
|
||||||
|
std::unique_ptr<ProgressDialog> &pDialog,
|
||||||
unsigned numChannels,
|
unsigned numChannels,
|
||||||
const wxString &fName,
|
const wxString &fName,
|
||||||
bool selectionOnly,
|
bool selectionOnly,
|
||||||
|
@ -489,12 +491,13 @@ ProgressResult ExportPCM::Export(AudacityProject *project,
|
||||||
info.channels, maxBlockLen, true,
|
info.channels, maxBlockLen, true,
|
||||||
rate, format, true, mixerSpec);
|
rate, format, true, mixerSpec);
|
||||||
|
|
||||||
ProgressDialog progress(wxFileName(fName).GetName(),
|
InitProgress( pDialog, wxFileName(fName).GetName(),
|
||||||
selectionOnly ?
|
selectionOnly
|
||||||
wxString::Format(_("Exporting the selected audio as %s"),
|
? wxString::Format(_("Exporting the selected audio as %s"),
|
||||||
formatStr) :
|
formatStr)
|
||||||
wxString::Format(_("Exporting the audio as %s"),
|
: wxString::Format(_("Exporting the audio as %s"),
|
||||||
formatStr));
|
formatStr) );
|
||||||
|
auto &progress = *pDialog;
|
||||||
|
|
||||||
while (updateResult == ProgressResult::Success) {
|
while (updateResult == ProgressResult::Success) {
|
||||||
sf_count_t samplesWritten;
|
sf_count_t samplesWritten;
|
||||||
|
|
|
@ -997,7 +997,6 @@ END_EVENT_TABLE()
|
||||||
ProgressDialog::ProgressDialog()
|
ProgressDialog::ProgressDialog()
|
||||||
: wxDialogWrapper()
|
: wxDialogWrapper()
|
||||||
{
|
{
|
||||||
Init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ProgressDialog::ProgressDialog(const wxString & title,
|
ProgressDialog::ProgressDialog(const wxString & title,
|
||||||
|
@ -1006,8 +1005,6 @@ ProgressDialog::ProgressDialog(const wxString & title,
|
||||||
const wxString & sRemainingLabelText /* = wxEmptyString */)
|
const wxString & sRemainingLabelText /* = wxEmptyString */)
|
||||||
: wxDialogWrapper()
|
: wxDialogWrapper()
|
||||||
{
|
{
|
||||||
Init();
|
|
||||||
|
|
||||||
Create(title, message, flags, sRemainingLabelText);
|
Create(title, message, flags, sRemainingLabelText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1017,8 +1014,6 @@ ProgressDialog::ProgressDialog(const wxString & title,
|
||||||
const wxString & sRemainingLabelText /* = wxEmptyString */)
|
const wxString & sRemainingLabelText /* = wxEmptyString */)
|
||||||
: wxDialogWrapper()
|
: wxDialogWrapper()
|
||||||
{
|
{
|
||||||
Init();
|
|
||||||
|
|
||||||
Create(title, columns, flags, sRemainingLabelText);
|
Create(title, columns, flags, sRemainingLabelText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1059,10 +1054,6 @@ ProgressDialog::~ProgressDialog()
|
||||||
|
|
||||||
void ProgressDialog::Init()
|
void ProgressDialog::Init()
|
||||||
{
|
{
|
||||||
mLastValue = 0;
|
|
||||||
mDisable = NULL;
|
|
||||||
mIsTransparent = true;
|
|
||||||
|
|
||||||
// There's a problem where the focus is not returned to the window that had
|
// There's a problem where the focus is not returned to the window that had
|
||||||
// it before creating this object. The reason is because the focus events
|
// it before creating this object. The reason is because the focus events
|
||||||
// that are sent to the parent window after the wxWindowDisabler are created
|
// that are sent to the parent window after the wxWindowDisabler are created
|
||||||
|
@ -1082,6 +1073,34 @@ void ProgressDialog::Init()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProgressDialog::Reinit()
|
||||||
|
{
|
||||||
|
mLastValue = 0;
|
||||||
|
|
||||||
|
mStartTime = wxGetLocalTimeMillis().GetValue();
|
||||||
|
mLastUpdate = mStartTime;
|
||||||
|
mYieldTimer = mStartTime;
|
||||||
|
mCancel = false;
|
||||||
|
mStop = false;
|
||||||
|
|
||||||
|
// Because wxGTK is very sensitive about maintaining focus when
|
||||||
|
// this window is not shown, we always show it. But, since we
|
||||||
|
// want a 500ms delay before it's actually visible for those
|
||||||
|
// quick tasks, we show it as transparent. If the initial
|
||||||
|
// delay is exceeded, then we reset the dialog to full opacity.
|
||||||
|
SetTransparent(0);
|
||||||
|
mIsTransparent = true;
|
||||||
|
|
||||||
|
auto button = FindWindowById(wxID_CANCEL, this);
|
||||||
|
if (button)
|
||||||
|
button->Enable();
|
||||||
|
button = FindWindowById(wxID_OK, this);
|
||||||
|
if (button)
|
||||||
|
button->Enable();
|
||||||
|
|
||||||
|
wxDialogWrapper::Show(true);
|
||||||
|
}
|
||||||
|
|
||||||
// Add a NEW text column each time this is called.
|
// Add a NEW text column each time this is called.
|
||||||
void ProgressDialog::AddMessageAsColumn(wxBoxSizer * pSizer,
|
void ProgressDialog::AddMessageAsColumn(wxBoxSizer * pSizer,
|
||||||
const MessageColumn & column,
|
const MessageColumn & column,
|
||||||
|
@ -1138,6 +1157,8 @@ bool ProgressDialog::Create(const wxString & title,
|
||||||
int flags /* = pdlgDefaultFlags */,
|
int flags /* = pdlgDefaultFlags */,
|
||||||
const wxString & sRemainingLabelText /* = wxEmptyString */)
|
const wxString & sRemainingLabelText /* = wxEmptyString */)
|
||||||
{
|
{
|
||||||
|
Init();
|
||||||
|
|
||||||
wxWindow *parent = GetParentForModalDialog(NULL, 0);
|
wxWindow *parent = GetParentForModalDialog(NULL, 0);
|
||||||
|
|
||||||
// Set this boolean to indicate if we are using the "Elapsed" labels
|
// Set this boolean to indicate if we are using the "Elapsed" labels
|
||||||
|
@ -1267,21 +1288,7 @@ bool ProgressDialog::Create(const wxString & title,
|
||||||
|
|
||||||
Centre(wxCENTER_FRAME | wxBOTH);
|
Centre(wxCENTER_FRAME | wxBOTH);
|
||||||
|
|
||||||
mStartTime = wxGetLocalTimeMillis().GetValue();
|
Reinit();
|
||||||
mLastUpdate = mStartTime;
|
|
||||||
mYieldTimer = mStartTime;
|
|
||||||
mCancel = false;
|
|
||||||
mStop = false;
|
|
||||||
|
|
||||||
// Because wxGTK is very sensitive about maintaining focus when
|
|
||||||
// this window is not shown, we always show it. But, since we
|
|
||||||
// want a 500ms delay before it's actually visible for those
|
|
||||||
// quick tasks, we show it as transparent. If the initial
|
|
||||||
// delay is exceeded, then we reset the dialog to full opacity.
|
|
||||||
SetTransparent(0);
|
|
||||||
mIsTransparent = true;
|
|
||||||
|
|
||||||
wxDialogWrapper::Show(true);
|
|
||||||
|
|
||||||
// Even though we won't necessarily show the dialog due to the 500ms
|
// Even though we won't necessarily show the dialog due to the 500ms
|
||||||
// delay, we MUST disable other windows/menus anyway since we run the risk
|
// delay, we MUST disable other windows/menus anyway since we run the risk
|
||||||
|
|
|
@ -86,6 +86,8 @@ public:
|
||||||
int flags = pdlgDefaultFlags,
|
int flags = pdlgDefaultFlags,
|
||||||
const wxString & sRemainingLabelText = wxEmptyString);
|
const wxString & sRemainingLabelText = wxEmptyString);
|
||||||
|
|
||||||
|
void Reinit();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool Create(const wxString & title,
|
bool Create(const wxString & title,
|
||||||
const MessageTable & columns,
|
const MessageTable & columns,
|
||||||
|
@ -103,7 +105,7 @@ public:
|
||||||
void SetMessage(const wxString & message);
|
void SetMessage(const wxString & message);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
wxWindow *mHadFocus;
|
wxWeakRef<wxWindow> mHadFocus;
|
||||||
|
|
||||||
wxStaticText *mElapsed;
|
wxStaticText *mElapsed;
|
||||||
wxStaticText *mRemaining;
|
wxStaticText *mRemaining;
|
||||||
|
|
Loading…
Reference in New Issue