Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-96025

QFileIconProvider::icon() does not return extra-large and jumbo icons for items with icon overlays on Windows

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.15.2
    • QPA: Windows
    • None
    • Windows

    Description

      When I try to obtain extra-large (48x48) icon or jumbo icon (256x256) via QFileIconProvider::icon() for items which have overlays (e.g. shortcuts or items which are associated with some shell extensions such as items present in Git repository when TortoiseGit is installed). These overlays are displayed like this in Windows File Explorer (note the sub-icons in the bottom left corner):

      I would expect to get the same result from QFileIconProvider::icon().pixmap(QSize(256,256)). But all I get is only small 32x32 icon which are pixelated when I try to resize them to 256x256.

      Not that in cases when the icon has no overlay, the returned icon has correct 256x256 size. So the problem is with overlays only!

      I dug into the code I found that this is probably caused by wrong obtaining of icon index with IImageList interface in cases when there is overlay associated with the icon. As documentation to SHGetFileInfo when used with flag SHGFI_OVERLAYINDEX says: the highest 8 bits are reserved for the overlay icon index. So to get the icon and overlay we need to separate the icon index (info.iIcon & 0xFFFFFF) and overlay index (info.iIcon >> 24). Otherwise we do not remove these 8 bits and try to get icon (IImageList::GetIcon()) with this index, we end up with invalid index which causes null bitmap being returned. To get the overlay index we need to use code like this

      int overlayIndex;
      imageList->GetOverlayImage(info.iIcon >> 24, &overlayIndex)); // TODO: error handling
      

      I created stackoverflow question and found some solution which I posted as answer which I think shows the correct way of handling with extra-large and jumbo icons with overlays. https://stackoverflow.com/questions/68928748/add-file-icon-overlay-for-jumbo-icons-with-winapi

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              owolff Oliver Wolff
              vladimir.kraus Vladimir Kraus
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes