28 #define YUILogComponent "qt-ui" 29 #include <yui/YUILog.h> 33 #include "YQDownloadProgress.h" 34 #include "YQWidgetCaption.h" 35 #include <QVBoxLayout> 36 #include <QProgressBar> 39 const std::string & label,
40 const std::string & filename,
41 YFileSize_t expectedSize )
42 : QFrame( (QWidget *) parent->widgetRep() )
43 , YDownloadProgress( parent, label, filename, expectedSize )
45 QVBoxLayout* layout =
new QVBoxLayout(
this );
49 layout->setMargin( YQWidgetMargin );
52 YUI_CHECK_NEW( _caption );
53 layout->addWidget( _caption );
55 _qt_progressBar =
new QProgressBar(
this );
56 YUI_CHECK_NEW( _qt_progressBar );
57 layout->addWidget( _qt_progressBar );
59 _qt_progressBar->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
60 _qt_progressBar->setRange( 0, 100 );
61 _qt_progressBar->setValue( currentPercent() );
63 _timer =
new QTimer(
this );
65 connect( _timer, &pclass(_timer)::timeout,
68 _timer->setSingleShot(
false);
83 YDownloadProgress::setLabel( label );
90 YDownloadProgress::setFilename( filename );
91 _qt_progressBar->setValue( currentPercent() );
98 _qt_progressBar->setValue( currentPercent() );
99 YDownloadProgress::setExpectedSize( expectedSize );
106 _qt_progressBar->setValue( currentPercent() );
113 _caption->setEnabled( enabled );
114 _qt_progressBar->setEnabled( enabled );
115 YWidget::setEnabled( enabled );
122 return sizeHint().width();
129 return sizeHint().height();
136 resize( newWidth, newHeight );
140 #include "YQDownloadProgress.moc" 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).