Fixes for project loading progress display (#3672)

Fix project loading progress jumping back.

Show the name of the track currently being loaded.
This commit is contained in:
Hyunjin Song
2017-07-07 03:47:01 +09:00
committed by Oskar Wallgren
parent 494714bf44
commit c6c67b3c75
3 changed files with 35 additions and 9 deletions

View File

@@ -97,6 +97,10 @@ public:
void processNextBuffer();
inline int getLoadingTrackCount() const
{
return m_nLoadingTrack;
}
inline int getMilliseconds() const
{
return m_elapsedMilliSeconds;
@@ -339,6 +343,7 @@ private:
ControllerVector m_controllers;
int m_nLoadingTrack;
QString m_fileName;
QString m_oldFileName;

View File

@@ -1054,6 +1054,27 @@ void Song::loadProject( const QString & fileName )
}
node = dataFile.content().firstChild();
QDomNodeList tclist=dataFile.content().elementsByTagName("trackcontainer");
m_nLoadingTrack=0;
for( int i=0,n=tclist.count(); i<n; ++i )
{
QDomNode nd=tclist.at(i).firstChild();
while(!nd.isNull())
{
if( nd.isElement() && nd.nodeName() == "track" )
{
++m_nLoadingTrack;
if( nd.toElement().attribute("type").toInt() == Track::BBTrack )
{
n += nd.toElement().elementsByTagName("bbtrack").at(0)
.toElement().firstChildElement().childNodes().count();
}
nd=nd.nextSibling();
}
}
}
while( !node.isNull() )
{
if( node.isElement() )

View File

@@ -86,25 +86,18 @@ void TrackContainer::loadSettings( const QDomElement & _this )
static QProgressDialog * pd = NULL;
bool was_null = ( pd == NULL );
int start_val = 0;
if( !journalRestore && gui != nullptr )
{
if( pd == NULL )
{
pd = new QProgressDialog( tr( "Loading project..." ),
tr( "Cancel" ), 0,
_this.childNodes().count(),
Engine::getSong()->getLoadingTrackCount(),
gui->mainWindow() );
pd->setWindowModality( Qt::ApplicationModal );
pd->setWindowTitle( tr( "Please wait..." ) );
pd->show();
}
else
{
start_val = pd->value();
pd->setMaximum( pd->maximum() +
_this.childNodes().count() );
}
}
QDomNode node = _this.firstChild();
@@ -124,6 +117,14 @@ void TrackContainer::loadSettings( const QDomElement & _this )
if( node.isElement() &&
!node.toElement().attribute( "metadata" ).toInt() )
{
QString trackName = node.toElement().hasAttribute( "name" ) ?
node.toElement().attribute( "name" ) :
node.firstChild().toElement().attribute( "name" );
if( pd != NULL )
{
pd->setLabelText( tr("Loading Track %1 (%2/Total %3)").arg( trackName ).
arg( pd->value() + 1 ).arg( Engine::getSong()->getLoadingTrackCount() ) );
}
Track::create( node.toElement(), this );
}
node = node.nextSibling();
@@ -131,7 +132,6 @@ void TrackContainer::loadSettings( const QDomElement & _this )
if( pd != NULL )
{
pd->setValue( start_val + _this.childNodes().count() );
if( was_null )
{
delete pd;