mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
appitem: fix icon size error
Change-Id: I246218b915a906227f029233cef913266869a10a
This commit is contained in:
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
@ -44,7 +44,10 @@ AppItem::AppItem(const QDBusObjectPath &entry, QWidget *parent)
|
|||||||
m_verticalIndicator(QPixmap(":/indicator/resources/indicator_ver.png")),
|
m_verticalIndicator(QPixmap(":/indicator/resources/indicator_ver.png")),
|
||||||
m_activeHorizontalIndicator(QPixmap(":/indicator/resources/indicator_active.png")),
|
m_activeHorizontalIndicator(QPixmap(":/indicator/resources/indicator_active.png")),
|
||||||
m_activeVerticalIndicator(QPixmap(":/indicator/resources/indicator_active_ver.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;
|
QHBoxLayout *centralLayout = new QHBoxLayout;
|
||||||
centralLayout->addWidget(m_itemView);
|
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::requestHidePreview, this, &AppItem::hidePopup, Qt::QueuedConnection);
|
||||||
connect(m_appPreviewTips, &_PreviewContainer::requestCheckWindows, m_itemEntry, &DBusDockEntry::Check);
|
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, [=] {
|
QTimer::singleShot(1, this, [=] {
|
||||||
updateTitle();
|
updateTitle();
|
||||||
refershIcon();
|
refershIcon();
|
||||||
@ -486,25 +492,22 @@ void AppItem::refershIcon()
|
|||||||
const QString icon = m_itemEntry->icon();
|
const QString icon = m_itemEntry->icon();
|
||||||
const int iconSize = qMin(width(), height());
|
const int iconSize = qMin(width(), height());
|
||||||
|
|
||||||
QFutureWatcher<QPixmap> *smallWatcher = new QFutureWatcher<QPixmap>(this);
|
m_smallWatcher->cancel();
|
||||||
QFutureWatcher<QPixmap> *largeWatcher = new QFutureWatcher<QPixmap>(this);
|
m_largeWatcher->cancel();
|
||||||
|
|
||||||
if (DockDisplayMode == Efficient)
|
if (DockDisplayMode == Efficient)
|
||||||
{
|
{
|
||||||
// m_smallIcon = ThemeAppIcon::getIcon(icon, iconSize * 0.7);
|
// m_smallIcon = ThemeAppIcon::getIcon(icon, iconSize * 0.7);
|
||||||
// m_largeIcon = ThemeAppIcon::getIcon(icon, iconSize * 0.9);
|
// m_largeIcon = ThemeAppIcon::getIcon(icon, iconSize * 0.9);
|
||||||
smallWatcher->setFuture(QtConcurrent::run(ThemeAppIcon::getIcon, icon, iconSize * 0.7));
|
m_smallWatcher->setFuture(QtConcurrent::run(ThemeAppIcon::getIcon, icon, iconSize * 0.7));
|
||||||
largeWatcher->setFuture(QtConcurrent::run(ThemeAppIcon::getIcon, icon, iconSize * 0.9));
|
m_largeWatcher->setFuture(QtConcurrent::run(ThemeAppIcon::getIcon, icon, iconSize * 0.9));
|
||||||
} else {
|
} else {
|
||||||
// m_smallIcon = ThemeAppIcon::getIcon(icon, iconSize * 0.6);
|
// m_smallIcon = ThemeAppIcon::getIcon(icon, iconSize * 0.6);
|
||||||
// m_largeIcon = ThemeAppIcon::getIcon(icon, iconSize * 0.8);
|
// m_largeIcon = ThemeAppIcon::getIcon(icon, iconSize * 0.8);
|
||||||
smallWatcher->setFuture(QtConcurrent::run(ThemeAppIcon::getIcon, icon, iconSize * 0.6));
|
m_smallWatcher->setFuture(QtConcurrent::run(ThemeAppIcon::getIcon, icon, iconSize * 0.6));
|
||||||
largeWatcher->setFuture(QtConcurrent::run(ThemeAppIcon::getIcon, icon, iconSize * 0.8));
|
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();
|
m_updateIconGeometryTimer->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -540,24 +543,14 @@ void AppItem::showPreview()
|
|||||||
|
|
||||||
void AppItem::gotSmallIcon()
|
void AppItem::gotSmallIcon()
|
||||||
{
|
{
|
||||||
QFutureWatcher<QPixmap> *fw = dynamic_cast<QFutureWatcher<QPixmap> *>(sender());
|
m_smallIcon = m_smallWatcher->result();
|
||||||
Q_ASSERT(fw);
|
|
||||||
|
|
||||||
m_smallIcon = fw->result();
|
|
||||||
|
|
||||||
fw->deleteLater();
|
|
||||||
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppItem::gotLargeIcon()
|
void AppItem::gotLargeIcon()
|
||||||
{
|
{
|
||||||
QFutureWatcher<QPixmap> *fw = dynamic_cast<QFutureWatcher<QPixmap> *>(sender());
|
m_largeIcon = m_largeWatcher->result();
|
||||||
Q_ASSERT(fw);
|
|
||||||
|
|
||||||
m_largeIcon = fw->result();
|
|
||||||
|
|
||||||
fw->deleteLater();
|
|
||||||
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
@ -81,6 +81,9 @@ private:
|
|||||||
|
|
||||||
QTimer *m_updateIconGeometryTimer;
|
QTimer *m_updateIconGeometryTimer;
|
||||||
|
|
||||||
|
QFutureWatcher<QPixmap> *m_smallWatcher;
|
||||||
|
QFutureWatcher<QPixmap> *m_largeWatcher;
|
||||||
|
|
||||||
static int IconBaseSize;
|
static int IconBaseSize;
|
||||||
static QPoint MousePressPos;
|
static QPoint MousePressPos;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user