1
mirror of https://invent.kde.org/network/falkon.git synced 2024-09-21 17:52:10 +02:00

HistoryMenu: Load icons asynchronously

See #1679
This commit is contained in:
David Rosca 2016-12-11 09:43:58 +01:00
parent d6ff977282
commit a4c4aabfe5

View File

@ -97,12 +97,16 @@ void HistoryMenu::aboutToShow()
const QUrl url = query.value(1).toUrl();
const QString title = QzTools::truncatedText(query.value(0).toString(), 40);
Action* act = new Action(IconProvider::iconForUrl(url), title);
Action* act = new Action(title);
act->setData(url);
connect(act, SIGNAL(triggered()), this, SLOT(historyEntryActivated()));
connect(act, SIGNAL(ctrlTriggered()), this, SLOT(historyEntryCtrlActivated()));
connect(act, SIGNAL(shiftTriggered()), this, SLOT(historyEntryShiftActivated()));
addAction(act);
IconProvider::imageForUrlAsync(url, act, [=](const QImage &img) {
act->setIcon(QIcon(QPixmap::fromImage(img)));
});
}
}
@ -120,12 +124,16 @@ void HistoryMenu::aboutToShowMostVisited()
const QVector<HistoryEntry> mostVisited = mApp->history()->mostVisited(10);
foreach (const HistoryEntry &entry, mostVisited) {
Action* act = new Action(IconProvider::iconForUrl(entry.url), QzTools::truncatedText(entry.title, 40));
Action* act = new Action(QzTools::truncatedText(entry.title, 40));
act->setData(entry.url);
connect(act, SIGNAL(triggered()), this, SLOT(historyEntryActivated()));
connect(act, SIGNAL(ctrlTriggered()), this, SLOT(historyEntryCtrlActivated()));
connect(act, SIGNAL(shiftTriggered()), this, SLOT(historyEntryShiftActivated()));
m_menuMostVisited->addAction(act);
IconProvider::imageForUrlAsync(entry.url, act, [=](const QImage &img) {
act->setIcon(QIcon(QPixmap::fromImage(img)));
});
}
if (m_menuMostVisited->isEmpty()) {