Gerbview: better progress reporter info when loading more than one file

This commit is contained in:
jean-pierre charras 2019-08-25 20:32:40 +02:00
parent 7c37641d83
commit 4f73530c4a
1 changed files with 8 additions and 8 deletions

View File

@ -269,10 +269,7 @@ bool GERBVIEW_FRAME::loadListOfGerberAndDrillFiles( const wxString& aPath,
wxString msg; wxString msg;
WX_STRING_REPORTER reporter( &msg ); WX_STRING_REPORTER reporter( &msg );
// Show progress dialog after 1 second of loading // Create progress dialog (only used if more than 1 file to load
static const long long progressShowDelay = 1000;
auto startTime = wxGetUTCTimeMillis();
std::unique_ptr<WX_PROGRESS_REPORTER> progress = nullptr; std::unique_ptr<WX_PROGRESS_REPORTER> progress = nullptr;
for( unsigned ii = 0; ii < aFilenameList.GetCount(); ii++ ) for( unsigned ii = 0; ii < aFilenameList.GetCount(); ii++ )
@ -294,20 +291,23 @@ bool GERBVIEW_FRAME::loadListOfGerberAndDrillFiles( const wxString& aPath,
continue; continue;
} }
if( !progress && wxGetUTCTimeMillis() - startTime > progressShowDelay ) m_lastFileName = filename.GetFullPath();
if( !progress && ( aFilenameList.GetCount() > 1 ) )
{ {
progress = std::make_unique<WX_PROGRESS_REPORTER>( this, progress = std::make_unique<WX_PROGRESS_REPORTER>( this,
_( "Loading Gerber files..." ), 1, false ); _( "Loading Gerber files..." ), 1, false );
progress->SetMaxProgress( aFilenameList.GetCount() - 1 ); progress->SetMaxProgress( aFilenameList.GetCount() - 1 );
progress->Report( _("Loading Gerber files..." ) ); progress->Report( wxString::Format( _("Loading %d/%d %s" ), ii+1,
aFilenameList.GetCount(), m_lastFileName ) );
} }
else if( progress ) else if( progress )
{ {
progress->Report( wxString::Format( _("Loading %d/%d %s" ), ii+1,
aFilenameList.GetCount(), m_lastFileName ) );
progress->KeepRefreshing(); progress->KeepRefreshing();
} }
m_lastFileName = filename.GetFullPath();
SetActiveLayer( layer, false ); SetActiveLayer( layer, false );
visibility[ layer ] = true; visibility[ layer ] = true;