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(this);
54 _qt_spinBox->setMinimum(minValue);
55 _qt_spinBox->setMaximum(maxValue);
56 _qt_spinBox->setSingleStep(1);
58 YUI_CHECK_NEW( _qt_spinBox );
59 layout->addWidget( _qt_spinBox );
61 _qt_spinBox->setValue( initialValue );
63 _caption->setBuddy( _qt_spinBox );
65 setValue( initialValue );
67 connect( _qt_spinBox, SIGNAL( valueChanged ( int ) ),
68 this, SLOT ( valueChangedSlot( int ) ) );
72 YQIntField::~YQIntField()
81 return _qt_spinBox->value();
86 YQIntField::setValueInternal( int newValue )
88 YQSignalBlocker sigBlocker( _qt_spinBox );
89 _qt_spinBox->setValue( newValue );
94 YQIntField::valueChangedSlot( int newValue )
97 YQUI::ui()->sendEvent( new YWidgetEvent( this, YEvent::ValueChanged ) );
98 emit valueChanged( newValue );
103 YQIntField::setLabel( const string & newLabel )
105 YIntField::setLabel( newLabel );
106 _caption->setText( newLabel );
111 YQIntField::setEnabled( bool enabled )
113 _caption->setEnabled ( enabled );
114 _qt_spinBox->setEnabled( enabled );
115 YWidget::setEnabled( enabled );
120 YQIntField::preferredWidth()
122 return sizeHint().width();
127 YQIntField::preferredHeight()
129 return sizeHint().height();
134 YQIntField::setSize( int newWidth, int newHeight )
136 resize( newWidth, newHeight );
141 YQIntField::setKeyboardFocus()
143 _qt_spinBox->setFocus();
149 #include "YQIntField.moc"