mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
optimize startup animation, fix coordinate error
Change-Id: Ia110a482bd18447b664dab45ae55ad51c66b4e4f
This commit is contained in:
parent
73e8e56c1a
commit
777291c812
Notes:
Deepin Code Review
2017-05-02 16:35:22 +08:00
Code-Review+2: 石博文 <sbw@sbw.so> Verified+1: 石博文 <sbw@sbw.so> Submitted-by: 石博文 <sbw@sbw.so> Submitted-at: Tue, 02 May 2017 16:35:17 +0800 Reviewed-on: https://cr.deepin.io/22740 Project: dde/dde-dock Branch: refs/heads/master
@ -39,14 +39,17 @@ AppItem::AppItem(const QDBusObjectPath &entry, QWidget *parent)
|
|||||||
QHBoxLayout *centralLayout = new QHBoxLayout;
|
QHBoxLayout *centralLayout = new QHBoxLayout;
|
||||||
centralLayout->addWidget(m_itemView);
|
centralLayout->addWidget(m_itemView);
|
||||||
centralLayout->setMargin(0);
|
centralLayout->setMargin(0);
|
||||||
|
centralLayout->setSpacing(0);
|
||||||
|
|
||||||
setAccessibleName(m_itemEntry->name());
|
setAccessibleName(m_itemEntry->name());
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
setLayout(centralLayout);
|
setLayout(centralLayout);
|
||||||
|
|
||||||
m_itemView->setScene(m_itemScene);
|
m_itemView->setScene(m_itemScene);
|
||||||
|
m_itemView->setAlignment(Qt::AlignCenter);
|
||||||
m_itemView->setVisible(false);
|
m_itemView->setVisible(false);
|
||||||
m_itemView->setFrameStyle(QFrame::NoFrame);
|
m_itemView->setFrameStyle(QFrame::NoFrame);
|
||||||
|
m_itemView->setContentsMargins(0, 0, 0, 0);
|
||||||
m_itemView->setRenderHints(QPainter::SmoothPixmapTransform);
|
m_itemView->setRenderHints(QPainter::SmoothPixmapTransform);
|
||||||
m_itemView->setViewportUpdateMode(QGraphicsView::SmartViewportUpdate);
|
m_itemView->setViewportUpdateMode(QGraphicsView::SmartViewportUpdate);
|
||||||
m_itemView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
m_itemView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
@ -149,10 +152,10 @@ void AppItem::paintEvent(QPaintEvent *e)
|
|||||||
painter.setRenderHint(QPainter::Antialiasing, true);
|
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||||
painter.setRenderHint(QPainter::SmoothPixmapTransform, true);
|
painter.setRenderHint(QPainter::SmoothPixmapTransform, true);
|
||||||
|
|
||||||
const QRect itemRect = rect();
|
const QRectF itemRect = rect();
|
||||||
|
|
||||||
// draw background
|
// draw background
|
||||||
QRect backgroundRect = itemRect;
|
QRectF backgroundRect = itemRect;
|
||||||
if (DockDisplayMode == Efficient)
|
if (DockDisplayMode == Efficient)
|
||||||
{
|
{
|
||||||
switch (DockPosition)
|
switch (DockPosition)
|
||||||
@ -175,7 +178,7 @@ void AppItem::paintEvent(QPaintEvent *e)
|
|||||||
painter.fillRect(backgroundRect, QColor(44, 167, 248, 255 * 0.3));
|
painter.fillRect(backgroundRect, QColor(44, 167, 248, 255 * 0.3));
|
||||||
|
|
||||||
const int activeLineWidth = itemRect.height() > 50 ? 4 : 2;
|
const int activeLineWidth = itemRect.height() > 50 ? 4 : 2;
|
||||||
QRect activeRect = backgroundRect;
|
QRectF activeRect = backgroundRect;
|
||||||
switch (DockPosition)
|
switch (DockPosition)
|
||||||
{
|
{
|
||||||
case Top: activeRect.setBottom(activeRect.top() + activeLineWidth); break;
|
case Top: activeRect.setBottom(activeRect.top() + activeLineWidth); break;
|
||||||
@ -236,7 +239,7 @@ void AppItem::paintEvent(QPaintEvent *e)
|
|||||||
// icon
|
// icon
|
||||||
const QPixmap pixmap = DockDisplayMode == Efficient ? m_smallIcon : m_largeIcon;
|
const QPixmap pixmap = DockDisplayMode == Efficient ? m_smallIcon : m_largeIcon;
|
||||||
// icon pos
|
// icon pos
|
||||||
QPointF iconPos = itemRect.center() - pixmap.rect().center();
|
QPointF iconPos = itemRect.center() - QRectF(pixmap.rect()).center();
|
||||||
|
|
||||||
// draw ligher/normal icon
|
// draw ligher/normal icon
|
||||||
if (!m_hover)
|
if (!m_hover)
|
||||||
@ -260,12 +263,14 @@ void AppItem::mouseReleaseEvent(QMouseEvent *e)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// start launching effects
|
// start launching effects
|
||||||
const QPixmap icon = DockDisplayMode == Efficient ? m_smallIcon : m_largeIcon;
|
m_itemScene->clear();
|
||||||
const QRect r = rect();
|
const QRect r = rect();
|
||||||
|
const QPixmap icon = DockDisplayMode == Efficient ? m_smallIcon : m_largeIcon;
|
||||||
QGraphicsPixmapItem *item = m_itemScene->addPixmap(icon);
|
QGraphicsPixmapItem *item = m_itemScene->addPixmap(icon);
|
||||||
item->setPos(r.center() - QPoint(18, 18));
|
|
||||||
item->setTransformationMode(Qt::SmoothTransformation);
|
item->setTransformationMode(Qt::SmoothTransformation);
|
||||||
|
item->setPos(r.center() - icon.rect().center());
|
||||||
m_itemView->setSceneRect(r);
|
m_itemView->setSceneRect(r);
|
||||||
|
// m_itemView->setSceneRect((r.width() - icon.width()) / 2, (r.height() - icon.height()) / 2, r.width(), r.height());
|
||||||
|
|
||||||
QTimeLine *tl = new QTimeLine;
|
QTimeLine *tl = new QTimeLine;
|
||||||
tl->setDuration(1200);
|
tl->setDuration(1200);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user