1 /*---------------------------------------------------------------------\
3 | __ __ ____ _____ ____ |
4 | \ \ / /_ _/ ___|_ _|___ \ |
5 | \ V / _` \___ \ | | __) | |
6 | | | (_| |___) || | / __/ |
7 | |_|\__,_|____/ |_| |_____| |
11 \----------------------------------------------------------------------/
15 Author: Stefan Hundhammer <sh@suse.de>
20 #include <qcheckbox.h>
22 #define y2log_component "qt-ui"
23 #include <ycp/y2log.h>
26 #include "YQApplication.h"
29 #include "YQCheckBox.h"
35 YQCheckBox::YQCheckBox( YWidget * parent,
38 : QCheckBox( fromUTF8( label ), (QWidget *) parent->widgetRep() )
39 , YCheckBox( parent, label )
43 QCheckBox::setChecked( checked );
45 connect( this, SIGNAL( stateChanged( int ) ),
46 this, SLOT ( stateChanged( int ) ) );
50 YQCheckBox::~YQCheckBox()
59 switch ( checkState() )
61 case Qt::Checked: return YCheckBox_on;
62 case Qt::Unchecked: return YCheckBox_off;
63 case Qt::PartiallyChecked: return YCheckBox_dont_care;
71 YQCheckBox::setValue( YCheckBoxState newValue )
76 QCheckBox::setChecked( true );
81 QCheckBox::setChecked( false );
85 case YCheckBox_dont_care:
86 QCheckBox::setTristate( true );
87 setCheckState(Qt::PartiallyChecked);
93 void YQCheckBox::setLabel( const string & label )
95 setText( fromUTF8( label ) );
96 YCheckBox::setLabel( label );
100 void YQCheckBox::setUseBoldFont( bool useBold )
103 YQUI::yqApp()->boldFont() :
104 YQUI::yqApp()->currentFont() );
106 YCheckBox::setUseBoldFont( useBold );
110 void YQCheckBox::setEnabled( bool enabled )
112 QCheckBox::setEnabled( enabled );
113 YWidget::setEnabled( enabled );
117 int YQCheckBox::preferredWidth()
119 return 2*SPACING + sizeHint().width();
123 int YQCheckBox::preferredHeight()
125 return sizeHint().height();
129 void YQCheckBox::setSize( int newWidth, int newHeight )
131 resize( newWidth, newHeight );
135 bool YQCheckBox::setKeyboardFocus()
143 void YQCheckBox::stateChanged( int newState )
145 // y2milestone( "new state: %d", newState );
148 YQUI::ui()->sendEvent( new YWidgetEvent( this, YEvent::ValueChanged ) );
152 #include "YQCheckBox.moc"