Skip to content

Commit

Permalink
FIX issue #124 QGradient::Preset::NumPresets is undocumented and seem…
Browse files Browse the repository at this point in the history
…s to be missing in some cases --> use QMetaEnum::fromType<QGradient::Preset>().keyCount() instead
  • Loading branch information
jkriege2 committed Mar 15, 2024
1 parent 378ae79 commit 77f498f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/jkqtcommon/jkqtpcsstools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ JKQTPExpected<QGradient, JKQTPCSSParser::GeneralError> JKQTPCSSParser::parseGrad

static QMap<QString,QGradient::Preset> s_GradientPresets = []() {
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();
if (id.size()>0) m[id]=static_cast<QGradient::Preset>(i);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/jkqtcommon/jkqtpstringtools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ namespace {

static QMap<QString,QGradient::Preset> s_GradientPresets = []() {
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();
if (id.size()>0) m[id]=static_cast<QGradient::Preset>(i);
}
Expand Down

0 comments on commit 77f498f

Please sign in to comment.