1 /*---------------------------------------------------------------------\
3 | __ __ ____ _____ ____ |
4 | \ \ / /_ _/ ___|_ _|___ \ |
5 | \ V / _` \___ \ | | __) | |
6 | | | (_| |___) || | / __/ |
7 | |_|\__,_|____/ |_| |_____| |
11 \----------------------------------------------------------------------/
15 Author: Stefan Hundhammer <sh@suse.de>
22 #define y2log_component "qt-ui"
23 #include <ycp/y2log.h>
28 #include "YQIntField.h"
29 #include "YQSignalBlocker.h"
30 #include "YQWidgetCaption.h"
31 #include <QVBoxLayout>
33 YQIntField::YQIntField( YWidget * parent,
38 : QFrame( (QWidget *) parent->widgetRep() )
39 , YIntField( parent, label, minValue, 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_spinBox = new QSpinBox( minValue, maxValue,
56 YUI_CHECK_NEW( _qt_spinBox );
57 layout->addWidget( _qt_spinBox );
59 _qt_spinBox->setValue( initialValue );
61 _caption->setBuddy( _qt_spinBox );
63 setValue( initialValue );
65 connect( _qt_spinBox, SIGNAL( valueChanged ( int ) ),
66 this, SLOT ( valueChangedSlot( int ) ) );
70 YQIntField::~YQIntField()
79 return _qt_spinBox->value();
84 YQIntField::setValueInternal( int newValue )
86 YQSignalBlocker sigBlocker( _qt_spinBox );
87 _qt_spinBox->setValue( newValue );
92 YQIntField::valueChangedSlot( int newValue )
95 YQUI::ui()->sendEvent( new YWidgetEvent( this, YEvent::ValueChanged ) );
96 emit valueChanged( newValue );
101 YQIntField::setLabel( const string & newLabel )
103 YIntField::setLabel( newLabel );
104 _caption->setText( newLabel );
109 YQIntField::setEnabled( bool enabled )
111 _caption->setEnabled ( enabled );
112 _qt_spinBox->setEnabled( enabled );
113 YWidget::setEnabled( enabled );
118 YQIntField::preferredWidth()
120 return sizeHint().width();
125 YQIntField::preferredHeight()
127 return sizeHint().height();
132 YQIntField::setSize( int newWidth, int newHeight )
134 resize( newWidth, newHeight );
139 YQIntField::setKeyboardFocus()
141 _qt_spinBox->setFocus();
147 #include "YQIntField.moc"