10 #ifdef QT_NO_SVGRENDERER
11 #error "QT_NO_SVGRENDERER defined"
17 #include <QTextStream>
26 inline const QPixmap&
LoadSvg(QString filename, QString style_name =
"light")
28 static std::map<QString, QPixmap> light_images;
29 static std::map<QString, QPixmap> dark_images;
30 bool light_theme = style_name.contains(
"light");
32 auto* stored_images = light_theme ? &light_images : &dark_images;
34 auto it = stored_images->find(filename);
35 if (it == stored_images->end())
38 file.open(QFile::ReadOnly | QFile::Text);
39 auto svg_data = file.readAll();
44 svg_data.replace(
"#000000",
"#111111");
45 svg_data.replace(
"#ffffff",
"#dddddd");
49 svg_data.replace(
"#000000",
"#dddddd");
50 svg_data.replace(
"#ffffff",
"#111111");
52 QByteArray content(svg_data);
54 QSvgRenderer rr(content);
55 QImage image(64, 64, QImage::Format_ARGB32);
56 QPainter painter(&image);
57 image.fill(Qt::transparent);
60 it = stored_images->insert({ filename, QPixmap::fromImage(image) }).
first;
65 #endif // PJ_SVG_UTIL_H