9
9
#include < qsize.h>
10
10
#include < qstring.h>
11
11
12
+ constexpr std::array<QAnyStringView, 2 > ICON_FILETYPES = {" png" , " xpm" }; // currently cannot open svg file
13
+
12
14
QPixmap
13
15
IconImageProvider::requestPixmap (const QString& id, QSize* size, const QSize& requestedSize) {
14
16
QString iconName;
@@ -19,8 +21,7 @@ IconImageProvider::requestPixmap(const QString& id, QSize* size, const QSize& re
19
21
if (splitIdx != -1 ) {
20
22
iconName = id.sliced (0 , splitIdx);
21
23
path = id.sliced (splitIdx + 6 );
22
- qWarning () << " Searching custom icon paths is not yet supported. Icon path will be ignored for"
23
- << id;
24
+ path = QString (" /%1/%2" ).arg (path, iconName.sliced (iconName.lastIndexOf (' /' ) + 1 ));
24
25
} else {
25
26
splitIdx = id.indexOf (" ?fallback=" );
26
27
if (splitIdx != -1 ) {
@@ -32,7 +33,13 @@ IconImageProvider::requestPixmap(const QString& id, QSize* size, const QSize& re
32
33
}
33
34
34
35
auto icon = QIcon::fromTheme (iconName);
35
- if (icon.isNull ()) icon = QIcon::fromTheme (fallbackName);
36
+ if (icon.isNull () && !fallbackName.isEmpty ()) icon = QIcon::fromTheme (fallbackName);
37
+ if (icon.isNull () && !path.isEmpty ()) {
38
+ for (const auto & iconFiletype : ICON_FILETYPES){
39
+ icon = QPixmap (QString (" %1.%2" ).arg (path, iconFiletype));
40
+ if (!icon.isNull ()) break ;
41
+ }
42
+ }
36
43
37
44
auto targetSize = requestedSize.isValid () ? requestedSize : QSize (100 , 100 );
38
45
if (targetSize.width () == 0 || targetSize.height () == 0 ) targetSize = QSize (2 , 2 );
0 commit comments