| 27 | }; |
| 28 | |
| 29 | QColor getColorFromHTMLText(const QString& text, const QString& colortype) { |
| 30 | const QString htmlColorPattern(QStringLiteral("(#[0-9A-Fa-f]{6})|(transparent)")); |
| 31 | QRegularExpression fontColorPattern(colortype + QStringLiteral(":") + htmlColorPattern); |
| 32 | QRegularExpressionMatch matchColor = fontColorPattern.match(text); |
| 33 | // QVERIFY(matchColor.hasMatch()); |
| 34 | // QCOMPARE(matchColor.capturedTexts().count(), 1); |
| 35 | const auto& splitted = matchColor.capturedTexts().at(0).split(colortype + QStringLiteral(":")); |
| 36 | QColor c; |
| 37 | if (splitted.length() > 1) { |
| 38 | QString color = splitted.at(1); |
| 39 | int r = color.mid(1, 2).toInt(nullptr, 16); |
| 40 | int g = color.mid(3, 2).toInt(nullptr, 16); |
| 41 | int b = color.mid(5, 2).toInt(nullptr, 16); |
| 42 | |
| 43 | c = QColor(r, g, b); |
| 44 | } else { |
| 45 | c = QColor(Qt::transparent); |
| 46 | } |
| 47 | return c; |
| 48 | } |
| 49 | |
| 50 | #define STORETEXTPROPERTIES(label, propertyVariable) \ |
| 51 | TextProperties propertyVariable; \ |
no test coverage detected