MCPcopy Create free account
hub / github.com/PlotJuggler/PlotJuggler / renderChevronIcon

Function renderChevronIcon

pj_widgets/src/DateRangePicker.cpp:164–186  ·  view source on GitHub ↗

Render one of the app's Material chevron SVGs (keyboard_arrow_left/right), recolored to `color`, into a px*DPR QIcon. The source path's own fill is irrelevant — we always load the "_light" variant and swap its #3D3D3D fill for `color` (theme ink for the resting state, the from/to hint colors when active). Cached by (direction, color, px): updateNavButtons() re-applies icons on every hovered-date c

Source from the content-addressed store, hash-verified

162// hovered-date change, so without the cache each mouse move would re-parse + raster
163// four SVGs.
164QIcon renderChevronIcon(bool left, const QColor& color, int px) {
165 static QHash<QString, QIcon> cache;
166 // Key on HexRgb to match the recolor below (color.name() drops alpha), so the
167 // key can never disagree with the rasterized output.
168 const QString key = QStringLiteral("%1:%2:%3").arg(left ? 1 : 0).arg(color.name()).arg(px);
169 const auto cached = cache.constFind(key);
170 if (cached != cache.constEnd()) {
171 return cached.value();
172 }
173
174 const QString path = left ? QStringLiteral(":/resources/svg/keyboard_arrow_left_light.svg")
175 : QStringLiteral(":/resources/svg/keyboard_arrow_right_light.svg");
176 QFile file(path);
177 if (!file.open(QIODevice::ReadOnly)) {
178 return QIcon();
179 }
180 QByteArray svg_data = file.readAll();
181 file.close();
182 svg_data.replace("#3D3D3D", color.name().toUtf8());
183 QIcon icon = rasterizeSvgIcon(svg_data, px);
184 cache.insert(key, icon);
185 return icon;
186}
187
188} // namespace
189

Callers 2

DualCalendarWidgetMethod · 0.85
updateNavButtonsMethod · 0.85

Calls 6

rasterizeSvgIconFunction · 0.85
openMethod · 0.80
closeMethod · 0.80
nameMethod · 0.45
valueMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected