MCPcopy Create free account
hub / github.com/IENT/YUView / convertIcon

Method convertIcon

YUViewLib/src/common/FunctionsGui.cpp:60–109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58}
59
60QIcon functionsGui::convertIcon(QString iconPath)
61{
62 QSettings settings;
63 QString themeName = settings.value("Theme", "Default").toString();
64
65 // Get the active and inactive colors
66 QStringList colors = functions::getThemeColors(themeName);
67 QRgb activeColor, inActiveColor;
68 if (colors.size() == 4)
69 {
70 QColor active(colors[1]);
71 QColor inactive(colors[2]);
72 activeColor = active.rgb();
73 inActiveColor = inactive.rgb();
74 }
75 else
76 {
77 activeColor = qRgb(0, 0, 0);
78 inActiveColor = qRgb(128, 128, 128);
79 }
80
81 // Color the icon in the active/inactive colors
82 QImage input(iconPath);
83
84 QImage active(input.size(), input.format());
85 QImage inActive(input.size(), input.format());
86 for (int y = 0; y < input.height(); y++)
87 {
88 for (int x = 0; x < input.width(); x++)
89 {
90 QRgb in = input.pixel(x, y);
91 if (qAlpha(in) != 0)
92 {
93 active.setPixel(x, y, activeColor);
94 inActive.setPixel(x, y, inActiveColor);
95 }
96 else
97 {
98 active.setPixel(x, y, in);
99 inActive.setPixel(x, y, in);
100 }
101 }
102 }
103
104 QIcon outIcon;
105 outIcon.addPixmap(QPixmap::fromImage(active), QIcon::Normal);
106 outIcon.addPixmap(QPixmap::fromImage(inActive), QIcon::Disabled);
107
108 return outIcon;
109}
110
111QPixmap functionsGui::convertPixmap(QString pixmapPath)
112{

Callers

nothing calls this directly

Calls 3

getThemeColorsFunction · 0.85
toStringMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected