From aba4462e0238d6075e8822d56a78372eacfa7d2e Mon Sep 17 00:00:00 2001 From: David Lerch Date: Sat, 30 Jan 2021 12:11:22 +0100 Subject: Add support for hover sequence thumbnails (via ThumbSequenceCreator) This shows a slideshow of thumbs when the user hovers a file item. --- src/kitemviews/kstandarditemlistwidget.cpp | 37 +++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'src/kitemviews/kstandarditemlistwidget.cpp') diff --git a/src/kitemviews/kstandarditemlistwidget.cpp b/src/kitemviews/kstandarditemlistwidget.cpp index e58340fb8..9c527fa17 100644 --- a/src/kitemviews/kstandarditemlistwidget.cpp +++ b/src/kitemviews/kstandarditemlistwidget.cpp @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -581,6 +582,13 @@ void KStandardItemListWidget::invalidateCache() m_dirtyContent = true; } +void KStandardItemListWidget::invalidateIconCache() +{ + m_dirtyContent = true; + m_dirtyContentRoles.insert("iconPixmap"); + m_dirtyContentRoles.insert("iconOverlays"); +} + void KStandardItemListWidget::refreshCache() { } @@ -945,7 +953,34 @@ void KStandardItemListWidget::updatePixmapCache() } if (updatePixmap) { - m_pixmap = values["iconPixmap"].value(); + m_pixmap = QPixmap(); + + int sequenceIndex = hoverSequenceIndex(); + + if (values.contains("hoverSequencePixmaps")) { + // Use one of the hover sequence pixmaps instead of the default + // icon pixmap. + + const QVector pixmaps = values["hoverSequencePixmaps"].value>(); + + if (values.contains("hoverSequenceWraparoundPoint")) { + const float wap = values["hoverSequenceWraparoundPoint"].toFloat(); + if (wap >= 1.0f) { + sequenceIndex %= static_cast(wap); + } + } + + const int loadedIndex = qMax(qMin(sequenceIndex, pixmaps.size()-1), 0); + + if (loadedIndex != 0) { + m_pixmap = pixmaps[loadedIndex]; + } + } + + if (m_pixmap.isNull()) { + m_pixmap = values["iconPixmap"].value(); + } + if (m_pixmap.isNull()) { // Use the icon that fits to the MIME-type QString iconName = values["iconName"].toString(); -- cgit v1.3