ProgressBar connections modified + Progress Bar class itself updated
[qtmeetings] / src / UserInterface / Utils / ProgressBar.cpp
index a43098d..30f6056 100755 (executable)
@@ -1,12 +1,17 @@
 #include "ProgressBar.h"
+#include "ObservedWidget.h"
 
 #include <QProgressBar>
-#include <QBoxLayout>
+#include <QVBoxLayout>
+#include <QHBoxLayout>
 #include <QPushButton>
+#include <QLabel>
+#include <QtDebug>
 
-ProgressBar::ProgressBar( const QString &aText, QWidget *aParent ) :
+ProgressBar::ProgressBar( const QString &aText, bool aCancellable, QWidget *aParent ) :
        QDialog( aParent )
 {
+       qDebug() << "ProgressBar::ProgressBar( const QString &, bool, QWidget *)";
        setWindowTitle( aText );
        setModal( true );
 
@@ -14,21 +19,29 @@ ProgressBar::ProgressBar( const QString &aText, QWidget *aParent ) :
        iProgress->setMinimumWidth( 200 );
        iProgress->setMaximum( 0 );
        iProgress->setTextVisible( false );
-
-       QBoxLayout* layout = new QBoxLayout( QBoxLayout::LeftToRight, this );
-       layout->setSizeConstraint( QLayout::SetDefaultConstraint );
-       layout->addWidget( iProgress, 0, Qt::AlignHCenter );
-       
-       QPushButton *buttonCancel = new QPushButton( tr( "Cancel" ) );
-       layout->addSpacing( 5 );
-       layout->addWidget( buttonCancel );
        
-       connect( buttonCancel, SIGNAL( pressed() ), this, SIGNAL( cancel() ) );
-       connect( iProgress, SIGNAL( valueChanged( int ) ), this, SIGNAL( started() ) );
+       QVBoxLayout *mainLayout = new QVBoxLayout;
+       iLabel = new QLabel();
+       mainLayout->addWidget( iLabel );
+       QHBoxLayout *subLayout = new QHBoxLayout;
+       subLayout->addWidget( iProgress );
+       if( aCancellable ) {
+               QPushButton *buttonCancel = new QPushButton( tr( "Cancel" ) );
+               subLayout->addSpacing( 5 );
+               subLayout->addWidget( buttonCancel );
+               connect( buttonCancel, SIGNAL( pressed() ), this, SIGNAL( cancel() ) );
+       }
        
-       setLayout( layout );
+       setLayout( mainLayout );
 }
 
 ProgressBar::~ProgressBar()
 {
+       qDebug() << "ProgressBar::~ProgressBar()";
 }
+
+void ProgressBar::update( const QString &aMessage )
+{
+       qDebug() << "ProgressBar::update( const QString & )";
+       iLabel->setText( aMessage );
+}
\ No newline at end of file