forked from qt-creator/qt-creator
QmlJS: Use QmlJS::toQColor to convert a string to a QColor.
The QColor constructor prints a warning if the string it gets passed isn't a known color name. Also, it doesn't know about the alpha value in strings like "#ff00ff00". Reviewed-by: Thomas Hartmann
This commit is contained in:
@@ -31,6 +31,7 @@
|
|||||||
#include "ui_contextpanewidgetrectangle.h"
|
#include "ui_contextpanewidgetrectangle.h"
|
||||||
#include "contextpanewidget.h"
|
#include "contextpanewidget.h"
|
||||||
#include <qmljs/qmljspropertyreader.h>
|
#include <qmljs/qmljspropertyreader.h>
|
||||||
|
#include <qmljs/qmljscheck.h>
|
||||||
#include <customcolordialog.h>
|
#include <customcolordialog.h>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
@@ -79,7 +80,7 @@ void ContextPaneWidgetRectangle::setProperties(QmlJS::PropertyReader *propertyRe
|
|||||||
|
|
||||||
if (propertyReader->hasProperty(QLatin1String("color"))) {
|
if (propertyReader->hasProperty(QLatin1String("color"))) {
|
||||||
QString str = propertyReader->readProperty("color").toString();
|
QString str = propertyReader->readProperty("color").toString();
|
||||||
if (QColor(str).alpha() == 0)
|
if (QmlJS::toQColor(str).alpha() == 0)
|
||||||
m_none = true;
|
m_none = true;
|
||||||
ui->colorColorButton->setColor(str);
|
ui->colorColorButton->setColor(str);
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
#include "qmljspropertyreader.h"
|
#include "qmljspropertyreader.h"
|
||||||
#include "qmljsdocument.h"
|
#include "qmljsdocument.h"
|
||||||
#include <qmljs/parser/qmljsast_p.h>
|
#include <qmljs/parser/qmljsast_p.h>
|
||||||
|
#include <qmljs/qmljscheck.h>
|
||||||
|
|
||||||
namespace QmlJS {
|
namespace QmlJS {
|
||||||
|
|
||||||
@@ -265,7 +266,7 @@ QLinearGradient PropertyReader::parseGradient(const QString &propertyName, bool
|
|||||||
if (UiObjectDefinition *objectDefinition = cast<UiObjectDefinition *>(member)) {
|
if (UiObjectDefinition *objectDefinition = cast<UiObjectDefinition *>(member)) {
|
||||||
PropertyReader localParser(m_doc, objectDefinition->initializer);
|
PropertyReader localParser(m_doc, objectDefinition->initializer);
|
||||||
if (localParser.hasProperty("color") && localParser.hasProperty("position")) {
|
if (localParser.hasProperty("color") && localParser.hasProperty("position")) {
|
||||||
QColor color = localParser.readProperty("color").value<QColor>();
|
QColor color = QmlJS::toQColor(localParser.readProperty("color").toString());
|
||||||
qreal position = localParser.readProperty("position").toReal();
|
qreal position = localParser.readProperty("position").toReal();
|
||||||
if (localParser.isBindingOrEnum("color") || localParser.isBindingOrEnum("position"))
|
if (localParser.isBindingOrEnum("color") || localParser.isBindingOrEnum("position"))
|
||||||
*isBound = true;
|
*isBound = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user