| 292 | } |
| 293 | |
| 294 | QPixmap Mod::setIcon(QImage new_image) const |
| 295 | { |
| 296 | QMutexLocker locker(&m_data_lock); |
| 297 | |
| 298 | Q_ASSERT(!new_image.isNull()); |
| 299 | |
| 300 | if (m_packImageCacheKey.key.isValid()) |
| 301 | PixmapCache::remove(m_packImageCacheKey.key); |
| 302 | |
| 303 | // scale the image to avoid flooding the pixmapcache |
| 304 | auto pixmap = |
| 305 | QPixmap::fromImage(new_image.scaled({ 64, 64 }, Qt::AspectRatioMode::KeepAspectRatioByExpanding, Qt::SmoothTransformation)); |
| 306 | |
| 307 | m_packImageCacheKey.key = PixmapCache::insert(pixmap); |
| 308 | m_packImageCacheKey.wasEverUsed = true; |
| 309 | m_packImageCacheKey.wasReadAttempt = true; |
| 310 | return pixmap; |
| 311 | } |
| 312 | |
| 313 | QPixmap Mod::icon(QSize size, Qt::AspectRatioMode mode) const |
| 314 | { |
no test coverage detected