21 {
"windows",
true,
false,
false},
23 {
"other",
true,
true,
false}};
28void MakeSingleColorImage(QImage &img,
const QColor &colorbase) {
29 img = img.convertToFormat(QImage::Format_ARGB32);
30 for (
int x = img.width(); x--;) {
31 for (
int y = img.height(); y--;) {
32 const QRgb rgb = img.pixel(x, y);
34 qRgba(colorbase.red(), colorbase.green(),
35 colorbase.blue(), qAlpha(rgb)));
40QIcon ColorizeIcon(
const QIcon &ico,
const QColor &colorbase) {
42 for (
const QSize &sz : ico.availableSizes()) {
43 QImage img(ico.pixmap(sz).toImage());
44 MakeSingleColorImage(img, colorbase);
45 new_ico.addPixmap(QPixmap::fromImage(img));
50QImage ColorizeImage(
const QString &filename,
const QColor &colorbase) {
52 MakeSingleColorImage(img, colorbase);
56QIcon ColorizeIcon(
const QString &filename,
const QColor &colorbase) {
57 return QIcon(QPixmap::fromImage(ColorizeImage(filename, colorbase)));
62 bool _colorizeIcons,
bool _useExtraSpacing)
65 singleColor(0, 0, 0), textColor(0, 0, 0) {
68 const QColor colorHighlightBg(
69 QApplication::palette().color(QPalette::Highlight));
70 const QColor colorHighlightFg(
71 QApplication::palette().color(QPalette::HighlightedText));
72 const QColor colorText(
73 QApplication::palette().color(QPalette::WindowText));
74 const int colorTextLightness = colorText.lightness();
76 if (abs(colorHighlightBg.lightness() - colorTextLightness) <
77 abs(colorHighlightFg.lightness() - colorTextLightness)) {
78 colorbase = colorHighlightBg;
80 colorbase = colorHighlightFg;
85 textColor = QColor(QApplication::palette().color(QPalette::WindowText));
90 return QImage(filename);
97 return QIcon(filename);
115 if (
platformId == platform_style.platformId) {
117 platform_style.platformId, platform_style.imagesOnButtons,
118 platform_style.colorizeIcons, platform_style.useExtraSpacing);