Skip to content
Browse files

using a single progress bar

  • Loading branch information...
1 parent 5cbf371 commit 9b0c5edce1cc6516da0923e0e687041ddfab6d0f @saurabhsood91 saurabhsood91 committed
Showing with 13 additions and 15 deletions.
  1. +12 −14 src/installscreen.cpp
  2. +1 −1 src/installscreen.h
View
26 src/installscreen.cpp
@@ -44,6 +44,15 @@ InstallScreen::InstallScreen(PackageBackend *backend, QString *tmpFileName, QObj
m_installStatus = new QLabel( "Downloading and Installing Packages" );
m_cancel = new QPushButton( "Cancel Installation" );
+ m_progressBar = new QProgressBar;
+ m_progressBar->setFixedHeight( 20 );
+ m_progressBar->setMinimum( 0 );
+ m_progressBar->setMaximum( 100 );
+ m_progressBar->setRange( 0, 100 );
+
+ installLayout->addWidget( m_progressBar );
+ installLayout->setSpacing( 20 );
+
foreach( QUrl iter, m_backend->repositories() ) {
QLabel *sourceLabel = new QLabel( QString( "Added Source: %1" ).arg( iter.toString() ) );
sourceLabel->setStyleSheet( "background-color: rgb(254, 250, 210); border-bottom : 1px solid rgb(252,233,79); border-left : 1px solid rgb(196,181,147); border-top : 1px solid rgb(196,181,147); border-right : 1px solid rgb(196,181,147);" );
@@ -61,15 +70,8 @@ InstallScreen::InstallScreen(PackageBackend *backend, QString *tmpFileName, QObj
QLabel *package = new QLabel( QString( "<b>Installing: </b> %1" ).arg( iter ) );
package->setFixedHeight( 40 );
package->setStyleSheet( "background-color : white" );
- QProgressBar * progressBar = new QProgressBar;
- m_progressBars.insert( i, progressBar );
- progressBar->setFixedHeight( 20 );
- progressBar->setMinimum( 0 );
- progressBar->setMaximum( 100 );
- progressBar->setRange( 0, 100 );
packageLayout->addWidget( package );
packageLayout->setSpacing( 200 );
- packageLayout->addWidget( progressBar );
installLayout->addLayout( packageLayout );
}
@@ -88,9 +90,7 @@ InstallScreen::InstallScreen(PackageBackend *backend, QString *tmpFileName, QObj
void InstallScreen::showCompletionStatus()
{
- foreach( QProgressBar *progress, m_progressBars ) {
- progress->hide();
- }
+ m_progressBar->hide();
foreach( QHBoxLayout *l, m_packageLayouts ) {
QLabel *completed = new QLabel( "Installed" );
@@ -119,9 +119,7 @@ void InstallScreen::logFileChanged( QString path )
qDebug() << val;
- foreach( QProgressBar *progress, m_progressBars ) {
- if( val > 0 )
- progress->setValue( val );
- }
+ m_progressBar->setValue( val );
+
}
}
View
2 src/installscreen.h
@@ -46,7 +46,7 @@ private slots:
QString *m_tmpFileName;
QHash< int, QHBoxLayout* > m_packageLayouts;
- QHash< int, QProgressBar* > m_progressBars;
+ QProgressBar *m_progressBar;
QFileSystemWatcher *m_watcher;

0 comments on commit 9b0c5ed

Please sign in to comment.
Something went wrong with that request. Please try again.