mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-14 00:49:41 -05:00
Cache the tooltips
This commit is contained in:
parent
5b0438a10f
commit
a3801c579a
@ -43,6 +43,7 @@ static QHash<QString, QPair<QVector<QString>, QHash<QString, QString> > > Smiley
|
||||
static QVector<QString> grpOrdered;
|
||||
static QVector<QString > StickerGroups;
|
||||
static QStringList filters;
|
||||
static QHash<QString, QString> 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<QPushButton *> children = current->findChildren<QPushButton *>();
|
||||
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<QPushButton *> children = firstpage->findChildren<QPushButton *>();
|
||||
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<QPushButton *> children = container->findChildren<QPushButton *>();
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user