From 15ac7eecc85cf2d165bc3646e22e362068282dbf Mon Sep 17 00:00:00 2001 From: hunbernd Date: Thu, 26 Dec 2019 00:01:14 +0100 Subject: [PATCH] Cache sticker icons --- retroshare-gui/src/gui/common/Emoticons.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/common/Emoticons.cpp b/retroshare-gui/src/gui/common/Emoticons.cpp index 1bc58b871..347d88b6e 100644 --- a/retroshare-gui/src/gui/common/Emoticons.cpp +++ b/retroshare-gui/src/gui/common/Emoticons.cpp @@ -45,6 +45,7 @@ static QVector grpOrdered; static QStringList filters; static QStringList stickerFolders; static QHash tooltipcache; +static QHash iconcache; void Emoticons::load() { @@ -398,7 +399,11 @@ void Emoticons::showStickerWidget(QWidget *parent, QWidget *button, const char * QPushButton *button = new QPushButton("", tabGrpWidget); button->setIconSize(QSize(buttonWidth, buttonHeight)); button->setFixedSize(QSize(buttonWidth, buttonHeight)); - button->setIcon(QPixmap(fi.absoluteFilePath())); + if(!iconcache.contains(fi.absoluteFilePath())) + { + iconcache.insert(fi.absoluteFilePath(), QPixmap(fi.absoluteFilePath()).scaled(buttonWidth, buttonHeight, Qt::KeepAspectRatio)); + } + button->setIcon(iconcache[fi.absoluteFilePath()]); button->setToolTip(fi.fileName()); button->setStatusTip(fi.absoluteFilePath()); button->setStyleSheet("QPushButton:hover {border: 3px solid #0099cc; border-radius: 3px;}");