diff --git a/desktoptoolbox.cpp b/desktoptoolbox.cpp index f553d57eb..88c2b448d 100644 --- a/desktoptoolbox.cpp +++ b/desktoptoolbox.cpp @@ -39,6 +39,7 @@ static const int ToolName = 7001; DesktopToolbox::DesktopToolbox(QGraphicsItem *parent) : QGraphicsItem(parent), m_icon("plasma"), + m_iconSelected("plasma"), m_size(50), m_showing(false), m_animId(0), @@ -88,13 +89,25 @@ void DesktopToolbox::paint(QPainter *painter, const QStyleOptionGraphicsItem *op painter->setBrush(gradient); painter->drawPath(p); painter->restore(); - m_icon.paint(painter, QRect(m_size*2 - 34, 2, 32, 32)); + + const qreal progress = m_animFrame / m_size; + + if (progress > 0.1) { + m_iconSelected.paint(painter, QRect(m_size*2 - 34, 2, 32, 32), Qt::AlignCenter, QIcon::Disabled, QIcon::Off); + } + + if (progress < 0.95) { + painter->save(); + painter->setOpacity(1.0 - m_animFrame / m_size); + m_icon.paint(painter, QRect(m_size*2 - 34, 2, 32, 32)); + painter->restore(); + } } QPainterPath DesktopToolbox::shape() const { QPainterPath path; - int size = m_size + m_animFrame; + int size = m_size + (int)m_animFrame; path.moveTo(m_size*2, 0); path.arcTo(QRectF(m_size*2 - size, -size, size*2, size*2), 180, 90); return path; @@ -161,9 +174,9 @@ void DesktopToolbox::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) void DesktopToolbox::animate(qreal progress) { if (m_showing) { - m_animFrame = static_cast(m_size * progress); + m_animFrame = m_size * progress; } else { - m_animFrame = static_cast(m_size * (1.0 - progress)); + m_animFrame = m_size * (1.0 - progress); } //kDebug(1209) << "animating at" << progress << "for" << m_animFrame; diff --git a/desktoptoolbox_p.h b/desktoptoolbox_p.h index d27ef2155..5f57a6bb6 100644 --- a/desktoptoolbox_p.h +++ b/desktoptoolbox_p.h @@ -57,11 +57,12 @@ protected slots: private: KIcon m_icon; + KIcon m_iconSelected; int m_size; bool m_hidden; bool m_showing; Plasma::Phase::AnimId m_animId; - int m_animFrame; + qreal m_animFrame; }; } // Plasma namespace