diff options
| author | David Lerch <[email protected]> | 2021-01-30 12:11:22 +0100 |
|---|---|---|
| committer | Elvis Angelaccio <[email protected]> | 2021-07-04 10:24:07 +0000 |
| commit | aba4462e0238d6075e8822d56a78372eacfa7d2e (patch) | |
| tree | 1b735f8959036ff66568ad209416d3b1362bff7f /src/kitemviews/kfileitemmodelrolesupdater.h | |
| parent | 8048e6ed1bee096fb82fa2335d533779c89c809a (diff) | |
Add support for hover sequence thumbnails (via ThumbSequenceCreator)
This shows a slideshow of thumbs when the user hovers a file item.
Diffstat (limited to 'src/kitemviews/kfileitemmodelrolesupdater.h')
| -rw-r--r-- | src/kitemviews/kfileitemmodelrolesupdater.h | 74 |
1 files changed, 73 insertions, 1 deletions
diff --git a/src/kitemviews/kfileitemmodelrolesupdater.h b/src/kitemviews/kfileitemmodelrolesupdater.h index 8e1e1fcbe..a03ab513a 100644 --- a/src/kitemviews/kfileitemmodelrolesupdater.h +++ b/src/kitemviews/kfileitemmodelrolesupdater.h @@ -10,6 +10,8 @@ #include "dolphin_export.h" #include "kitemviews/kitemmodelbase.h" +#include <list> + #include <KFileItem> #include <config-baloo.h> @@ -159,6 +161,19 @@ public: void setScanDirectories(bool enabled); bool scanDirectories() const; + /** + * Notifies the updater of a change in the hover state on an item. + * + * This will trigger asynchronous loading of the next few thumb sequence images + * using a PreviewJob. + * + * @param item URL of the item that is hovered, or an empty URL if no item is hovered. + * @param seqIdx The current hover sequence index. While an item is hovered, + * this method will be called repeatedly with increasing values + * for this parameter. + */ + void setHoverSequenceState(const QUrl& itemUrl, int seqIdx); + private Q_SLOTS: void slotItemsInserted(const KItemRangeList& itemRanges); void slotItemsRemoved(const KItemRangeList& itemRanges); @@ -170,12 +185,18 @@ private Q_SLOTS: /** * Is invoked after a preview has been received successfully. + * + * Note that this is not called for hover sequence previews. + * * @see startPreviewJob() */ void slotGotPreview(const KFileItem& item, const QPixmap& pixmap); /** * Is invoked after generating a preview has failed. + * + * Note that this is not called for hover sequence previews. + * * @see startPreviewJob() */ void slotPreviewFailed(const KFileItem& item); @@ -183,12 +204,35 @@ private Q_SLOTS: /** * Is invoked when the preview job has been finished. Starts a new preview * job if there are any interesting items without previews left, or updates - * the changed items otherwise. * + * the changed items otherwise. + * + * Note that this is not called for hover sequence previews. + * * @see startPreviewJob() */ void slotPreviewJobFinished(); /** + * Is invoked after a hover sequence preview has been received successfully. + */ + void slotHoverSequenceGotPreview(const KFileItem& item, const QPixmap& pixmap); + + /** + * Is invoked after generating a hover sequence preview has failed. + */ + void slotHoverSequencePreviewFailed(const KFileItem& item); + + /** + * Is invoked when a hover sequence preview job is finished. May start another + * job for the next sequence index right away by calling + * \a loadNextHoverSequencePreview(). + * + * Note that a PreviewJob will only ever generate a single sequence image, due + * to limitations of the PreviewJob API. + */ + void slotHoverSequencePreviewJobFinished(); + + /** * Is invoked when one of the KOverlayIconPlugin emit the signal that an overlay has changed */ void slotOverlaysChanged(const QUrl& url, const QStringList&); @@ -244,6 +288,24 @@ private: void startPreviewJob(); /** + * Transforms a raw preview image, applying scale and frame. + * + * @param pixmap A raw preview image from a PreviewJob. + * @return The scaled and decorated preview image. + */ + QPixmap transformPreviewPixmap(const QPixmap& pixmap); + + /** + * Starts a PreviewJob for loading the next hover sequence image. + */ + void loadNextHoverSequencePreview(); + + /** + * Aborts the currently running hover sequence PreviewJob (if any). + */ + void killHoverSequencePreviewJob(); + + /** * Ensures that icons, previews, and other roles are determined for any * items that have been changed. */ @@ -273,6 +335,8 @@ private: QList<int> indexesToResolve() const; + void trimHoverSequenceLoadedItems(); + private: enum State { Idle, @@ -329,6 +393,14 @@ private: KIO::PreviewJob* m_previewJob; + // Info about the item that the user currently hovers, and the current sequence + // index for thumb generation. + KFileItem m_hoverSequenceItem; + int m_hoverSequenceIndex; + KIO::PreviewJob* m_hoverSequencePreviewJob; + int m_hoverSequenceNumSuccessiveFailures; + std::list<KFileItem> m_hoverSequenceLoadedItems; + // When downloading or copying large files, the slot slotItemsChanged() // will be called periodically within a quite short delay. To prevent // a high CPU-load by generating e.g. previews for each notification, the update |
