Commit 81220db1 authored by Anton Anikin's avatar Anton Anikin

Fix StatusbarProgressWidget::slotProgressItemCompleted() method

The patch provides fix for case when StatusbarProgressWidget displays single status item which use busy indicator. Such items can be provided for example by jobs which don't know progress information during run. For this case old version displays progress bar in still busy state for "final" 5 seconds after the item is finished. Such behavior is very misleading - it's impossible to understand the state (run/finish) of progress item. New version fix this by changing the state of progress bar to 100% after item finishing, which is more clear for user.
parent 9ac2ba9a
......@@ -210,10 +210,21 @@ void StatusbarProgressWidget::slotProgressItemCompleted( ProgressItem *item )
item = nullptr;
return; // we are only interested in top level items
}
bool itemUsesBusyIndicator = item->usesBusyIndicator();
item->deleteLater();
item = nullptr;
connectSingleItem(); // if going back to 1 item
if ( ProgressManager::instance()->isEmpty() ) { // No item
// If completed item uses busy indicator and progress manager doesn't have any
// other items, then we should set it progress to 100% to indicate finishing.
// Without this fix we will show busy indicator for already finished item
// for next 5s.
if ( itemUsesBusyIndicator ) {
activateSingleItemMode( 100 );
}
// Done. In 5s the progress-widget will close, then we can clean up the statusbar
mCleanTimer->start( 5000 );
} else if ( mCurrentItem ) { // Exactly one item
......@@ -236,13 +247,18 @@ void StatusbarProgressWidget::connectSingleItem()
}
void StatusbarProgressWidget::activateSingleItemMode()
{
activateSingleItemMode( mCurrentItem->progress() );
}
void StatusbarProgressWidget::activateSingleItemMode( unsigned int progress )
{
m_pProgressBar->setMaximum( 100 );
m_pProgressBar->setValue( mCurrentItem->progress() );
m_pProgressBar->setValue( progress );
m_pProgressBar->setTextVisible( true );
#ifdef Q_OS_OSX
MacDockProgressView::setRange( 0, 100 );
MacDockProgressView::setProgress( mCurrentItem->progress() );
MacDockProgressView::setProgress( progress );
#endif
}
......
......@@ -67,6 +67,7 @@ protected:
void setMode();
void connectSingleItem();
void activateSingleItemMode();
void activateSingleItemMode( unsigned int progress );
bool eventFilter( QObject *, QEvent * ) override;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment