animate hide of the focus indicator when a button is pressed
svn path=/trunk/KDE/kdelibs/; revision=1164481
This commit is contained in:
parent
4fdf87b54f
commit
bc6d40852b
@ -155,6 +155,18 @@ void FocusIndicator::resizeEvent(QGraphicsSceneResizeEvent *event)
|
|||||||
m_hoverAnimation->setProperty("targetPixmap", m_background->framePixmap());
|
m_hoverAnimation->setProperty("targetPixmap", m_background->framePixmap());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FocusIndicator::animateVisibility(const bool visible)
|
||||||
|
{
|
||||||
|
m_fade->setProperty("startOpacity", opacity());
|
||||||
|
|
||||||
|
if (visible) {
|
||||||
|
m_fade->setProperty("targetOpacity", 1.0);
|
||||||
|
} else {
|
||||||
|
m_fade->setProperty("targetOpacity", 0);
|
||||||
|
}
|
||||||
|
m_fade->start();
|
||||||
|
}
|
||||||
|
|
||||||
void FocusIndicator::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
void FocusIndicator::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||||
{
|
{
|
||||||
Q_UNUSED(option)
|
Q_UNUSED(option)
|
||||||
|
@ -39,6 +39,7 @@ public:
|
|||||||
void setCustomGeometry(const QRectF &geometry);
|
void setCustomGeometry(const QRectF &geometry);
|
||||||
void setCustomPrefix(const QString &prefix);
|
void setCustomPrefix(const QString &prefix);
|
||||||
|
|
||||||
|
void animateVisibility(const bool visible);
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -107,6 +107,15 @@ public:
|
|||||||
static_cast<KPushButton*>(q->widget())->setIcon(KIcon(pm));
|
static_cast<KPushButton*>(q->widget())->setIcon(KIcon(pm));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void pressedChanged()
|
||||||
|
{
|
||||||
|
if (q->nativeWidget()->isDown() || q->nativeWidget()->isChecked()) {
|
||||||
|
focusIndicator->animateVisibility(false);
|
||||||
|
} else {
|
||||||
|
focusIndicator->animateVisibility(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void syncActiveRect();
|
void syncActiveRect();
|
||||||
void syncBorders();
|
void syncBorders();
|
||||||
|
|
||||||
@ -119,6 +128,7 @@ public:
|
|||||||
|
|
||||||
Animation *hoverAnimation;
|
Animation *hoverAnimation;
|
||||||
|
|
||||||
|
FocusIndicator *focusIndicator;
|
||||||
QString imagePath;
|
QString imagePath;
|
||||||
QString absImagePath;
|
QString absImagePath;
|
||||||
Svg *svg;
|
Svg *svg;
|
||||||
@ -174,7 +184,9 @@ PushButton::PushButton(QGraphicsWidget *parent)
|
|||||||
|
|
||||||
KPushButton *native = new KPushButton;
|
KPushButton *native = new KPushButton;
|
||||||
connect(native, SIGNAL(pressed()), this, SIGNAL(pressed()));
|
connect(native, SIGNAL(pressed()), this, SIGNAL(pressed()));
|
||||||
|
connect(native, SIGNAL(pressed()), this, SLOT(pressedChanged()));
|
||||||
connect(native, SIGNAL(released()), this, SIGNAL(released()));
|
connect(native, SIGNAL(released()), this, SIGNAL(released()));
|
||||||
|
connect(native, SIGNAL(released()), this, SLOT(pressedChanged()));
|
||||||
connect(native, SIGNAL(clicked()), this, SIGNAL(clicked()));
|
connect(native, SIGNAL(clicked()), this, SIGNAL(clicked()));
|
||||||
connect(native, SIGNAL(toggled(bool)), this, SIGNAL(toggled(bool)));
|
connect(native, SIGNAL(toggled(bool)), this, SIGNAL(toggled(bool)));
|
||||||
setWidget(native);
|
setWidget(native);
|
||||||
@ -183,7 +195,7 @@ PushButton::PushButton(QGraphicsWidget *parent)
|
|||||||
|
|
||||||
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||||
|
|
||||||
FocusIndicator *focusIndicator = new FocusIndicator(this, "widgets/button");
|
d->focusIndicator = new FocusIndicator(this, "widgets/button");
|
||||||
|
|
||||||
d->syncBorders();
|
d->syncBorders();
|
||||||
setAcceptHoverEvents(true);
|
setAcceptHoverEvents(true);
|
||||||
|
@ -222,6 +222,7 @@ protected:
|
|||||||
private:
|
private:
|
||||||
Q_PRIVATE_SLOT(d, void syncBorders())
|
Q_PRIVATE_SLOT(d, void syncBorders())
|
||||||
Q_PRIVATE_SLOT(d, void setPixmap())
|
Q_PRIVATE_SLOT(d, void setPixmap())
|
||||||
|
Q_PRIVATE_SLOT(d, void pressedChanged())
|
||||||
|
|
||||||
friend class PushButtonPrivate;
|
friend class PushButtonPrivate;
|
||||||
PushButtonPrivate *const d;
|
PushButtonPrivate *const d;
|
||||||
|
Loading…
Reference in New Issue
Block a user