ThumbCreator
#include <KIO/ThumbCreator>

Public Types | |
enum | Flags { None = 0, DrawFrame, BlendIcon = 2 } |
Public Member Functions | |
virtual | ~ThumbCreator () |
virtual bool | create (const QString &path, int width, int height, QImage &img)=0 |
virtual QWidget * | createConfigurationWidget () |
virtual Flags | flags () const |
virtual void | writeConfiguration (const QWidget *configurationWidget) |
Detailed Description
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 ThumbCreator and implement create() to generate a thumbnail for a given path. Then create a factory method called "new_creator" to return instances of your subclass:
Compile your ThumbCreator as a module; for example, the relevant CMake code for a thumbnailer for the "foo" filetype might look like
You also need to create a desktop file describing the thumbnailer. For example:
Of course, you will need to install it:
Note that you can supply a comma-separated list of MIME types to the MimeTypes entry, naming all MIME types your ThumbCreator supports. You can also use simple wildcards, like "text/*".
If the thumbnail creation is cheap (such as text previews), you can set
in the desktop file to prevent your thumbnails from being cached on disk.
You can also use the "ThumbnailerVersion" optional property in the .desktop file, like
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.
- Deprecated:
- since 5.101, use KIO::ThumbnailCreator instead
Definition at line 87 of file thumbcreator.h.
Member Enumeration Documentation
◆ Flags
enum ThumbCreator::Flags |
Flags to provide hints to the user of this plugin.
- See also
- flags()
Enumerator | |
---|---|
None | No hints. |
DrawFrame |
Used to paint a frame around the preview, but applications take care of that nowadays. |
BlendIcon | The MIME type icon should be blended over the preview. |
Definition at line 94 of file thumbcreator.h.
Constructor & Destructor Documentation
◆ ~ThumbCreator()
|
virtual |
Destructor.
Definition at line 14 of file thumbcreator.cpp.
Member Function Documentation
◆ create()
|
pure virtual |
Creates a thumbnail.
Note that this method should not do any scaling. The width
and height
parameters are provided as hints for images that are generated from non-image data (like text).
- Parameters
-
path The path of the file to create a preview for. This is always a local path. width The requested preview width (see the note on scaling above). height The requested preview height (see the note on scaling above). img The QImage to store the preview in.
- Returns
true
if a preview was successfully generated and store inimg
,false
otherwise.
- Deprecated:
- since 5.101, use KIO::ThumbnailCreator instead.
◆ createConfigurationWidget()
|
virtual |
Create a widget for configuring the thumb creator.
The caller will take ownership of the returned instance and must ensure its deletion.
The default implementation returns nullptr
.
The following key in the thumbcreator .desktop file must be set to mark the plugin as configurable:
- Returns
- A QWidget instance, which the caller takes ownership of, or
nullptr
.
- Deprecated:
- Since 5.87, deprecated for lack of usage and only being used for niche usecases. Instead use sane defaults and keep reading the config if it exists.
Definition at line 30 of file thumbcreator.cpp.
◆ flags()
|
virtual |
Returns the flags for this plugin.
- Returns
- XOR'd flags values.
- See also
- Flags
Definition at line 18 of file thumbcreator.cpp.
◆ writeConfiguration()
|
virtual |
Write the updated configuration.
- Parameters
-
configurationWidget An object returned by createConfigurationWidget().
- Deprecated:
- Since 5.87, see API docs of
createConfigurationWidget
Definition at line 35 of file thumbcreator.cpp.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2023 The KDE developers.
Generated on Thu Dec 7 2023 03:55:34 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.