forked from qt-creator/qt-creator
PropertyEditor: Replace old code for getting color from string
Change-Id: I9eb774ee4fc3f574ed543124407099d0ac2f5134 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
This commit is contained in:
@@ -32,47 +32,6 @@
|
|||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
|
||||||
static uchar fromHex(const uchar c, const uchar c2)
|
|
||||||
{
|
|
||||||
uchar rv = 0;
|
|
||||||
if (c >= '0' && c <= '9')
|
|
||||||
rv += (c - '0') * 16;
|
|
||||||
else if (c >= 'A' && c <= 'F')
|
|
||||||
rv += (c - 'A' + 10) * 16;
|
|
||||||
else if (c >= 'a' && c <= 'f')
|
|
||||||
rv += (c - 'a' + 10) * 16;
|
|
||||||
|
|
||||||
if (c2 >= '0' && c2 <= '9')
|
|
||||||
rv += (c2 - '0');
|
|
||||||
else if (c2 >= 'A' && c2 <= 'F')
|
|
||||||
rv += (c2 - 'A' + 10);
|
|
||||||
else if (c2 >= 'a' && c2 <= 'f')
|
|
||||||
rv += (c2 - 'a' + 10);
|
|
||||||
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
static uchar fromHex(const QString &s, int idx)
|
|
||||||
{
|
|
||||||
uchar c = s.at(idx).toLatin1();
|
|
||||||
uchar c2 = s.at(idx + 1).toLatin1();
|
|
||||||
return fromHex(c, c2);
|
|
||||||
}
|
|
||||||
|
|
||||||
QColor convertColorFromString(const QString &s)
|
|
||||||
{
|
|
||||||
if (s.length() == 9 && s.startsWith(QLatin1Char('#'))) {
|
|
||||||
uchar a = fromHex(s, 1);
|
|
||||||
uchar r = fromHex(s, 3);
|
|
||||||
uchar g = fromHex(s, 5);
|
|
||||||
uchar b = fromHex(s, 7);
|
|
||||||
return {r, g, b, a};
|
|
||||||
} else {
|
|
||||||
QColor rv(s);
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
static Q_LOGGING_CATEGORY(urlSpecifics, "qtc.propertyeditor.specifics", QtWarningMsg)
|
static Q_LOGGING_CATEGORY(urlSpecifics, "qtc.propertyeditor.specifics", QtWarningMsg)
|
||||||
@@ -111,7 +70,7 @@ QString PropertyEditorContextObject::convertColorToString(const QVariant &color)
|
|||||||
|
|
||||||
QColor PropertyEditorContextObject::colorFromString(const QString &colorString)
|
QColor PropertyEditorContextObject::colorFromString(const QString &colorString)
|
||||||
{
|
{
|
||||||
return convertColorFromString(colorString);
|
return QColor::fromString(colorString);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString PropertyEditorContextObject::translateFunction()
|
QString PropertyEditorContextObject::translateFunction()
|
||||||
|
Reference in New Issue
Block a user