KIO::PreviewJob Class

KIO Job to get a thumbnail picture. More...

Header: #include <KIO/PreviewJob>
CMake: find_package(KF6 REQUIRED COMPONENTS KIO)
target_link_libraries(mytarget PRIVATE KIOGui)
Inherits: KIO::Job

Public Types

enum ScaleType { Unscaled, Scaled, ScaledAndCached }

Public Functions

PreviewJob(const KFileItemList &items, const QSize &size, const QStringList *enabledPlugins = nullptr)
(since 5.80) bool handlesSequences() const
void removeItem(const QUrl &url)
KIO::PreviewJob::ScaleType scaleType() const
int sequenceIndex() const
(since 5.80) float sequenceIndexWraparoundPoint() const
(since 5.84) void setDevicePixelRatio(qreal dpr)
void setIgnoreMaximumSize(bool ignoreSize = true)
void setScaleType(KIO::PreviewJob::ScaleType type)
void setSequenceIndex(int index)

Signals

void failed(const KFileItem &item)
void gotPreview(const KFileItem &item, const QPixmap &preview)

Static Public Members

QStringList availablePlugins()
(since 5.90) QList<KPluginMetaData> availableThumbnailerPlugins()
(since 5.40) QStringList defaultPlugins()
(since 5.84) void setDefaultDevicePixelRatio(qreal devicePixelRatio)
QStringList supportedMimeTypes()
KIO::PreviewJob *filePreview(const KFileItemList &items, const QSize &size, const QStringList *enabledPlugins = nullptr)

Detailed Description

This class catches a preview (thumbnail) for files.

Member Type Documentation

enum PreviewJob::ScaleType

Specifies the type of scaling that is applied to the generated preview. For HiDPI, pixel density scaling, see setDevicePixelRatio

ConstantValueDescription
KIO::PreviewJob::Unscaled0The original size of the preview will be returned. Most previews will return a size of 256 x 256 pixels.
KIO::PreviewJob::Scaled1The preview will be scaled to the size specified when constructing the PreviewJob. The aspect ratio will be kept.
KIO::PreviewJob::ScaledAndCached2The preview will be scaled to the size specified when constructing the PreviewJob. The result will be cached for later use. Per default ScaledAndCached is set.

Member Function Documentation

PreviewJob::PreviewJob(const KFileItemList &items, const QSize &size, const QStringList *enabledPlugins = nullptr)

items List of files to create previews for. size Desired size of the preview. enabledPlugins If non-zero it defines the list of plugins that are considered for generating the preview. If enabledPlugins is zero the plugins specified in the KConfigGroup "PreviewSettings" are used.

[static] QStringList PreviewJob::availablePlugins()

Returns a list of all available preview plugins. The list contains the basenames of the plugins' .desktop files (no path, no .desktop). Returns the list of all available plugins

[static, since 5.90] QList<KPluginMetaData> PreviewJob::availableThumbnailerPlugins()

Returns all plugins that are considered when a preview is generated The result is internally cached, meaning any further method call will not reload the plugins

This function was introduced in KDE Frameworks 5.90.

[static, since 5.40] QStringList PreviewJob::defaultPlugins()

Returns a list of plugins that should be enabled by default, which is all plugins Minus the plugins specified in an internal blacklist Returns the list of plugins that should be enabled by default

This function was introduced in KDE Frameworks 5.40.

[signal] void PreviewJob::failed(const KFileItem &item)

Emitted when a thumbnail for item could not be created, either because a ThumbCreator for its MIME type does not exist, or because something went wrong.

item the file that failed

[signal] void PreviewJob::gotPreview(const KFileItem &item, const QPixmap &preview)

Emitted when a thumbnail picture for item has been successfully retrieved.

item the file of the preview

preview the preview image

[since 5.80] bool PreviewJob::handlesSequences() const

Determines whether the ThumbCreator in use is a ThumbSequenceCreator.

This function was introduced in KDE Frameworks 5.80.

void PreviewJob::removeItem(const QUrl &url)

Removes an item from preview processing. Use this if you passed an item to filePreview and want to delete it now.

url the url of the item that should be removed from the preview queue

KIO::PreviewJob::ScaleType PreviewJob::scaleType() const

Returns The scale type for the generated preview.

See also setScaleType() and PreviewJob::ScaleType.

int PreviewJob::sequenceIndex() const

Returns the currently set sequence index

See also setSequenceIndex().

[since 5.80] float PreviewJob::sequenceIndexWraparoundPoint() const

Returns the index at which the thumbs of a ThumbSequenceCreator start wrapping around ("looping"). Fractional values may be returned if the ThumbSequenceCreator supports sub-integer precision, but frontends supporting only integer sequence indices may choose to round it down.

This function was introduced in KDE Frameworks 5.80.

See also ThumbSequenceCreator::sequenceIndexWraparoundPoint().

[static, since 5.84] void PreviewJob::setDefaultDevicePixelRatio(qreal devicePixelRatio)

Sets a default device Pixel Ratio used for Previews

Defaults to 1

This function was introduced in KDE Frameworks 5.84.

See also setDevicePixelRatio.

[since 5.84] void PreviewJob::setDevicePixelRatio(qreal dpr)

Request preview to use the device pixel ratio dpr. The returned thumbnail may not respect the device pixel ratio requested. Use QPixmap::devicePixelRatio to check, or paint as necessary.

This function was introduced in KDE Frameworks 5.84.

void PreviewJob::setIgnoreMaximumSize(bool ignoreSize = true)

If ignoreSize is true, then the preview is always generated regardless of the settings

void PreviewJob::setScaleType(KIO::PreviewJob::ScaleType type)

Sets the scale type for the generated preview. Per default PreviewJob::ScaledAndCached is set.

See also scaleType() and PreviewJob::ScaleType.

void PreviewJob::setSequenceIndex(int index)

Sets the sequence index given to the thumb creators. Use the sequence index, it is possible to create alternative icons for the same item. For example it may allow iterating through the items of a directory, or the frames of a video.

See also sequenceIndex().

[static] QStringList PreviewJob::supportedMimeTypes()

Returns a list of all supported MIME types. The list can contain entries like text/ * (without the space). Returns the list of MIME types

Related Non-Members

KIO::PreviewJob *filePreview(const KFileItemList &items, const QSize &size, const QStringList *enabledPlugins = nullptr)

Creates a PreviewJob to generate a preview image for the given items.

items List of files to create previews for.

size Desired size of the preview.

enabledPlugins If non-zero it defines the list of plugins that are considered for generating the preview. If enabledPlugins is zero the plugins specified in the KConfigGroup "PreviewSettings" are used.