store the under mouse value, avoids a sync cursor position call

svn path=/trunk/KDE/kdelibs/; revision=1127792
This commit is contained in:
Marco Martin 2010-05-17 16:35:27 +00:00
parent d6c0119d69
commit 610b3c85df
2 changed files with 6 additions and 2 deletions

View File

@ -34,7 +34,8 @@ namespace Plasma
FocusIndicator::FocusIndicator(QGraphicsWidget *parent, QString widget) FocusIndicator::FocusIndicator(QGraphicsWidget *parent, QString widget)
: QGraphicsWidget(parent), : QGraphicsWidget(parent),
m_parent(parent), m_parent(parent),
m_background(0) m_background(0),
m_isUnderMouse(false)
{ {
setFlag(QGraphicsItem::ItemStacksBehindParent); setFlag(QGraphicsItem::ItemStacksBehindParent);
setAcceptsHoverEvents(true); setAcceptsHoverEvents(true);
@ -95,6 +96,7 @@ bool FocusIndicator::eventFilter(QObject *watched, QEvent *event)
m_hoverAnimation->setProperty("startPixmap", m_background->framePixmap()); m_hoverAnimation->setProperty("startPixmap", m_background->framePixmap());
m_background->setElementPrefix("hover"); m_background->setElementPrefix("hover");
m_hoverAnimation->setProperty("targetPixmap", m_background->framePixmap()); m_hoverAnimation->setProperty("targetPixmap", m_background->framePixmap());
m_isUnderMouse = true;
m_hoverAnimation->start(); m_hoverAnimation->start();
} else if (!m_parent->hasFocus() && event->type() == QEvent::GraphicsSceneHoverLeave) { } else if (!m_parent->hasFocus() && event->type() == QEvent::GraphicsSceneHoverLeave) {
m_prefix = m_customPrefix + "shadow"; m_prefix = m_customPrefix + "shadow";
@ -104,6 +106,7 @@ bool FocusIndicator::eventFilter(QObject *watched, QEvent *event)
m_hoverAnimation->setProperty("startPixmap", m_background->framePixmap()); m_hoverAnimation->setProperty("startPixmap", m_background->framePixmap());
m_background->setElementPrefix("shadow"); m_background->setElementPrefix("shadow");
m_hoverAnimation->setProperty("targetPixmap", m_background->framePixmap()); m_hoverAnimation->setProperty("targetPixmap", m_background->framePixmap());
m_isUnderMouse = false;
m_hoverAnimation->start(); m_hoverAnimation->start();
} else if (event->type() == QEvent::GraphicsSceneResize) { } else if (event->type() == QEvent::GraphicsSceneResize) {
syncGeometry(); syncGeometry();
@ -115,7 +118,7 @@ bool FocusIndicator::eventFilter(QObject *watched, QEvent *event)
m_background->setElementPrefix("focus"); m_background->setElementPrefix("focus");
m_hoverAnimation->setProperty("targetPixmap", m_background->framePixmap()); m_hoverAnimation->setProperty("targetPixmap", m_background->framePixmap());
m_hoverAnimation->start(); m_hoverAnimation->start();
} else if (!m_parent->isUnderMouse() && event->type() == QEvent::FocusOut) { } else if (!m_isUnderMouse && event->type() == QEvent::FocusOut) {
m_prefix = m_customPrefix + "shadow"; m_prefix = m_customPrefix + "shadow";
syncGeometry(); syncGeometry();
m_hoverAnimation->stop(); m_hoverAnimation->stop();

View File

@ -56,6 +56,7 @@ private:
QRectF m_customGeometry; QRectF m_customGeometry;
QString m_prefix; QString m_prefix;
QString m_customPrefix; QString m_customPrefix;
bool m_isUnderMouse;
}; };
} }
#endif #endif