forked from quickshell/quickshell
service/tray: log icon render failures due to IconThemePath
This commit is contained in:
parent
1f49c55711
commit
c71fdd62d0
4 changed files with 33 additions and 7 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -10,4 +10,5 @@ public:
|
|||
QPixmap requestPixmap(const QString& id, QSize* size, const QSize& requestedSize) override;
|
||||
|
||||
static QPixmap missingPixmap(const QSize& size);
|
||||
static QString requestString(const QString& icon, const QString& path);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue