forked from qt-creator/qt-creator
QmlDesigner.rewriter: writing out the alpha channel of a color
QColor::name() ignores the alpha channel Reviewed-by: Erik Verbruggen
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user