From a263c89ed5a2810856716ce6a5cbbbe078fb88a0 Mon Sep 17 00:00:00 2001
From: Christiaan Janssen <christiaan.janssen@nokia.com>
Date: Mon, 22 Feb 2010 10:03:22 +0100
Subject: [PATCH] QmlDesigner.PropertyEditor: Fixed color widget for black

---
 .../components/propertyeditor/colorwidget.cpp        | 12 ++++++++++--
 .../components/propertyeditor/colorwidget.h          |  5 ++++-
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/src/plugins/qmldesigner/components/propertyeditor/colorwidget.cpp b/src/plugins/qmldesigner/components/propertyeditor/colorwidget.cpp
index 89f3e208460..65fbb415aa1 100644
--- a/src/plugins/qmldesigner/components/propertyeditor/colorwidget.cpp
+++ b/src/plugins/qmldesigner/components/propertyeditor/colorwidget.cpp
@@ -134,7 +134,7 @@ namespace QmlDesigner {
         if (x>120) x=120;
         if (y<0) y=0;
         if (y>120) y=120;
-        newColor.setHsv(m_saturatedColor.hsvHue(), (x*255) / 120, 255 - (y*255) / 120);
+        newColor.setHsv(m_lastHue, (x*255) / 120, 255 - (y*255) / 120);
         setColor(newColor);
     }
 
@@ -149,6 +149,9 @@ namespace QmlDesigner {
 
         if ((m_saturatedColor.hsvHue() != m_lastHue) || (m_cache.isNull())) {
             m_lastHue = m_saturatedColor.hsvHue();
+            if (m_lastHue<0) m_lastHue=0;
+            if (m_lastHue>359) m_lastHue=359;
+
             m_cache = QPixmap(120, 120);
 
             int height = 120;
@@ -160,7 +163,7 @@ namespace QmlDesigner {
                 for (int x = 0; x < width; x++)
                 {
                 QColor c;
-                c.setHsv(m_saturatedColor.hsvHue(), (x*255) / 120, 255 - (y*255) / 120);
+                c.setHsv(m_lastHue, (x*255) / 120, 255 - (y*255) / 120);
                 chacheP.setPen(c);
                 chacheP.drawPoint(x ,y);
             }
@@ -171,6 +174,11 @@ namespace QmlDesigner {
         int x = m_color.hsvSaturationF() * 120 + 5;
         int y = 120 - m_color.valueF() * 120 + 5;
 
+        if (x<5) x=5;
+        if (x>125) x=125;
+        if (y<5) y=5;
+        if (y>125) y=125;
+
         p.setPen(Qt::white);
         p.drawEllipse(x - 2, y - 2, 4, 4);
     }
diff --git a/src/plugins/qmldesigner/components/propertyeditor/colorwidget.h b/src/plugins/qmldesigner/components/propertyeditor/colorwidget.h
index e1f72820750..272e9ace659 100644
--- a/src/plugins/qmldesigner/components/propertyeditor/colorwidget.h
+++ b/src/plugins/qmldesigner/components/propertyeditor/colorwidget.h
@@ -112,7 +112,10 @@ void setHue(int newHue)
 
 int hue() const
 {
-    return m_color.hue();
+    int retval = m_color.hsvHue();
+    if (retval<0) retval=0;
+    if (retval>359) retval=359;
+    return retval;
 }
 
 void setColor(const QString &colorStr)
-- 
GitLab