• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KIO

Public Types | Public Member Functions | List of all members
ThumbCreator Class Referenceabstract

#include <thumbcreator.h>

Inheritance diagram for ThumbCreator:
Inheritance graph
[legend]

Public Types

enum  Flags { None = 0, DrawFrame = 1, BlendIcon = 2 }
 

Public Member Functions

virtual ~ThumbCreator ()
 
virtual bool create (const QString &path, int width, int height, QImage &img)=0
 
virtual Flags flags () const
 

Detailed Description

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. Use ThumbCreatorV2 if the thumbnail-plugin should be configurable by the user.

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.

The following optional property can also be added to the .desktop file:

ThumbnailerVersion=N

where N is some nonnegative integer. If a cached thumbnail has been created with a previous version of the thumbnailer, then the cached thumbnail will be discarded and a new one will be regenerated. Increase (or define) the version number if and only if old thumbnails need to be regenerated. If no version number is provided, then the version is assumed to be <0.

Baseclass for thumbnail-generating plugins.

Definition at line 109 of file thumbcreator.h.

Member Enumeration Documentation

enum ThumbCreator::Flags

The flags of this plugin.

See also
flags()
Enumerator
None 
DrawFrame 
BlendIcon 

Definition at line 116 of file thumbcreator.h.

Constructor & Destructor Documentation

ThumbCreator::~ThumbCreator ( )
virtual

Definition at line 22 of file thumbcreator.cpp.

Member Function Documentation

virtual bool ThumbCreator::create ( const QString &  path,
int  width,
int  height,
QImage &  img 
)
pure virtual

Creates a thumbnail Note that the width and height parameters should not be used for scaling.

Only plugins that create an image "from scratch", like the TextCreator should directly use the specified size. If the resulting preview is larger than width x height, it will be scaled down.

Parameters
paththe (always local) file path to create a preview for
widthmaximum width for the preview
heightmaximum height for the preview
imgthis image will contain the preview on success
Returns
true if preview generation succeeded
ThumbCreator::Flags ThumbCreator::flags ( ) const
virtual

The flags of this plugin:

  • None nothing special
  • DrawFrame a frame should be painted around the preview
  • BlendIcon the mimetype icon should be blended over the preview
Returns
flags for this plugin

Definition at line 26 of file thumbcreator.cpp.


The documentation for this class was generated from the following files:
  • thumbcreator.h
  • thumbcreator.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:24:55 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KIO

Skip menu "KIO"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal