appitem: fix icon size error

Change-Id: I246218b915a906227f029233cef913266869a10a
This commit is contained in:
石博文 2017-06-16 15:26:20 +08:00
parent 47be1507da
commit 71be6bfaf6
Notes: Deepin Code Review 2017-06-16 15:35:04 +08:00
Verified+1: Anonymous Coward #1000004
Code-Review+2: 石博文 <sbw@sbw.so>
Submitted-by: 石博文 <sbw@sbw.so>
Submitted-at: Fri, 16 Jun 2017 15:35:00 +0800
Reviewed-on: https://cr.deepin.io/23888
Project: dde/dde-dock
Branch: refs/heads/master
2 changed files with 18 additions and 22 deletions

View File

@ -44,7 +44,10 @@ AppItem::AppItem(const QDBusObjectPath &entry, QWidget *parent)
m_verticalIndicator(QPixmap(":/indicator/resources/indicator_ver.png")),
m_activeHorizontalIndicator(QPixmap(":/indicator/resources/indicator_active.png")),
m_activeVerticalIndicator(QPixmap(":/indicator/resources/indicator_active_ver.png")),
m_updateIconGeometryTimer(new QTimer(this))
m_updateIconGeometryTimer(new QTimer(this)),
m_smallWatcher(new QFutureWatcher<QPixmap>(this)),
m_largeWatcher(new QFutureWatcher<QPixmap>(this))
{
QHBoxLayout *centralLayout = new QHBoxLayout;
centralLayout->addWidget(m_itemView);
@ -93,6 +96,9 @@ AppItem::AppItem(const QDBusObjectPath &entry, QWidget *parent)
connect(m_appPreviewTips, &_PreviewContainer::requestHidePreview, this, &AppItem::hidePopup, Qt::QueuedConnection);
connect(m_appPreviewTips, &_PreviewContainer::requestCheckWindows, m_itemEntry, &DBusDockEntry::Check);
connect(m_smallWatcher, &QFutureWatcher<QPixmap>::finished, this, &AppItem::gotSmallIcon);
connect(m_largeWatcher, &QFutureWatcher<QPixmap>::finished, this, &AppItem::gotLargeIcon);
QTimer::singleShot(1, this, [=] {
updateTitle();
refershIcon();
@ -486,25 +492,22 @@ void AppItem::refershIcon()
const QString icon = m_itemEntry->icon();
const int iconSize = qMin(width(), height());
QFutureWatcher<QPixmap> *smallWatcher = new QFutureWatcher<QPixmap>(this);
QFutureWatcher<QPixmap> *largeWatcher = new QFutureWatcher<QPixmap>(this);
m_smallWatcher->cancel();
m_largeWatcher->cancel();
if (DockDisplayMode == Efficient)
{
// m_smallIcon = ThemeAppIcon::getIcon(icon, iconSize * 0.7);
// m_largeIcon = ThemeAppIcon::getIcon(icon, iconSize * 0.9);
smallWatcher->setFuture(QtConcurrent::run(ThemeAppIcon::getIcon, icon, iconSize * 0.7));
largeWatcher->setFuture(QtConcurrent::run(ThemeAppIcon::getIcon, icon, iconSize * 0.9));
m_smallWatcher->setFuture(QtConcurrent::run(ThemeAppIcon::getIcon, icon, iconSize * 0.7));
m_largeWatcher->setFuture(QtConcurrent::run(ThemeAppIcon::getIcon, icon, iconSize * 0.9));
} else {
// m_smallIcon = ThemeAppIcon::getIcon(icon, iconSize * 0.6);
// m_largeIcon = ThemeAppIcon::getIcon(icon, iconSize * 0.8);
smallWatcher->setFuture(QtConcurrent::run(ThemeAppIcon::getIcon, icon, iconSize * 0.6));
largeWatcher->setFuture(QtConcurrent::run(ThemeAppIcon::getIcon, icon, iconSize * 0.8));
m_smallWatcher->setFuture(QtConcurrent::run(ThemeAppIcon::getIcon, icon, iconSize * 0.6));
m_largeWatcher->setFuture(QtConcurrent::run(ThemeAppIcon::getIcon, icon, iconSize * 0.8));
}
connect(smallWatcher, &QFutureWatcher<QPixmap>::finished, this, &AppItem::gotSmallIcon);
connect(largeWatcher, &QFutureWatcher<QPixmap>::finished, this, &AppItem::gotLargeIcon);
m_updateIconGeometryTimer->start();
}
@ -540,24 +543,14 @@ void AppItem::showPreview()
void AppItem::gotSmallIcon()
{
QFutureWatcher<QPixmap> *fw = dynamic_cast<QFutureWatcher<QPixmap> *>(sender());
Q_ASSERT(fw);
m_smallIcon = fw->result();
fw->deleteLater();
m_smallIcon = m_smallWatcher->result();
update();
}
void AppItem::gotLargeIcon()
{
QFutureWatcher<QPixmap> *fw = dynamic_cast<QFutureWatcher<QPixmap> *>(sender());
Q_ASSERT(fw);
m_largeIcon = fw->result();
fw->deleteLater();
m_largeIcon = m_largeWatcher->result();
update();
}

View File

@ -81,6 +81,9 @@ private:
QTimer *m_updateIconGeometryTimer;
QFutureWatcher<QPixmap> *m_smallWatcher;
QFutureWatcher<QPixmap> *m_largeWatcher;
static int IconBaseSize;
static QPoint MousePressPos;
};