Recent

Author Topic: ShellTreeView and system icons  (Read 18522 times)

El Salvador

  • Full Member
  • ***
  • Posts: 133
Re: ShellTreeView and system icons
« Reply #60 on: April 17, 2021, 12:58:47 pm »
Hi everyone, these days I went back to the topic and did some research.

On Linux, the file icons are located in the themes folder (different folders), according to the FreeDesktop.org Icon Theme specification (https://specifications.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html).

I found that the DoubleCommander authors wrote their own implementation (https://github.com/double-commander/doublecmd/blob/master/src/platform/uicontheme.pas) in FreePascal. But GTK2 / 3 and QT5 also have their own variant. So there are three cases:
- We write an implementation in Pascal (we reinvent the wheel)
- We take (with the permission of the DoubleCMD authors) and adapt (remove external unit) the class for insertion into Lazarus
- We use the QT (using QIcon_fromtheme(retval, 'mimetype') and get its QPixMap with defined size) and GTK2 / 3 (see https://github.com/GNOME/gtk/blob/f6f07ba238b4f734d9134c5e3a5e726ce8cb5fea/gtk/gtkicontheme.c#L91) libraries. But how do we draw icons (as QIcon/QPixMap or GtkIconPaintable)?

El Salvador

  • Full Member
  • ***
  • Posts: 133
Re: ShellTreeView and system icons
« Reply #61 on: April 19, 2021, 08:44:10 pm »
Some progress in QT5. See attached image.

wp

  • Hero Member
  • *****
  • Posts: 11830
Re: ShellTreeView and system icons
« Reply #62 on: April 19, 2021, 10:23:30 pm »
Can you post a patch?

balazsszekely

  • Guest
Re: ShellTreeView and system icons
« Reply #63 on: April 20, 2021, 06:38:06 am »
@El Salvador

Quote
Some progress in QT5. See attached image.
Looks good!

El Salvador

  • Full Member
  • ***
  • Posts: 133
Re: ShellTreeView and system icons
« Reply #64 on: April 20, 2021, 10:08:08 am »
Can you post a patch?
I'm still working on it. For now I am adapting the GetMem demo for QT5. Then I'll move on to integrate the changes into Lazarus.

wp

  • Hero Member
  • *****
  • Posts: 11830
Re: ShellTreeView and system icons
« Reply #65 on: April 20, 2021, 10:15:20 am »
Thanks

El Salvador

  • Full Member
  • ***
  • Posts: 133
Re: ShellTreeView and system icons
« Reply #66 on: April 20, 2021, 02:41:12 pm »
I am integrating the first changes into Lazarus for QT but I am having a small issue regarding the ShellListView.

The problem is simple: while in Windows, we use the system ImageList (see https://github.com/graemeg/lazarus/blob/9d47cae65ecb458d45e05edf0bd2d26629c907e2/lcl/interfaces/win32/win32wsshellctrls.pp#L140-L146), in Linux this does not exist. So in Linux how do we do?

El Salvador

  • Full Member
  • ***
  • Posts: 133
Re: ShellTreeView and system icons
« Reply #67 on: April 22, 2021, 07:53:08 pm »
Good news, everyone. I just pushed my WIP about automatic shell icons in QT5 and GTK2 in my Lazarus repo in github. Tomorrow I will do the GTK3 version.

For GTK3 and QT5, the code is still in work in progress and therefore the patch is not yet ready for the following reasons:
- The procedure LoadMimeIconNames is quite slow and I want to try to improve it. [fixed]
- Some parts of the code are duplicated between QT5 and GTK2. This is my first time modifying Lazarus, so I don't know how to go about making things better (especially QT5 wants Widestring and GTK2 AnsiString).
- There is no recognition of special folders and therefore generic icons are used for them

Edit: Completed for GTK3 (TShellListview doesn't work, I believe for issues on the TListview) - https://github.com/salvadorbs/lazarus/commit/e92a9e40b52a8cfaacc0a1658f480ef8faf1e6a3
Duplicate code problem got worse (see GTK3), but I will make the patch anyway. Suggestions are welcome
« Last Edit: April 23, 2021, 02:42:35 pm by El Salvador »

wp

  • Hero Member
  • *****
  • Posts: 11830
Re: ShellTreeView and system icons
« Reply #68 on: April 24, 2021, 10:39:36 pm »
El Salvador, applied your patch. Built-in shell icons now are displayed in TShellTreeView and TShellListview for the win32, qt5, gtk2 and gtk3 widgetsets (the latter has issues already in the base classes). Thanks for this contribution.

El Salvador

  • Full Member
  • ***
  • Posts: 133
Re: ShellTreeView and system icons
« Reply #69 on: April 27, 2021, 05:06:51 pm »
El Salvador, applied your patch.
Thank you very much. These days I'll probably do a small patch (about executable files), but if someone were to test the code on the various distros in the meantime it would be great. Thank you everybody!

wp

  • Hero Member
  • *****
  • Posts: 11830
Re: ShellTreeView and system icons
« Reply #70 on: May 03, 2021, 09:41:07 pm »
Had to revert the patch because it broke usage of qt5, gtk2 and gtk3 on Windows (https://bugs.freepascal.org/view.php?id=38831).

El Salvador

  • Full Member
  • ***
  • Posts: 133
Re: ShellTreeView and system icons
« Reply #71 on: May 03, 2021, 10:33:02 pm »
No problem, wp.

 

TinyPortal © 2005-2018