summaryrefslogtreecommitdiff
path: root/src/settings/ColorBox.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/settings/ColorBox.cpp')
-rw-r--r--src/settings/ColorBox.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/settings/ColorBox.cpp b/src/settings/ColorBox.cpp
new file mode 100644
index 0000000..4ed73ab
--- /dev/null
+++ b/src/settings/ColorBox.cpp
@@ -0,0 +1,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 );
+ }