Unified icon set and image version handling for Qt Widgets and Qt Quick
[By the lack of a better term, "version" refers to image properties such as size and scale, not scm revisions.]
Key Change: Support differentiating between image size and image density.
Example: starting with a 32x32 base image there are two ways to create a 64x64 variant:
- Add more content - the version is intended to cover a larger visual area
- Add more detail - the version is intended for higher density displays
Current support in Qt (e.g. QIcon) folds these into one dimension “size”. This can be sufficient for many use cases, but we want Qt to have the support for making the distinction. This requires modifying API such as QIconProvider and QQuickImageProvider.
Icon support for Qt Quick Controls: https://wiki.qt.io/Icons_In_Qt_Quick_Controls
Current Solutions In Qt
- efficient run-time look up of correct pixmap variant
- minimal memory usage: load correct pixmap variant for target display(s) only
- Declarative format, independent of "user" API (QIcon vs QtQuick equivalent, devicePixelRatio vs other high-dpi implementation)
- Modes and states support? (active/inactive/disabled etc)
Current Solutions In Qt
Google Maps API uses tile size and scale. The tile size here controls the resolution and is not a visual size: increasing it gives more detail, not more map content. See https://developers.google.com/maps/documentation/ios-sdk/tiles
Supports srcset with device-pixel-ratio based image selection:
HTML does not seem to support differentiating between firstname.lastname@example.org and email@example.com.
New Icon type for Qt Quick
QtWidgets currently has two container types: QIcon for multiple images, and QImage/Pixmap for single images. We could bring the same setup to Qt Quick and introduce the Icon type for representing multiple images. This type would then be used in many places where Image is used today.
The counter-argument to this is that we want to simplify for Qt Quick: Today multi-resolution display support is the norm and the main (and only) Image type in Qt Quick should support it.
Suggested image file schema
Use in Qt Widgets
Use in Qt Quick
We would implement backends for QIcon and QML Icon and make loading efficient: The filesystem structure is only scanned once, and only the version actually displayed is loaded into memory.
To avoid filesystem scanning we support a manifest file: