From a4c4aabfe5a7fd5daa0d10b6a92deeb68cc1e0d9 Mon Sep 17 00:00:00 2001 From: David Rosca Date: Sun, 11 Dec 2016 09:43:58 +0100 Subject: [PATCH] HistoryMenu: Load icons asynchronously See #1679 --- src/lib/history/historymenu.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/lib/history/historymenu.cpp b/src/lib/history/historymenu.cpp index 2db671544..dd73abe98 100644 --- a/src/lib/history/historymenu.cpp +++ b/src/lib/history/historymenu.cpp @@ -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 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()) {