- QFileIconProvider doesn't work under Plasma 5 with any Qt theme. - The effect is that icons in views using QFileSystemModel aren't shown: http://martchus.netai.net/images/screenshots/kde-no-icons.png - Reproducible: Always Steps to Reproduce: 1. Ensure Plasma/KDE integration is used, eg. XDG_CURRENT_DESKTOP=kde 2. window->setWindowIcon(QFileIconProvider().icon(QFileInfo(QStringLiteral("/run/media")))); 3. The bug also effects QFileSystemModel: anyQTreeViewInstance->setModel(anyQFileSystemModel); Actual Results: - Icon is not shown. - Icons aren't shown: http://martchus.netai.net/images/screenshots/kde-no-icons.png Expected Results: - Icon is shown. - Icons are shown: http://martchus.netai.net/images/screenshots/gnome-with-icons.png - I've noticed this bug for quite a while. Hence I can't remember when it occurred the first time. - I'm actually wondering why this hasn't been reported yet as it affects the commonly used QFileSystemModel. - I'm not 100 % sure whether it is a Qt or KDE bug. However I suspect it is likely a KDE issue because the "Steps to reproduce" give "Expected Results" when setting XDG_CURRENT_DESKTOP=GNOME. (This is how I created the screenshot under "Expected Results". As you can see it even works with Breeze Qt theme and Breeze icon theme.) - For testing I use only pure Qt. I'm not linking against any KDE libraries. - I'm using the lastest Qt and KDE libs provided by the official (stable) Arch Linux repositories (NO testing/kde-unstable).
I confirm this also happens in Debian stretch using plasma 5.4.3 and Qt 5.5.1. I'm using pure Qt, as stated above. I'm using QFileSystemModel in the following way (which I understand is similar to what is reported originally): QFileSystemModel *m_fileModel = new QFileSystemModel; m_fileModel->setRootPath(QDir::homePath()); QListView *m_listView = new QListView; m_listView->setModel(m_fileModel); m_listView->setRootIndex(m_fileModel->index(QDir::homePath()));
Thanks for confirming this. The code you provided matches indeed what I reported. This issue is there for quite a time now and still unresolved. I already tried to investigate the issue myself and therefore built all required KDE libraries from Git but I don't know how I can tell my Qt 5 application to use the customized built of the plugin. Another problem is, that there is almost no documentation about platform integration plugins. However, I now suspect the problem might be caused by KIconEngine which is part of the kiconthemes module (and not the frameworksintegration module).
Hi, I can also confirm same behavior at my Debian Stretch machine running Qt 5.5.1 and KDE Frameworks 5.16.0.
Hi, I can also confirm the bug on OpenSuse Tumbleweed. I think the problem is linked with QFileIconProvider wich can't find the icon name; When you do QFileInfo fi ( ... ); QFileIconProvider fip; QIcon icon = fip.icon ( fi ); qDebug() << "icon.isNull()=" << icon.isNull() << "icon.name()=" << icon.name() << "icon.themeName()="<< icon.themeName() << "icon.themeSearchPaths()=" << icon.themeSearchPaths(); setIcon ( 0, icon ); The result is : icon.isNull()= false icon.name()= "" icon.themeName()= "breeze" icon.themeSearchPaths()= ("/usr/share/icons", ":/icons") icon is not null theme name is OK theme search path are OK but there is no icon name and when you use QIcon icon = fip.icon ( QFileIconProvider::File ); it's OK By
Interesting. To summarize this: - The icon name is missing but the icon is not null. - Getting the icon via enum value seems to work. However, I think the problem is not solely a QFileIconProvider issue because it only occurs when frameworksintegration is enabled and hence KIconEngine is used.
I have found a momentary workaround, you can try first QMimeDatabase mimeDatabase; QFileInfo fileInfo ( fileName ); QMimeType mimeType = mimeDatabase.mimeTypeForFile( fileInfo ); and then it->setIcon ( 0, QIcon::fromTheme( mimeType.iconName() ) ); show the good icon.
Icons seem to work again after recent updates (having plasma-integration 5.9.0 and kiconthemes 5.30.0 installed now). Thanks for fixing it.