Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
**************************************************************************/ **************************************************************************/
#include <QtCore/QVariant> #include <QtCore/QVariant>
#include <QtGui/QColor>
#include "bindingproperty.h" #include "bindingproperty.h"
#include "nodeproperty.h" #include "nodeproperty.h"
...@@ -38,6 +39,16 @@ ...@@ -38,6 +39,16 @@
using namespace QmlDesigner; using namespace QmlDesigner;
using namespace QmlDesigner::Internal; 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): QmlTextGenerator::QmlTextGenerator(const QStringList &propertyOrder, int indentDepth):
m_propertyOrder(propertyOrder), m_propertyOrder(propertyOrder),
m_indentDepth(indentDepth) m_indentDepth(indentDepth)
...@@ -89,6 +100,9 @@ QString QmlTextGenerator::toQml(const AbstractProperty &property, int indentDept ...@@ -89,6 +100,9 @@ QString QmlTextGenerator::toQml(const AbstractProperty &property, int indentDept
else else
return QLatin1String("false"); return QLatin1String("false");
case QVariant::Color:
return QString(QLatin1String("\"%1\"")).arg(properColorName(value.value<QColor>()));
case QVariant::Double: case QVariant::Double:
case QVariant::Int: case QVariant::Int:
case QVariant::LongLong: case QVariant::LongLong:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment