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
| 162 | // hovered-date change, so without the cache each mouse move would re-parse + raster |
| 163 | // four SVGs. |
| 164 | QIcon 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 |