blob: 4ed73abce1b0d96ae55be9cadcc7bcfd5c7c0b1e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#include "ColorBox.h"
ColorBox::ColorBox( QColor aColor )
{
setAutoFillBackground(true);
setFrameStyle( QFrame::Box );
setLineWidth(2);
setMinimumHeight( MinHeight );
setMinimumWidth( MinWidth );
setColor( aColor );
}
void ColorBox::setColor( QColor aColor )
{
m_color = aColor;
if( isEnabled() )
setPalette( m_color );
else
setPalette( Qt::lightGray );
}
void ColorBox::mousePressEvent(QMouseEvent* /*event*/)
{
QColor c = QColorDialog::getColor( color(), this );
if( c.isValid() )
{
setColor( c );
emit colorChanged( c );
}
}
void ColorBox::changeEvent ( QEvent* event )
{
if( event->type() == QEvent::EnabledChange )
setColor( m_color );
}
|