Clean up download progress vs package progress vs overall progress.
This commit is contained in:
parent
a22dd614b0
commit
43b840d9d2
|
@ -29,8 +29,8 @@ DIALOG_PCM_PROGRESS::DIALOG_PCM_PROGRESS( wxWindow* parent, bool aShowDownloadSe
|
|||
PROGRESS_REPORTER_BASE( 1 ),
|
||||
m_downloaded( 0 ),
|
||||
m_downloadTotal( 0 ),
|
||||
m_overallProgress( 0 ),
|
||||
m_overallProgressTotal( 0 ),
|
||||
m_currentProgress( 0 ),
|
||||
m_currentProgressTotal( 0 ),
|
||||
m_finished( false )
|
||||
#if wxCHECK_VERSION( 3, 1, 0 )
|
||||
,
|
||||
|
@ -53,7 +53,7 @@ DIALOG_PCM_PROGRESS::DIALOG_PCM_PROGRESS( wxWindow* parent, bool aShowDownloadSe
|
|||
void DIALOG_PCM_PROGRESS::OnCancelClicked( wxCommandEvent& event )
|
||||
{
|
||||
SetNumPhases( 1 );
|
||||
SetOverallProgress( 1, 1 );
|
||||
SetPackageProgress( 1, 1 );
|
||||
m_reporter->Report( _( "Aborting remaining tasks." ) );
|
||||
|
||||
m_cancelled.store( true );
|
||||
|
@ -87,10 +87,17 @@ uint64_t DIALOG_PCM_PROGRESS::toKb( uint64_t aValue )
|
|||
}
|
||||
|
||||
|
||||
void DIALOG_PCM_PROGRESS::SetOverallProgress( uint64_t aProgress, uint64_t aTotal )
|
||||
void DIALOG_PCM_PROGRESS::SetPackageProgress( uint64_t aProgress, uint64_t aTotal )
|
||||
{
|
||||
m_overallProgress.store( std::min( aProgress, aTotal ) );
|
||||
m_overallProgressTotal.store( aTotal );
|
||||
m_currentProgress.store( std::min( aProgress, aTotal ) );
|
||||
m_currentProgressTotal.store( aTotal );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_PCM_PROGRESS::AdvancePhase()
|
||||
{
|
||||
PROGRESS_REPORTER_BASE::AdvancePhase();
|
||||
m_currentProgress.store( 0 );
|
||||
}
|
||||
|
||||
|
||||
|
@ -105,7 +112,7 @@ bool DIALOG_PCM_PROGRESS::updateUI()
|
|||
bool finished = m_finished.load();
|
||||
int phase = m_phase.load();
|
||||
int phases = m_numPhases.load();
|
||||
double current = m_overallProgress.load() / (double) m_overallProgressTotal.load();
|
||||
double current = m_currentProgress.load() / (double) m_currentProgressTotal.load();
|
||||
|
||||
if( phases > 0 )
|
||||
current = ( phase + current ) / phases;
|
||||
|
|
|
@ -48,16 +48,19 @@ public:
|
|||
/** Constructor */
|
||||
DIALOG_PCM_PROGRESS( wxWindow* parent, bool aShowDownloadSection = true );
|
||||
|
||||
///< Thread safe. Adds a message to detailed report window.
|
||||
///< Safe to call from non-UI thread. Adds a message to detailed report window.
|
||||
void Report( const wxString& aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED );
|
||||
|
||||
///< Thread safe. Sets current download progress gauge and text.
|
||||
///< Safe to call from non-UI thread. Sets the download progress of the current zip entry.
|
||||
void SetDownloadProgress( uint64_t aDownloaded, uint64_t aTotal );
|
||||
|
||||
///< Safe to call from non-UI thread. Sets current overall progress gauge.
|
||||
void SetOverallProgress( uint64_t aProgress, uint64_t aTotal );
|
||||
///< Safe to call from non-UI thread. Sets the download prgress of the current package.
|
||||
void SetPackageProgress( uint64_t aProgress, uint64_t aTotal );
|
||||
|
||||
///< Thread safe. Disables cancel button, enables close button.
|
||||
///< Safe to call from non-UI thread. Advances to the next package.
|
||||
void AdvancePhase() override;
|
||||
|
||||
///< Safe to call from non-UI thread. Disables cancel button, enables close button.
|
||||
void SetFinished();
|
||||
|
||||
private:
|
||||
|
@ -69,8 +72,8 @@ private:
|
|||
std::atomic_int64_t m_downloaded;
|
||||
std::atomic_int64_t m_downloadTotal;
|
||||
|
||||
std::atomic_int64_t m_overallProgress;
|
||||
std::atomic_int64_t m_overallProgressTotal;
|
||||
std::atomic_int64_t m_currentProgress;
|
||||
std::atomic_int64_t m_currentProgressTotal;
|
||||
|
||||
std::atomic_bool m_finished;
|
||||
|
||||
|
|
|
@ -234,7 +234,7 @@ bool PCM_TASK_MANAGER::extract( const wxString& aFilePath, const wxString& aPack
|
|||
}
|
||||
|
||||
extracted++;
|
||||
m_reporter->SetOverallProgress( extracted, entries );
|
||||
m_reporter->SetPackageProgress( extracted, entries );
|
||||
|
||||
if( !isMultiThreaded )
|
||||
m_reporter->KeepRefreshing( false );
|
||||
|
@ -252,7 +252,7 @@ bool PCM_TASK_MANAGER::extract( const wxString& aFilePath, const wxString& aPack
|
|||
}
|
||||
|
||||
m_reporter->Report( _( "Extracted package\n" ), RPT_SEVERITY_INFO );
|
||||
m_reporter->SetOverallProgress( entries, entries );
|
||||
m_reporter->SetPackageProgress( entries, entries );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue