17 #include <QApplication> 21 #include <QRegularExpression> 25 QString
ParseColor(
const QString &subject,
const QString &pattern,
const QString &fallback)
27 QRegularExpression re(pattern, QRegularExpression::CaseInsensitiveOption);
28 auto match = re.match(subject);
30 return match.hasMatch()
38 auto styleSheet = qApp->styleSheet();
40 if (styleSheet.isEmpty())
41 return QPixmap::fromImage(QImage::fromData(originalSVG));
44 QStringLiteral(
"iconColor\\s*[=:]\\s*(#[0-9a-f]{6})"),
45 QStringLiteral(
"#000000"));
48 QStringLiteral(
"iconAccentColor\\s*[=:]\\s*(#[0-9a-f]{6})"),
49 QStringLiteral(
"#ffffff"));
51 auto themedSVG = QString(originalSVG).replace(QStringLiteral(
"#00ff00"), iconColor, Qt::CaseInsensitive);
52 themedSVG = themedSVG.replace(QStringLiteral(
"#ff00ff"), iconAccentColor, Qt::CaseInsensitive);
54 return QPixmap::fromImage(QImage::fromData(themedSVG.toLatin1()));
59 QFile resourceFile(resourcePath);
61 if (resourceFile.open(QIODevice::ReadOnly))
63 auto originalSVG = resourceFile.readAll();
67 MITK_WARN <<
"Could not read " << resourcePath.toStdString();
static QString ParseColor(const QString &subject, const QString &pattern, const QString &fallback)
static QIcon ThemeIcon(const QByteArray &originalSVG)