summaryrefslogtreecommitdiff
path: root/src/settings/ColorBox.cpp
diff options
context:
space:
mode:
authorJedidiah Barber <contact@jedbarber.id.au>2021-07-14 11:49:10 +1200
committerJedidiah Barber <contact@jedbarber.id.au>2021-07-14 11:49:10 +1200
commitd24f813f3f2a05c112e803e4256b53535895fc98 (patch)
tree601e6ae9a1cd44bcfdcf91739a5ca36aedd827c9 /src/settings/ColorBox.cpp
Initial mirror commitHEADmaster
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 );
+ }