Commit 222824e2 authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

QmlDesigner.rewriter: writing out the alpha channel of a color

QColor::name() ignores the alpha channel

Reviewed-by: Erik Verbruggen
parent 65a30b06
......@@ -28,6 +28,7 @@
**************************************************************************/
#include <QtCore/QVariant>
#include <QtGui/QColor>
#include "bindingproperty.h"
#include "nodeproperty.h"
......@@ -38,6 +39,16 @@
using namespace QmlDesigner;
using namespace QmlDesigner::Internal;
inline static QString properColorName(const QColor &color)
{
QString s;
if (color.alpha() == 255)
s.sprintf("#%02x%02x%02x", color.red(), color.green(), color.blue());
else
s.sprintf("#%02x%02x%02x%02x", color.alpha(), color.red(), color.green(), color.blue());
return s;
}
QmlTextGenerator::QmlTextGenerator(const QStringList &propertyOrder, int indentDepth):
m_propertyOrder(propertyOrder),
m_indentDepth(indentDepth)
......@@ -89,6 +100,9 @@ QString QmlTextGenerator::toQml(const AbstractProperty &property, int indentDept
else
return QLatin1String("false");
case QVariant::Color:
return QString(QLatin1String("\"%1\"")).arg(properColorName(value.value<QColor>()));
case QVariant::Double:
case QVariant::Int:
case QVariant::LongLong:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment