toolbox's icon "fades" to gray when expanding
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=758449
This commit is contained in:
parent
12ef6308cb
commit
55d699dace
@ -39,6 +39,7 @@ static const int ToolName = 7001;
|
|||||||
DesktopToolbox::DesktopToolbox(QGraphicsItem *parent)
|
DesktopToolbox::DesktopToolbox(QGraphicsItem *parent)
|
||||||
: QGraphicsItem(parent),
|
: QGraphicsItem(parent),
|
||||||
m_icon("plasma"),
|
m_icon("plasma"),
|
||||||
|
m_iconSelected("plasma"),
|
||||||
m_size(50),
|
m_size(50),
|
||||||
m_showing(false),
|
m_showing(false),
|
||||||
m_animId(0),
|
m_animId(0),
|
||||||
@ -88,13 +89,25 @@ void DesktopToolbox::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
|
|||||||
painter->setBrush(gradient);
|
painter->setBrush(gradient);
|
||||||
painter->drawPath(p);
|
painter->drawPath(p);
|
||||||
painter->restore();
|
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 DesktopToolbox::shape() const
|
||||||
{
|
{
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
int size = m_size + m_animFrame;
|
int size = m_size + (int)m_animFrame;
|
||||||
path.moveTo(m_size*2, 0);
|
path.moveTo(m_size*2, 0);
|
||||||
path.arcTo(QRectF(m_size*2 - size, -size, size*2, size*2), 180, 90);
|
path.arcTo(QRectF(m_size*2 - size, -size, size*2, size*2), 180, 90);
|
||||||
return path;
|
return path;
|
||||||
@ -161,9 +174,9 @@ void DesktopToolbox::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
|||||||
void DesktopToolbox::animate(qreal progress)
|
void DesktopToolbox::animate(qreal progress)
|
||||||
{
|
{
|
||||||
if (m_showing) {
|
if (m_showing) {
|
||||||
m_animFrame = static_cast<int>(m_size * progress);
|
m_animFrame = m_size * progress;
|
||||||
} else {
|
} else {
|
||||||
m_animFrame = static_cast<int>(m_size * (1.0 - progress));
|
m_animFrame = m_size * (1.0 - progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
//kDebug(1209) << "animating at" << progress << "for" << m_animFrame;
|
//kDebug(1209) << "animating at" << progress << "for" << m_animFrame;
|
||||||
|
@ -57,11 +57,12 @@ protected slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
KIcon m_icon;
|
KIcon m_icon;
|
||||||
|
KIcon m_iconSelected;
|
||||||
int m_size;
|
int m_size;
|
||||||
bool m_hidden;
|
bool m_hidden;
|
||||||
bool m_showing;
|
bool m_showing;
|
||||||
Plasma::Phase::AnimId m_animId;
|
Plasma::Phase::AnimId m_animId;
|
||||||
int m_animFrame;
|
qreal m_animFrame;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // Plasma namespace
|
} // Plasma namespace
|
||||||
|
Loading…
x
Reference in New Issue
Block a user