1 /*---------------------------------------------------------------------\
3 | __ __ ____ _____ ____ |
4 | \ \ / /_ _/ ___|_ _|___ \ |
5 | \ V / _` \___ \ | | __) | |
6 | | | (_| |___) || | / __/ |
7 | |_|\__,_|____/ |_| |_____| |
11 \----------------------------------------------------------------------/
15 Author: Stefan Hundhammer <sh@suse.de>
21 #include <qprogressbar.h>
23 #define y2log_component "qt-ui"
24 #include <ycp/y2log.h>
28 #include "YQDownloadProgress.h"
29 #include "YQWidgetCaption.h"
32 YQDownloadProgress::YQDownloadProgress( YWidget * parent,
34 const string & filename,
35 YFileSize_t expectedSize )
36 : QVBox( (QWidget *) parent->widgetRep() )
37 , YDownloadProgress( parent, label, filename, expectedSize )
40 setMargin( YQWidgetMargin );
42 _caption = new YQWidgetCaption( this, label );
43 YUI_CHECK_NEW( _caption );
45 _qt_progressBar = new QProgressBar( this );
46 YUI_CHECK_NEW( _qt_progressBar );
48 _qt_progressBar->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
49 _qt_progressBar->setTotalSteps( 100 ); // Using percent
50 _qt_progressBar->setProgress( currentPercent() );
52 _timer = new QTimer( this );
54 connect( _timer, SIGNAL( timeout() ),
55 this, SLOT ( pollFileSize() ) );
57 _timer->start( 250, // millisec
58 false ); // single shot?
62 YQDownloadProgress::~YQDownloadProgress()
69 YQDownloadProgress::setLabel( const string & label )
71 _caption->setText( label );
72 YDownloadProgress::setLabel( label );
77 YQDownloadProgress::setFilename( const string & filename )
79 YDownloadProgress::setFilename( filename );
80 _qt_progressBar->setProgress( currentPercent() );
85 YQDownloadProgress::setExpectedSize( YFileSize_t expectedSize )
87 _qt_progressBar->setProgress( currentPercent() );
88 YDownloadProgress::setExpectedSize( expectedSize );
93 YQDownloadProgress::pollFileSize()
95 _qt_progressBar->setProgress( currentPercent() );
100 YQDownloadProgress::setEnabled( bool enabled )
102 _caption->setEnabled( enabled );
103 _qt_progressBar->setEnabled( enabled );
104 YWidget::setEnabled( enabled );
109 YQDownloadProgress::preferredWidth()
111 return sizeHint().width();
116 YQDownloadProgress::preferredHeight()
118 return sizeHint().height();
123 YQDownloadProgress::setSize( int newWidth, int newHeight )
125 resize( newWidth, newHeight );
129 #include "YQDownloadProgress.moc"