Draw alert boxes using colors from settings

This commit is contained in:
Dan Paulat 2022-12-25 21:55:27 -06:00
parent 3289f98638
commit 14f825d896
3 changed files with 34 additions and 15 deletions

View file

@ -1,6 +1,7 @@
#include <scwx/qt/util/color.hpp>
#include <format>
#include <QColor>
namespace scwx
{
@ -19,6 +20,15 @@ std::string ToArgbString(const boost::gil::rgba8_pixel_t& color)
"#{:02x}{:02x}{:02x}{:02x}", color[3], color[0], color[1], color[2]);
}
boost::gil::rgba8_pixel_t ToRgba8PixelT(const std::string& argbString)
{
QRgb color = QColor(QString::fromStdString(argbString)).rgba();
return boost::gil::rgba8_pixel_t {static_cast<uint8_t>(qRed(color)),
static_cast<uint8_t>(qGreen(color)),
static_cast<uint8_t>(qBlue(color)),
static_cast<uint8_t>(qAlpha(color))};
}
} // namespace color
} // namespace util
} // namespace qt

View file

@ -11,8 +11,24 @@ namespace util
namespace color
{
/**
* Converts a Boost.GIL 8-bit RGBA pixel to an ARGB string used by Qt libraries.
*
* @param color RGBA8 pixel
*
* @return ARGB string in the format #AARRGGBB
*/
std::string ToArgbString(const boost::gil::rgba8_pixel_t& color);
/**
* Converts an ARGB string used by Qt libraries to a Boost.GIL 8-bit RGBA pixel.
*
* @param argbString ARGB string in the format #AARRGGBB
*
* @return RGBA8 pixel
*/
boost::gil::rgba8_pixel_t ToRgba8PixelT(const std::string& argbString);
} // namespace color
} // namespace util
} // namespace qt