Skip to content

Commit

Permalink
libs/qtplot/ColorMap - adding isColorNameValid() method
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-dixon committed Oct 11, 2024
1 parent 9bc541d commit f735649
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
13 changes: 13 additions & 0 deletions codebase/libs/qtplot/src/ColorMap/ColorMap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1688,3 +1688,16 @@ QImage *ColorMap::getColorScaleLegend() {

}

/////////////////////////////////////////////////////
// check that color name is valid

bool ColorMap::isColorNameValid(QString colorName)
{
#if QT_VERSION >= 0x060000
QColor color = QColor::fromString(colorName);
#else
QColor color;
color.setNamedColor(colorName);
#endif
return color.isValid();
}
4 changes: 4 additions & 0 deletions codebase/libs/qtplot/src/include/qtplot/ColorMap.hh
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,10 @@ class DLL_EXPORT ColorMap {

QImage *getColorScaleLegend();

// check for valid color

static bool isColorNameValid(QString colorName);

protected:

bool _debug;
Expand Down

0 comments on commit f735649

Please sign in to comment.