class ThumbCreator


abstract

Module kio
Namespace
Class ThumbCreator
Inherits
This is the baseclass for "thumbnail-plugins" in KDE. Using the class KIO.PreviewJob allows you to generate small images (thumbnails) for any kind of file, where a "ThumbCreator" is available. Have a look at kdebase/kioslave/thumbnail/ for existing ThumbCreators.

What you need to do to create and register a ThumbCreator:

  • Inherit from this class and reimplement the create() method to
  • generate a thumbnail for the given file-path.
  • Provide a factory method in your implementation file to instantiate
  • your plugin, e.g.:
    extern "C"
    {
    KDE_EXPORT ThumbCreator *new_creator()
    {
    return new YourThumbCreator();
    }
    };
    

    Compile your ThumbCreator as a module. The contents of CMakeLists.txt should look something like this, with "filetype" replaced by the type of file this plugin creates thumbnails for:

    project(filetypethumbcreator)
    

    find_package(KDE4 REQUIRED) include (KDE4Defaults) include(MacroOptionalAddSubdirectory)

    set(filetypethumbnail_SRCS filetypethumbnail.cpp)

    kde4_add_ui_files(filetypethumbnail_SRCS config.ui )

    kde4_add_plugin(filetypethumbnail ${filetypethumbnail_SRCS}) target_link_libraries(filetypethumbnail ${KDE4_KIO_LIBS})

    install(TARGETS filetypethumbnail DESTINATION ${PLUGIN_INSTALL_DIR}) install(FILES filetypethumbcreator.desktop DESTINATION ${SERVICES_INSTALL_DIR})

  • Create a file filetypethumbcreator.desktop with the following contents:
  • [Desktop Entry]
    Encoding=UTF-8
    Type=Service
    Name=Name of the type of files your ThumbCreator supports
    ServiceTypes=ThumbCreator
    MimeType=application/x-somemimetype;
    CacheThumbnail=true
    X-KDE-Library=yourthumbcreator
    

    You can supply a comma-separated list of mimetypes to the MimeTypes entry, naming all mimetypes your ThumbCreator supports. You can also use simple wildcards, like (where you see [slash], put a /)

    text[slash]* or image[slash]*.
    

    If your plugin is rather inexpensive (e.g. like the text preview ThumbCreator), you can set CacheThumbnail=false to prevent your thumbnails from being cached on disk.

    Baseclass for thumbnail-generating plugins.



    enums

    enum details

    methods