service/tray: log icon render failures due to IconThemePath

This commit is contained in:
outfoxxed 2024-04-29 18:16:04 -07:00
parent 1f49c55711
commit c71fdd62d0
Signed by untrusted user: outfoxxed
GPG key ID: 4C88A185FB89301E
4 changed files with 33 additions and 7 deletions

View file

@ -10,7 +10,19 @@
QPixmap
IconImageProvider::requestPixmap(const QString& id, QSize* size, const QSize& requestedSize) {
auto icon = QIcon::fromTheme(id);
QString iconName;
QString path;
auto splitIdx = id.indexOf("?path=");
if (splitIdx != -1) {
iconName = id.sliced(0, splitIdx);
path = id.sliced(splitIdx + 6);
qWarning() << "Searching custom icon paths is not yet supported. Icon path will be ignored for"
<< id;
} else {
iconName = id;
}
auto icon = QIcon::fromTheme(iconName);
auto targetSize = requestedSize.isValid() ? requestedSize : QSize(100, 100);
if (targetSize.width() == 0 || targetSize.height() == 0) targetSize = QSize(2, 2);
@ -42,3 +54,13 @@ QPixmap IconImageProvider::missingPixmap(const QSize& size) {
painter.fillRect(0, halfHeight, halfWidth, halfHeight, purple);
return pixmap;
}
QString IconImageProvider::requestString(const QString& icon, const QString& path) {
auto req = "image://icon/" + icon;
if (!path.isEmpty()) {
req += "?path=" + path;
}
return req;
}