mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-08 22:32:34 -04:00
Cache the tooltips
This commit is contained in:
parent
5b0438a10f
commit
a3801c579a
2 changed files with 25 additions and 15 deletions
|
@ -43,6 +43,7 @@ static QHash<QString, QPair<QVector<QString>, QHash<QString, QString> > > Smiley
|
||||||
static QVector<QString> grpOrdered;
|
static QVector<QString> grpOrdered;
|
||||||
static QVector<QString > StickerGroups;
|
static QVector<QString > StickerGroups;
|
||||||
static QStringList filters;
|
static QStringList filters;
|
||||||
|
static QHash<QString, QString> tooltipcache;
|
||||||
|
|
||||||
void Emoticons::load()
|
void Emoticons::load()
|
||||||
{
|
{
|
||||||
|
@ -339,14 +340,7 @@ void Emoticons::showStickerWidget(QWidget *parent, QWidget *button, const char *
|
||||||
//Lazy load tooltips for the current tab
|
//Lazy load tooltips for the current tab
|
||||||
QObject::connect(smTab, &QTabWidget::currentChanged, [=](int index){
|
QObject::connect(smTab, &QTabWidget::currentChanged, [=](int index){
|
||||||
QWidget* current = smTab->widget(index);
|
QWidget* current = smTab->widget(index);
|
||||||
QList<QPushButton *> children = current->findChildren<QPushButton *>();
|
loadToolTips(current);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
tabGrpWidget = new QWidget(smTab);
|
tabGrpWidget = new QWidget(smTab);
|
||||||
|
@ -414,12 +408,7 @@ void Emoticons::showStickerWidget(QWidget *parent, QWidget *button, const char *
|
||||||
} else {
|
} else {
|
||||||
firstpage = smTab->currentWidget();
|
firstpage = smTab->currentWidget();
|
||||||
}
|
}
|
||||||
QList<QPushButton *> children = firstpage->findChildren<QPushButton *>();
|
loadToolTips(firstpage);
|
||||||
for(int i = 0; i < children.length(); ++i) {
|
|
||||||
QString tooltip;
|
|
||||||
if(RsHtml::makeEmbeddedImage(children[i]->statusTip(), tooltip, 300*300))
|
|
||||||
children[i]->setToolTip(tooltip);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Get left up pos of button
|
//Get left up pos of button
|
||||||
QPoint butTopLeft = button->mapToGlobal(QPoint(0,0));
|
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->move(x, y);
|
||||||
smWidget->show();
|
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 showSmileyWidget(QWidget *parent, QWidget *button, const char *slotAddMethod, bool above);
|
||||||
static void showStickerWidget(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
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue