diff --git a/src/delegates/ImageManipulationDelegate.h b/src/delegates/ImageManipulationDelegate.h index 9605ba39f64b786dcc091cfc83102517fbe88e62..b99cd6ae2b4290e81adc17d2bad37c33ab49ad4e 100644 --- a/src/delegates/ImageManipulationDelegate.h +++ b/src/delegates/ImageManipulationDelegate.h @@ -63,6 +63,7 @@ namespace Interfaces { CGImageRef resizeCGImage(CGImageRef image, const QSize& size); QHash<QString, QPixmap> m_hDefaultUserPixmap; + QHash<QString, QPixmap> m_hContactsPixmap; /** * Return a version of size destSize centered of the bigger photo diff --git a/src/delegates/ImageManipulationDelegate.mm b/src/delegates/ImageManipulationDelegate.mm index 7780d9470a0b081f751ff3cd61a4645b4fceef13..082c9416978c5461f51db358c891c8f118e50492 100644 --- a/src/delegates/ImageManipulationDelegate.mm +++ b/src/delegates/ImageManipulationDelegate.mm @@ -46,6 +46,13 @@ namespace Interfaces { QVariant ImageManipulationDelegate::contactPhoto(Person* c, const QSize& size, bool displayPresence) { const int radius = size.height() / 2; + auto index = QStringLiteral("%1%2%3").arg(size.width()) + .arg(size.height()) + .arg(QString::fromUtf8(c->uid())); + if (m_hContactsPixmap.contains(index)) { + return m_hContactsPixmap.value(index); + } + QPixmap pxm; if (c && c->photo().isValid()) { QPixmap contactPhoto(qvariant_cast<QPixmap>(c->photo()).scaled(size, Qt::KeepAspectRatioByExpanding, @@ -87,6 +94,8 @@ namespace Interfaces { pxm = drawDefaultUserPixmap(size); } + m_hContactsPixmap.insert(index, pxm); + return pxm; }