]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Port away from deprecated KIconEffect API
authorNicolas Fella <nicolas.fella@gmx.de>
Tue, 16 Jul 2024 22:03:52 +0000 (00:03 +0200)
committerNicolas Fella <nicolas.fella@gmx.de>
Thu, 18 Jul 2024 23:15:45 +0000 (23:15 +0000)
src/kitemviews/kstandarditemlistwidget.cpp
src/panels/information/informationpanelcontent.cpp

index cddd433306c05f7ecd447109cd35bcb6b211a69f..e3e925c035b72b0afa73ef814c8b00ac2d7d60ca 100644 (file)
@@ -1088,8 +1088,14 @@ void KStandardItemListWidget::updatePixmapCache()
         }
 
         if (m_isCut) {
-            KIconEffect *effect = KIconLoader::global()->iconEffect();
-            m_pixmap = effect->apply(m_pixmap, KIconLoader::Desktop, KIconLoader::DisabledState);
+#if KICONTHEMES_VERSION >= QT_VERSION_CHECK(6, 5, 0)
+            KIconEffect::toDisabled(m_pixmap);
+#else
+            QImage img = m_pixmap.toImage();
+            KIconEffect::toGray(img, 1);
+            KIconEffect::semiTransparent(img);
+            m_pixmap = QPixmap::fromImage(img);
+#endif
         }
 
         if (m_isHidden) {
@@ -1162,13 +1168,13 @@ void KStandardItemListWidget::updatePixmapCache()
     // Prepare the pixmap that is used when the item gets hovered
     if (isHovered()) {
         m_hoverPixmap = m_pixmap;
-        KIconEffect *effect = KIconLoader::global()->iconEffect();
-        // In the KIconLoader terminology, active = hover.
-        if (effect->hasEffect(KIconLoader::Desktop, KIconLoader::ActiveState)) {
-            m_hoverPixmap = effect->apply(m_pixmap, KIconLoader::Desktop, KIconLoader::ActiveState);
-        } else {
-            m_hoverPixmap = m_pixmap;
-        }
+#if KICONTHEMES_VERSION >= QT_VERSION_CHECK(6, 5, 0)
+        KIconEffect::toActive(m_hoverPixmap);
+#else
+        QImage img = m_pixmap.toImage();
+        KIconEffect::toGamma(img, 0.7);
+        m_hoverPixmap = QPixmap::fromImage(img);
+#endif
     } else if (hoverOpacity() <= 0.0) {
         // No hover animation is ongoing. Clear m_hoverPixmap to save memory.
         m_hoverPixmap = QPixmap();
index 86a569a866809e09cb21d8c69e49f503ffd74bba..70d85a40211f2f3c928c07b391f76a517035fafa 100644 (file)
@@ -411,8 +411,15 @@ void InformationPanelContent::markOutdatedPreview()
         // use it until the preview is done
         showIcon(m_item);
     } else {
-        KIconEffect *iconEffect = KIconLoader::global()->iconEffect();
-        QPixmap disabledPixmap = iconEffect->apply(m_preview->pixmap(), KIconLoader::Desktop, KIconLoader::DisabledState);
+#if KICONTHEMES_VERSION >= QT_VERSION_CHECK(6, 5, 0)
+        QPixmap disabledPixmap = m_preview->pixmap();
+        KIconEffect::toDisabled(disabledPixmap);
+#else
+        QImage img = m_preview->pixmap().toImage();
+        KIconEffect::toGray(img, 1);
+        KIconEffect::semiTransparent(img);
+        QPixmap disabledPixmap = QPixmap::fromImage(img);
+#endif
         m_preview->setPixmap(disabledPixmap);
     }
 }