9 #include <QApplication> 24 } platform_styles[] = {
25 {
"macosx",
true,
true,
false},
26 {
"windows",
true,
true,
false},
28 {
"other",
true,
true,
false}
30 static const unsigned platform_styles_count =
sizeof(platform_styles)/
sizeof(*platform_styles);
35 void MakeSingleColorImage(QImage& img,
const QColor& colorbase,
double opacity = 1)
38 if(opacity > 1 && opacity < 0) opacity = 1;
40 img = img.convertToFormat(QImage::Format_ARGB32);
41 for (
int x = img.width();
x--; )
43 for (
int y = img.height(); y--; )
45 const QRgb rgb = img.pixel(
x, y);
46 img.setPixel(
x, y, qRgba(colorbase.red(), colorbase.green(), colorbase.blue(), opacity * qAlpha(rgb)));
51 QPixmap MakeSingleColorPixmap(QImage& img,
const QColor& colorbase,
double opacity = 1)
53 MakeSingleColorImage(img, colorbase, opacity);
54 return QPixmap::fromImage(img);
57 QIcon ColorizeIcon(
const QIcon& ico,
const QColor& colorbase,
double opacity = 1)
61 Q_FOREACH(sz, ico.availableSizes())
63 QImage img(ico.pixmap(sz).toImage());
64 MakeSingleColorImage(img, colorbase, opacity);
65 new_ico.addPixmap(QPixmap::fromImage(img));
70 QImage ColorizeImage(
const QString& filename,
const QColor& colorbase,
double opacity = 1)
73 MakeSingleColorImage(img, colorbase, opacity);
77 QIcon ColorizeIcon(
const QString& filename,
const QColor& colorbase,
double opacity = 1)
79 return QIcon(QPixmap::fromImage(ColorizeImage(filename, colorbase, opacity)));
100 menuColor = QColor(QApplication::palette().color(QPalette::WindowText));
106 return QImage(filename);
107 return ColorizeImage(filename,
SingleColor(), 0.8);
113 return QIcon(filename);
126 return ColorizeIcon(filename,
TextColor(), 0.6);
131 return ColorizeIcon(icon,
TextColor(), 0.6);
136 return ColorizeIcon(filename,
MenuColor(), 0.8);
141 return ColorizeIcon(icon,
MenuColor(), 0.8);
150 QImage img1(resourcename);
153 QPixmap pix1 = MakeSingleColorPixmap(img1, color, 1);
154 QPixmap pix2 = MakeSingleColorPixmap(img2, color, 0.8);
155 QPixmap pix3 = MakeSingleColorPixmap(img3, colorAlt, 0.8);
156 icon.addPixmap(pix1, QIcon::Normal, QIcon::On);
157 icon.addPixmap(pix2, QIcon::Normal, QIcon::Off);
158 icon.addPixmap(pix3, QIcon::Selected, QIcon::On);
163 QImage img1(resourcename);
165 QPixmap pix1 = MakeSingleColorPixmap(img1, color, 1);
166 QPixmap pix2 = MakeSingleColorPixmap(img2, color, 0.2);
167 icon.addPixmap(pix1, QIcon::Normal, QIcon::Off);
168 icon.addPixmap(pix2, QIcon::Disabled, QIcon::On);
169 icon.addPixmap(pix2, QIcon::Disabled, QIcon::Off);
182 QImage img1(resourcename);
185 double opacitySelected = 0.8;
186 int color = 0xffffff;
187 int colorSelected = 0xffffff;
193 QPixmap pix1 = MakeSingleColorPixmap(img1, color, opacity);
194 QPixmap pix2 = MakeSingleColorPixmap(img2, colorSelected, opacitySelected);
197 icon.addPixmap(pix1, QIcon::Normal, QIcon::On);
198 icon.addPixmap(pix1, QIcon::Normal, QIcon::Off);
199 icon.addPixmap(pix2, QIcon::Selected, QIcon::On);
200 icon.addPixmap(pix2, QIcon::Selected, QIcon::Off);
208 QImage img(resourcename);
210 int color = 0xffffff;
216 MakeSingleColorImage(img, color, opacity);
256 for (
unsigned x=0;
x<platform_styles_count; ++
x)
258 if (platformId == platform_styles[
x].platformId)
261 platform_styles[
x].platformId,
PlatformStyle::TableColorType type