KIO::ThumbnailCreator Class
Base class for thumbnail generator plugins. More...
Header: | #include <KIO/ThumbnailCreator> |
CMake: | find_package(KF6 REQUIRED COMPONENTS KIO) target_link_libraries(mytarget PRIVATE KIOGui) |
Since: | KDE Frameworks 5.100 |
Inherits: | QObject |
Public Functions
virtual KIO::ThumbnailResult | create(const KIO::ThumbnailRequest &request) = 0 |
Detailed Description
KIO::PreviewJob, via the "thumbnail" KIO worker, uses instances of this class to generate the thumbnail previews.
To add support for a new document type, subclass KIO::ThumbnailCreator and implement create() to generate a thumbnail for a given path.
Compile your ThumbCreator as a plugin; for example, the relevant CMake code for a thumbnailer for the "foo" filetype might look like
kcoreaddons_add_plugin(foothumbnail SOURCES foothumbnail.cpp INSTALL_NAMESPACE "kf6/thumbcreator") target_link_libraries(foothumbnail PRIVATE KF5::KIOGui)
You also need a JSON file containing the metadata:
{ "CacheThumbnail": true, "KPlugin": { "MimeTypes": [ "image/x-foo" ], "Name": "Foo Documents" } }
MIME types can also use simple wildcards, like "text/*"
If the thumbnail creation is cheap (such as text previews), you can set
"CacheThumbnail": false
in metadata to prevent your thumbnails from being cached on disk.
You can also use the "ThumbnailerVersion" optional property in the .desktop file, like
"ThumbnailerVersion": 5
When this is incremented (or defined when it previously was not), all the previously-cached thumbnails for this creator will be discarded. You should increase the version if and only if old thumbnails need to be regenerated.
Member Function Documentation
[pure virtual]
KIO::ThumbnailResult ThumbnailCreator::create(const KIO::ThumbnailRequest &request)
Creates a thumbnail for a given request