From 7b5ac717143c16b3fbf9a9b8385b544f7f4e0599 Mon Sep 17 00:00:00 2001 From: scribblemaniac Date: Sat, 21 May 2016 11:35:18 -0600 Subject: [PATCH] Stopped color wheel changes from resetting alpha Fixes #426 --- app/colorwheel.cpp | 29 +++++++++++++++++++++++++++-- app/colorwheel.h | 1 + 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/app/colorwheel.cpp b/app/colorwheel.cpp index cc9aead81..5c6f2bf4c 100644 --- a/app/colorwheel.cpp +++ b/app/colorwheel.cpp @@ -40,6 +40,11 @@ void ColorWheel::changeColor(const QColor &color) { svChanged(color); } + + if(color.alpha() != m_currentColor.alpha()) + { + alphaChanged(color.alpha()); + } //emit colorChanged(color); update(); } @@ -61,6 +66,11 @@ void ColorWheel::setColor(const QColor &color) svChanged(color); } + if ( color.alpha() != m_currentColor.alpha() ) + { + alphaChanged(color.alpha()); + } + update(); emit colorSelected(color); } @@ -360,8 +370,9 @@ void ColorWheel::hueChanged(const int &hue) } int s = m_currentColor.saturation(); int v = m_currentColor.value(); + int a = m_currentColor.alpha(); - m_currentColor.setHsv(hue, s, v); + m_currentColor.setHsv(hue, s, v, a); if(!isVisible()) { @@ -377,9 +388,11 @@ void ColorWheel::hueChanged(const int &hue) void ColorWheel::svChanged(const QColor &newcolor) { int hue = m_currentColor.hue(); + int alpha = m_currentColor.alpha(); m_currentColor.setHsv(hue, newcolor.saturation(), - newcolor.value()); + newcolor.value(), + alpha); if( !isVisible() ) { return; @@ -388,3 +401,15 @@ void ColorWheel::svChanged(const QColor &newcolor) repaint(); emit colorChanged(m_currentColor); } + +void ColorWheel::alphaChanged(const int &alpha) +{ + m_currentColor.setAlpha(alpha); + + if(!isVisible()) + { + return; + } + + emit colorChanged(m_currentColor); +} diff --git a/app/colorwheel.h b/app/colorwheel.h index 224d5fe67..76f08d176 100644 --- a/app/colorwheel.h +++ b/app/colorwheel.h @@ -33,6 +33,7 @@ public slots: void changeColor(const QColor &color); void hueChanged(const int &hue); void svChanged(const QColor &newcolor); + void alphaChanged(const int &alpha); QColor pickColor(const QPoint &point);