diff --git a/retroshare-gui/src/gui/common/Emoticons.cpp b/retroshare-gui/src/gui/common/Emoticons.cpp index bb935d052..37e40e72f 100644 --- a/retroshare-gui/src/gui/common/Emoticons.cpp +++ b/retroshare-gui/src/gui/common/Emoticons.cpp @@ -43,6 +43,7 @@ static QHash, QHash > > Smiley static QVector grpOrdered; static QVector StickerGroups; static QStringList filters; +static QHash tooltipcache; void Emoticons::load() { @@ -339,14 +340,7 @@ void Emoticons::showStickerWidget(QWidget *parent, QWidget *button, const char * //Lazy load tooltips for the current tab QObject::connect(smTab, &QTabWidget::currentChanged, [=](int index){ QWidget* current = smTab->widget(index); - QList children = current->findChildren(); - for(int i = 0; i < children.length(); ++i) { - if(!children[i]->toolTip().contains('<')) { - QString tooltip; - if(RsHtml::makeEmbeddedImage(children[i]->statusTip(), tooltip, 300*300)) - children[i]->setToolTip(tooltip); - } - } + loadToolTips(current); }); tabGrpWidget = new QWidget(smTab); @@ -414,12 +408,7 @@ void Emoticons::showStickerWidget(QWidget *parent, QWidget *button, const char * } else { firstpage = smTab->currentWidget(); } - QList children = firstpage->findChildren(); - for(int i = 0; i < children.length(); ++i) { - QString tooltip; - if(RsHtml::makeEmbeddedImage(children[i]->statusTip(), tooltip, 300*300)) - children[i]->setToolTip(tooltip); - } + loadToolTips(firstpage); //Get left up pos of button QPoint butTopLeft = button->mapToGlobal(QPoint(0,0)); @@ -456,3 +445,23 @@ void Emoticons::showStickerWidget(QWidget *parent, QWidget *button, const char * smWidget->move(x, y); smWidget->show(); } + +void Emoticons::loadToolTips(QWidget *container) +{ + QList children = container->findChildren(); + for(int i = 0; i < children.length(); ++i) { + if(!children[i]->toolTip().contains('<')) { + if(tooltipcache.contains(children[i]->statusTip())) { + children[i]->setToolTip(tooltipcache[children[i]->statusTip()]); + } else { + QString tooltip; + if(RsHtml::makeEmbeddedImage(children[i]->statusTip(), tooltip, 300*300)) { + tooltipcache.insert(children[i]->statusTip(), tooltip); + children[i]->setToolTip(tooltip); + } + + } + + } + } +} diff --git a/retroshare-gui/src/gui/common/Emoticons.h b/retroshare-gui/src/gui/common/Emoticons.h index 360ddf880..f4b42c0ff 100644 --- a/retroshare-gui/src/gui/common/Emoticons.h +++ b/retroshare-gui/src/gui/common/Emoticons.h @@ -34,7 +34,8 @@ public: static void showSmileyWidget(QWidget *parent, QWidget *button, const char *slotAddMethod, bool above); static void showStickerWidget(QWidget *parent, QWidget *button, const char *slotAddMethod, bool above); -// static void formatText(QString &text); +private: + static void loadToolTips(QWidget *container); }; #endif