FIX issue #124 QGradient::Preset::NumPresets is undocumented and seems to be missing in some cases --> use QMetaEnum::fromType<QGradient::Preset>().keyCount() instead

This commit is contained in:
jkriege2 2024-03-15 10:15:29 +01:00
parent 378ae79517
commit 77f498f04d
2 changed files with 2 additions and 2 deletions

View File

@ -214,7 +214,7 @@ JKQTPExpected<QGradient, JKQTPCSSParser::GeneralError> JKQTPCSSParser::parseGrad
static QMap<QString,QGradient::Preset> s_GradientPresets = []() { static QMap<QString,QGradient::Preset> s_GradientPresets = []() {
QMap<QString,QGradient::Preset> m; QMap<QString,QGradient::Preset> m;
for (int i=1; i<QGradient::Preset::NumPresets; i++) { for (int i=1; i<QMetaEnum::fromType<QGradient::Preset>().keyCount(); i++) {
const QString id=QString(QMetaEnum::fromType<QGradient::Preset>().valueToKey(static_cast<QGradient::Preset>(i))).toLower().trimmed().simplified(); const QString id=QString(QMetaEnum::fromType<QGradient::Preset>().valueToKey(static_cast<QGradient::Preset>(i))).toLower().trimmed().simplified();
if (id.size()>0) m[id]=static_cast<QGradient::Preset>(i); if (id.size()>0) m[id]=static_cast<QGradient::Preset>(i);
} }

View File

@ -393,7 +393,7 @@ namespace {
static QMap<QString,QGradient::Preset> s_GradientPresets = []() { static QMap<QString,QGradient::Preset> s_GradientPresets = []() {
QMap<QString,QGradient::Preset> m; QMap<QString,QGradient::Preset> m;
for (int i=1; i<QGradient::Preset::NumPresets; i++) { for (int i=1; i<QMetaEnum::fromType<QGradient::Preset>().keyCount(); i++) {
const QString id=QString(QMetaEnum::fromType<QGradient::Preset>().valueToKey(static_cast<QGradient::Preset>(i))).toLower().trimmed().simplified(); const QString id=QString(QMetaEnum::fromType<QGradient::Preset>().valueToKey(static_cast<QGradient::Preset>(i))).toLower().trimmed().simplified();
if (id.size()>0) m[id]=static_cast<QGradient::Preset>(i); if (id.size()>0) m[id]=static_cast<QGradient::Preset>(i);
} }