25#define GAUGE_RANGE 1000
32 m_currentProgress( 0 ),
33 m_currentProgressTotal( 0 ),
36 m_appProgressIndicator( parent->GetParent(),
GAUGE_RANGE )
44 if( !aShowDownloadSection )
68 std::lock_guard<std::mutex> guard(
m_mutex );
69 m_reports.push_back( std::make_pair( aText, aSeverity ) );
82 return ( aValue + 999 ) / 1000;
113 double current = ( total > 0 ) ? (
double( cp ) / double( total ) ) : 0;
116 current = ( phase + current ) / phases;
118 if( current > 1.0 || finished )
131 m_downloadText->SetLabel( wxString::Format(
_(
"Downloaded %lld/%lld kB" ),
137 if( current > 1.0 || finished )
143 std::lock_guard<std::mutex> guard(
m_mutex );
145 for(
const std::pair<wxString, SEVERITY>& pair :
m_reports )
Class DIALOG_PCM_PROGRESS_BASE.
wxPanel * m_panelDownload
wxButton * m_buttonCancel
wxGauge * m_downloadGauge
wxStaticText * m_downloadText
WX_HTML_REPORT_BOX * m_reporter
std::atomic_int64_t m_currentProgressTotal
std::atomic_int64_t m_currentProgress
void OnCloseClicked(wxCommandEvent &event) override
std::atomic_bool m_finished
void OnCancelClicked(wxCommandEvent &event) override
void AdvancePhase() override
Safe to call from non-UI thread. Disables cancel button, enables close button.
wxAppProgressIndicator m_appProgressIndicator
void SetDownloadProgress(uint64_t aDownloaded, 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)
Safe to call from non-UI thread. Advances to the next package.
std::vector< std::pair< wxString, SEVERITY > > m_reports
void PCMReport(const wxString &aText, SEVERITY aSeverity)
Safe to call from non-UI thread. Sets the download progress of the current zip entry.
static uint64_t toKb(uint64_t aValue)
DIALOG_PCM_PROGRESS(wxWindow *parent, bool aShowDownloadSection=true)
Constructor.
std::atomic_int64_t m_downloadTotal
std::atomic_int64_t m_downloaded
This implements all the tricky bits for thread safety, but the GUI is left to derived classes.
virtual void AdvancePhase() override
Use the next available virtual zone of the dialog progress bar.
std::atomic_int m_numPhases
std::atomic_bool m_cancelled
std::atomic_int m_progress
void SetNumPhases(int aNumPhases) override
Set the number of phases.
std::atomic_int m_maxProgress
void SetImmediateMode()
In immediate mode, messages are flushed as they are added.
REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Report a string with a given severity.