From b8bd4d4d3d890ac5915c0a5dd643a2c6e8c3601e Mon Sep 17 00:00:00 2001 From: Ali Kianian Date: Fri, 21 Mar 2025 09:38:55 +0200 Subject: [PATCH] PropertyEditor: Replace old code for getting color from string Change-Id: I9eb774ee4fc3f574ed543124407099d0ac2f5134 Reviewed-by: Miikka Heikkinen --- .../propertyeditorcontextobject.cpp | 43 +------------------ 1 file changed, 1 insertion(+), 42 deletions(-) diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.cpp index 1ff7f85c1a3..46436c135f5 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.cpp @@ -32,47 +32,6 @@ #include -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 { 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) { - return convertColorFromString(colorString); + return QColor::fromString(colorString); } QString PropertyEditorContextObject::translateFunction()