Corrected the password dialog and progress bar related errors. Texts and titles of...
[qtmeetings] / src / UserInterface / Utils / ProgressBar.cpp
1 #include "ProgressBar.h"
2 #include "ObservedWidget.h"
3
4 #include <QProgressBar>
5 #include <QVBoxLayout>
6 #include <QHBoxLayout>
7 #include <QPushButton>
8 #include <QLabel>
9 #include <QtDebug>
10
11 ProgressBar::ProgressBar( const QString &aTitle, bool aCancellable, QWidget *aParent ) :
12         QDialog( aParent )
13 {
14         qDebug() << "ProgressBar::ProgressBar( const QString &, bool, QWidget *)";
15         setWindowTitle( aTitle );
16         setModal( true );
17
18         iProgress = new QProgressBar();
19         iProgress->setMinimumWidth( 200 );
20         iProgress->setRange( 0, 0 );
21         iProgress->reset();
22         iProgress->setTextVisible( false );
23         
24         QVBoxLayout *mainLayout = new QVBoxLayout;
25         iLabel = new QLabel();
26         mainLayout->addWidget( iLabel );
27         QHBoxLayout *subLayout = new QHBoxLayout;
28         subLayout->addWidget( iProgress );
29         
30         iButton = new QPushButton( tr( "Cancel" ) );
31         subLayout->addSpacing( 5 );
32         subLayout->addWidget( iButton );
33         connect( iButton, SIGNAL( pressed() ), this, SIGNAL( cancel() ) );
34         if( !aCancellable ) {
35                 iButton->setVisible( false );
36         }
37         
38         mainLayout->addLayout( subLayout );
39         mainLayout->setAlignment( Qt::AlignCenter );
40         setLayout( mainLayout );
41 }
42
43 ProgressBar::~ProgressBar()
44 {
45         qDebug() << "ProgressBar::~ProgressBar()";
46 }
47
48 void ProgressBar::update( const QString &aMessage, const QString &aTitle )
49 {
50         qDebug() << "ProgressBar::update( const QString & )";
51         iLabel->setText( aMessage );
52         if( aTitle != "" )
53                 setWindowTitle( aTitle );
54 }
55
56 void ProgressBar::toggleCancellable( bool aEnable )
57 {
58         if( aEnable )
59                 iButton->setVisible( true );
60         else
61                 iButton->setVisible( false );
62 }