KIO::ThumbnailCreator Class

Header: #include <ThumbnailCreator>
CMake: find_package(KF6 REQUIRED COMPONENTS KIO)
target_link_libraries(mytarget PRIVATE KIOGui)

Public Functions

virtual KIO::ThumbnailResult create(const KIO::ThumbnailRequest &request) = 0

Detailed Description

@class ThumbnailCreator thumbnailcreator.h <KIO/ThumbnailCreator>

Base class for thumbnail generator plugins.

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 \htmlonly "text/&#42;".\endhtmlonly\latexonly text/$\ast$.\endlatexonly

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.

@since 5.100

Member Function Documentation

[pure virtual] KIO::ThumbnailResult ThumbnailCreator::create(const KIO::ThumbnailRequest &request)

Creates a thumbnail for a given request