Corrected the password dialog and progress bar related errors. Texts and titles of...
[qtmeetings] / src / UserInterface / Utils / ProgressBar.cpp
index a43098d..198fb65 100755 (executable)
@@ -1,34 +1,62 @@
 #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 &aTitle, bool aCancellable, QWidget *aParent ) :
        QDialog( aParent )
 {
-       setWindowTitle( aText );
+       qDebug() << "ProgressBar::ProgressBar( const QString &, bool, QWidget *)";
+       setWindowTitle( aTitle );
        setModal( true );
 
        iProgress = new QProgressBar();
        iProgress->setMinimumWidth( 200 );
-       iProgress->setMaximum( 0 );
+       iProgress->setRange( 0, 0 );
+       iProgress->reset();
        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 );
+       QVBoxLayout *mainLayout = new QVBoxLayout;
+       iLabel = new QLabel();
+       mainLayout->addWidget( iLabel );
+       QHBoxLayout *subLayout = new QHBoxLayout;
+       subLayout->addWidget( iProgress );
        
-       connect( buttonCancel, SIGNAL( pressed() ), this, SIGNAL( cancel() ) );
-       connect( iProgress, SIGNAL( valueChanged( int ) ), this, SIGNAL( started() ) );
+       iButton = new QPushButton( tr( "Cancel" ) );
+       subLayout->addSpacing( 5 );
+       subLayout->addWidget( iButton );
+       connect( iButton, SIGNAL( pressed() ), this, SIGNAL( cancel() ) );
+       if( !aCancellable ) {
+               iButton->setVisible( false );
+       }
        
-       setLayout( layout );
+       mainLayout->addLayout( subLayout );
+       mainLayout->setAlignment( Qt::AlignCenter );
+       setLayout( mainLayout );
 }
 
 ProgressBar::~ProgressBar()
 {
+       qDebug() << "ProgressBar::~ProgressBar()";
+}
+
+void ProgressBar::update( const QString &aMessage, const QString &aTitle )
+{
+       qDebug() << "ProgressBar::update( const QString & )";
+       iLabel->setText( aMessage );
+       if( aTitle != "" )
+               setWindowTitle( aTitle );
+}
+
+void ProgressBar::toggleCancellable( bool aEnable )
+{
+       if( aEnable )
+               iButton->setVisible( true );
+       else
+               iButton->setVisible( false );
 }