30 /* |
30 /* |
31 * makeColorIcon |
31 * makeColorIcon |
32 * |
32 * |
33 * Creates an icon to represent an LDraw color. |
33 * Creates an icon to represent an LDraw color. |
34 */ |
34 */ |
35 QIcon GuiUtilities::makeColorIcon (LDColor ldColor, int size) |
35 QIcon makeColorIcon(LDColor color, int size) |
36 { |
36 { |
37 QImage image {size, size, QImage::Format_ARGB32}; |
37 QImage image {size, size, QImage::Format_ARGB32}; |
38 QPainter painter {&image}; |
38 QPainter painter {&image}; |
39 QColor color; |
39 QColor truecolor; |
40 |
40 |
41 if (ldColor == MainColor) |
41 if (color == MainColor) |
42 { |
42 { |
43 // Use the user preferences for the main color. |
43 // Use the user preferences for the main color. |
44 color = m_config->mainColor(); |
44 truecolor = config->mainColor(); |
45 color.setAlphaF(m_config->mainColorAlpha()); |
45 truecolor.setAlphaF(config->mainColorAlpha()); |
46 } |
46 } |
47 else |
47 else |
48 color = ldColor.faceColor(); |
48 { |
|
49 truecolor = color.faceColor(); |
|
50 } |
49 |
51 |
50 // Paint the icon border |
52 // Paint the icon border |
51 painter.fillRect(QRect {0, 0, size, size}, ldColor.edgeColor()); |
53 painter.fillRect(QRect {0, 0, size, size}, color.edgeColor()); |
52 |
54 |
53 // Paint the checkerboard background, visible with translucent icons |
55 // Paint the checkerboard background, visible with translucent icons |
54 painter.drawPixmap(QRect {1, 1, size - 2, size - 2}, MainWindow::getIcon("checkerboard"), QRect {0, 0, 8, 8}); |
56 painter.drawPixmap( |
|
57 QRect {1, 1, size - 2, size - 2}, |
|
58 MainWindow::getIcon("checkerboard"), |
|
59 QRect {0, 0, 8, 8} |
|
60 ); |
55 |
61 |
56 // Paint the color above the checkerboard |
62 // Paint the color above the checkerboard |
57 painter.fillRect (QRect {1, 1, size - 2, size - 2}, color); |
63 painter.fillRect(QRect {1, 1, size - 2, size - 2}, truecolor); |
58 return QIcon {QPixmap::fromImage(image)}; |
64 return {QPixmap::fromImage(image)}; |
59 } |
65 } |
60 |
66 |
61 /* |
67 /* |
62 * fillUsedColorsToComboBox |
68 * fillUsedColorsToComboBox |
63 * |
69 * |