2 #include <HYDROGUI_ColorWidget.h>
3 #include <QColorDialog>
5 HYDROGUI_ColorWidget::HYDROGUI_ColorWidget( QWidget* parent )
8 setFrameShape( QFrame::Box );
9 //setFixedSize( 40, 20 );
10 //commented for correct layout management
11 //(otherwise the column with color widget can not be resized
12 //and all free space is arranged on sides
15 HYDROGUI_ColorWidget::~HYDROGUI_ColorWidget()
19 QColor HYDROGUI_ColorWidget::color() const
21 QPalette aPalette = palette();
22 return aPalette.color( QPalette::Window );
25 void HYDROGUI_ColorWidget::setColor( const QColor& c )
27 QPalette aPalette = palette();
28 aPalette.setColor( QPalette::Window, c );
29 setAutoFillBackground( true );
30 setPalette( aPalette );
33 void HYDROGUI_ColorWidget::mouseDoubleClickEvent( QMouseEvent* )
35 QColor c = QColorDialog::getColor( color(), this );
39 emit colorChanged( c );
43 int HYDROGUI_ColorWidget::intColor() const
45 return HYDROGUI_Tools::color2int( color() );
48 void HYDROGUI_ColorWidget::setColor( const int col )
50 setColor( HYDROGUI_Tools::int2color( col ) );
53 /*void HYDROGUI_ColorWidget::setRandColor()
55 setColor( HYDROGUI_Tools::randColor() );