1 /*---------------------------------------------------------------------\
3 | __ __ ____ _____ ____ |
4 | \ \ / /_ _/ ___|_ _|___ \ |
5 | \ V / _` \___ \ | | __) | |
6 | | | (_| |___) || | / __/ |
7 | |_|\__,_|____/ |_| |_____| |
11 \----------------------------------------------------------------------/
13 File: YQProgressBar.cc
15 Author: Stefan Hundhammer <sh@suse.de>
20 #include <qprogressbar.h>
21 #include <QVBoxLayout>
24 #define y2log_component "qt-ui"
25 #include <ycp/y2log.h>
31 #include "YQProgressBar.h"
32 #include "YQWidgetCaption.h"
35 YQProgressBar::YQProgressBar( YWidget * parent,
38 : QFrame( (QWidget *) parent->widgetRep() )
39 , YProgressBar( parent, label, maxValue )
41 QVBoxLayout* layout = new QVBoxLayout( this );
46 layout->setSpacing( YQWidgetSpacing );
47 layout->setMargin ( YQWidgetMargin );
49 _caption = new YQWidgetCaption( this, label );
50 YUI_CHECK_NEW( _caption );
51 layout->addWidget( _caption );
53 _qt_progressbar = new QProgressBar( this );
54 _qt_progressbar->setRange(0, maxValue);
55 YUI_CHECK_NEW( _qt_progressbar );
56 layout->addWidget( _qt_progressbar );
58 _caption->setBuddy( _qt_progressbar );
62 YQProgressBar::~YQProgressBar()
68 void YQProgressBar::setLabel( const string & label )
70 _caption->setText( label );
71 YProgressBar::setLabel( label );
75 void YQProgressBar::setValue( int newValue )
77 YProgressBar::setValue( newValue );
78 _qt_progressbar->setValue( value() );
83 void YQProgressBar::setEnabled( bool enabled )
85 _caption->setEnabled( enabled );
86 _qt_progressbar->setEnabled( enabled );
87 YWidget::setEnabled( enabled );
91 int YQProgressBar::preferredWidth()
93 int hintWidth = _caption->isShown() ?
94 _caption->sizeHint().width() + layout()->margin() : 0;
96 return max( 200, hintWidth );
100 int YQProgressBar::preferredHeight()
102 return sizeHint().height();
106 void YQProgressBar::setSize( int newWidth, int newHeight )
108 resize( newWidth, newHeight );
112 bool YQProgressBar::setKeyboardFocus()
114 _qt_progressbar->setFocus();
120 #include "YQProgressBar.moc"