Bug 358926 - QFileIconProvider doesn't provide under Plasma 5
Summary: QFileIconProvider doesn't provide under Plasma 5
Status: RESOLVED FIXED
Alias: None
Product: frameworks-frameworkintegration
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: kdelibs bugs
URL: http://martchus.netai.net/images/scre...
Keywords: regression, reproducible
Depends on:
Blocks:
 
Reported: 2016-02-02 20:05 UTC by martchus
Modified: 2017-02-05 20:20 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description martchus 2016-02-02 20:05:39 UTC
- 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).
Comment 1 parejaobregon 2016-03-23 13:33:08 UTC
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()));
Comment 2 martchus 2016-03-23 17:24:06 UTC
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).
Comment 3 Michal Wirth 2016-03-25 21:20:20 UTC
Hi, I can also confirm same behavior at my Debian Stretch machine running Qt 5.5.1 and KDE Frameworks 5.16.0.
Comment 4 Diabolo 2016-04-09 17:18:48 UTC
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
Comment 5 martchus 2016-04-09 18:32:12 UTC
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.
Comment 6 Diabolo 2016-04-10 20:46:52 UTC
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.
Comment 7 martchus 2017-02-05 20:20:59 UTC
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.