28 #define YUILogComponent "qt-ui" 29 #include <yui/YUILog.h> 33 #include "YQDownloadProgress.h" 34 #include "YQWidgetCaption.h" 35 #include <QVBoxLayout> 36 #include <QProgressBar> 43 const string & filename,
44 YFileSize_t expectedSize )
45 : QFrame( (QWidget *) parent->widgetRep() )
46 , YDownloadProgress( parent, label, filename, expectedSize )
48 QVBoxLayout* layout =
new QVBoxLayout(
this );
52 layout->setMargin( YQWidgetMargin );
55 YUI_CHECK_NEW( _caption );
56 layout->addWidget( _caption );
58 _qt_progressBar =
new QProgressBar(
this );
59 YUI_CHECK_NEW( _qt_progressBar );
60 layout->addWidget( _qt_progressBar );
62 _qt_progressBar->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
63 _qt_progressBar->setRange( 0, 100 );
64 _qt_progressBar->setValue( currentPercent() );
66 _timer =
new QTimer(
this );
68 connect( _timer, &pclass(_timer)::timeout,
71 _timer->setSingleShot(
false);
86 YDownloadProgress::setLabel( label );
93 YDownloadProgress::setFilename( filename );
94 _qt_progressBar->setValue( currentPercent() );
101 _qt_progressBar->setValue( currentPercent() );
102 YDownloadProgress::setExpectedSize( expectedSize );
109 _qt_progressBar->setValue( currentPercent() );
116 _caption->setEnabled( enabled );
117 _qt_progressBar->setEnabled( enabled );
118 YWidget::setEnabled( enabled );
125 return sizeHint().width();
132 return sizeHint().height();
139 resize( newWidth, newHeight );
virtual int preferredWidth()
Preferred width of the widget.
virtual void setEnabled(bool enabled)
Set enabled/disabled state.
virtual int preferredHeight()
Preferred height of the widget.
virtual void setExpectedSize(YFileSize_t expectedSize)
Change the expected file size.
virtual ~YQDownloadProgress()
Destructor.
virtual void setSize(int newWidth, int newHeight)
Set the new size of the widget.
YQDownloadProgress(YWidget *parent, const std::string &label, const std::string &filename, YFileSize_t expectedSize)
Constructor.
virtual void setFilename(const std::string &filename)
Set the name of a new file to monitor.
void pollFileSize(void)
Slot for polling and displaying the file size.
virtual void setLabel(const std::string &label)
Set the label (the text above the progress bar).