avoid some unecesary calls, write an if as a switch
svn path=/trunk/KDE/kdelibs/; revision=1178749
This commit is contained in:
parent
6e14d1c773
commit
4946385727
@ -121,82 +121,107 @@ bool FocusIndicator::eventFilter(QObject *watched, QEvent *event)
|
|||||||
m_isUnderMouse = false;
|
m_isUnderMouse = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_parent->hasFocus() && event->type() == QEvent::GraphicsSceneHoverEnter) {
|
switch (event->type()) {
|
||||||
m_prefix = m_customPrefix % "hover";
|
case QEvent::GraphicsSceneHoverEnter:
|
||||||
syncGeometry();
|
if (!m_parent->hasFocus()) {
|
||||||
m_hoverAnimation->stop();
|
m_prefix = m_customPrefix % "hover";
|
||||||
if (m_background->hasElementPrefix(m_testPrefix)) {
|
syncGeometry();
|
||||||
m_background->setElementPrefix(m_customPrefix % "shadow");
|
m_hoverAnimation->stop();
|
||||||
m_hoverAnimation->setProperty("startPixmap", m_background->framePixmap());
|
if (m_background->hasElementPrefix(m_testPrefix)) {
|
||||||
m_background->setElementPrefix(m_customPrefix % "hover");
|
m_background->setElementPrefix(m_customPrefix % "shadow");
|
||||||
m_hoverAnimation->setProperty("targetPixmap", m_background->framePixmap());
|
m_hoverAnimation->setProperty("startPixmap", m_background->framePixmap());
|
||||||
} else if (m_background->hasElement(m_testPrefix)) {
|
m_background->setElementPrefix(m_customPrefix % "hover");
|
||||||
m_hoverAnimation->setProperty("startPixmap", m_background->pixmap(m_customPrefix % "shadow"));
|
m_hoverAnimation->setProperty("targetPixmap", m_background->framePixmap());
|
||||||
m_hoverAnimation->setProperty("targetPixmap", m_background->pixmap(m_customPrefix % "hover"));
|
} else if (m_background->hasElement(m_testPrefix)) {
|
||||||
}
|
m_hoverAnimation->setProperty("startPixmap", m_background->pixmap(m_customPrefix % "shadow"));
|
||||||
|
m_hoverAnimation->setProperty("targetPixmap", m_background->pixmap(m_customPrefix % "hover"));
|
||||||
|
}
|
||||||
|
|
||||||
m_hoverAnimation->start();
|
m_hoverAnimation->start();
|
||||||
} else if (!m_parent->hasFocus() && event->type() == QEvent::GraphicsSceneHoverLeave) {
|
}
|
||||||
m_prefix = m_customPrefix % "shadow";
|
break;
|
||||||
syncGeometry();
|
|
||||||
m_hoverAnimation->stop();
|
|
||||||
|
|
||||||
if (m_background->hasElementPrefix(m_testPrefix)) {
|
case QEvent::GraphicsSceneHoverLeave:
|
||||||
m_background->setElementPrefix(m_customPrefix % "hover");
|
if (!m_parent->hasFocus()) {
|
||||||
m_hoverAnimation->setProperty("startPixmap", m_background->framePixmap());
|
m_prefix = m_customPrefix % "shadow";
|
||||||
m_background->setElementPrefix(m_customPrefix % "shadow");
|
syncGeometry();
|
||||||
m_hoverAnimation->setProperty("targetPixmap", m_background->framePixmap());
|
m_hoverAnimation->stop();
|
||||||
} else if (m_background->hasElement(m_testPrefix)) {
|
|
||||||
m_hoverAnimation->setProperty("startPixmap", m_background->pixmap(m_customPrefix % "hover"));
|
|
||||||
m_hoverAnimation->setProperty("targetPixmap", m_background->pixmap(m_customPrefix % "shadow"));
|
|
||||||
}
|
|
||||||
m_hoverAnimation->start();
|
|
||||||
} else if (event->type() == QEvent::GraphicsSceneResize) {
|
|
||||||
syncGeometry();
|
|
||||||
} else if (event->type() == QEvent::FocusIn) {
|
|
||||||
m_prefix = m_customPrefix % "focus";
|
|
||||||
syncGeometry();
|
|
||||||
m_hoverAnimation->stop();
|
|
||||||
|
|
||||||
if (m_background->hasElementPrefix(m_customPrefix % "focus")) {
|
if (m_background->hasElementPrefix(m_testPrefix)) {
|
||||||
//m_background->setElementPrefix(m_customPrefix % "shadow");
|
m_background->setElementPrefix(m_customPrefix % "hover");
|
||||||
m_hoverAnimation->setProperty("startPixmap", m_background->framePixmap());
|
m_hoverAnimation->setProperty("startPixmap", m_background->framePixmap());
|
||||||
m_background->setElementPrefix(m_customPrefix % "focus");
|
m_background->setElementPrefix(m_customPrefix % "shadow");
|
||||||
m_hoverAnimation->setProperty("targetPixmap", m_background->framePixmap());
|
m_hoverAnimation->setProperty("targetPixmap", m_background->framePixmap());
|
||||||
} else if (m_background->hasElement(m_customPrefix % "focus")) {
|
} else if (m_background->hasElement(m_testPrefix)) {
|
||||||
//m_hoverAnimation->setProperty("startPixmap", m_background->pixmap(m_customPrefix % "shadow"));
|
m_hoverAnimation->setProperty("startPixmap", m_background->pixmap(m_customPrefix % "hover"));
|
||||||
m_hoverAnimation->setProperty("targetPixmap", m_background->pixmap(m_customPrefix % "focus"));
|
m_hoverAnimation->setProperty("targetPixmap", m_background->pixmap(m_customPrefix % "shadow"));
|
||||||
}
|
}
|
||||||
|
m_hoverAnimation->start();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
m_hoverAnimation->start();
|
case QEvent::GraphicsSceneResize:
|
||||||
} else if (!m_isUnderMouse && event->type() == QEvent::FocusOut) {
|
syncGeometry();
|
||||||
m_prefix = m_customPrefix % "shadow";
|
break;
|
||||||
syncGeometry();
|
|
||||||
m_hoverAnimation->stop();
|
|
||||||
|
|
||||||
if (m_background->hasElementPrefix(m_customPrefix % "focus")) {
|
case QEvent::FocusIn:
|
||||||
m_background->setElementPrefix("focus");
|
m_prefix = m_customPrefix % "focus";
|
||||||
m_hoverAnimation->setProperty("startPixmap", m_background->framePixmap());
|
syncGeometry();
|
||||||
m_background->setElementPrefix("shadow");
|
m_hoverAnimation->stop();
|
||||||
m_hoverAnimation->setProperty("targetPixmap", m_background->framePixmap());
|
|
||||||
} else if (m_background->hasElement(m_customPrefix % "focus")) {
|
|
||||||
m_hoverAnimation->setProperty("startPixmap", m_background->pixmap(m_customPrefix % "focus"));
|
|
||||||
m_hoverAnimation->setProperty("targetPixmap", m_background->pixmap(m_customPrefix % "shadow"));
|
|
||||||
}
|
|
||||||
|
|
||||||
m_hoverAnimation->start();
|
if (m_background->hasElementPrefix(m_customPrefix % "focus")) {
|
||||||
}
|
//m_background->setElementPrefix(m_customPrefix % "shadow");
|
||||||
|
m_hoverAnimation->setProperty("startPixmap", m_background->framePixmap());
|
||||||
|
m_background->setElementPrefix(m_customPrefix % "focus");
|
||||||
|
m_hoverAnimation->setProperty("targetPixmap", m_background->framePixmap());
|
||||||
|
} else if (m_background->hasElement(m_customPrefix % "focus")) {
|
||||||
|
//m_hoverAnimation->setProperty("startPixmap", m_background->pixmap(m_customPrefix % "shadow"));
|
||||||
|
m_hoverAnimation->setProperty("targetPixmap", m_background->pixmap(m_customPrefix % "focus"));
|
||||||
|
}
|
||||||
|
|
||||||
|
m_hoverAnimation->start();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case QEvent::FocusOut:
|
||||||
|
if (!m_isUnderMouse) {
|
||||||
|
m_prefix = m_customPrefix % "shadow";
|
||||||
|
syncGeometry();
|
||||||
|
m_hoverAnimation->stop();
|
||||||
|
|
||||||
|
if (m_background->hasElementPrefix(m_customPrefix % "focus")) {
|
||||||
|
m_background->setElementPrefix("focus");
|
||||||
|
m_hoverAnimation->setProperty("startPixmap", m_background->framePixmap());
|
||||||
|
m_background->setElementPrefix("shadow");
|
||||||
|
m_hoverAnimation->setProperty("targetPixmap", m_background->framePixmap());
|
||||||
|
} else if (m_background->hasElement(m_customPrefix % "focus")) {
|
||||||
|
m_hoverAnimation->setProperty("startPixmap", m_background->pixmap(m_customPrefix % "focus"));
|
||||||
|
m_hoverAnimation->setProperty("targetPixmap", m_background->pixmap(m_customPrefix % "shadow"));
|
||||||
|
}
|
||||||
|
|
||||||
|
m_hoverAnimation->start();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FocusIndicator::resizeEvent(QGraphicsSceneResizeEvent *)
|
void FocusIndicator::resizeEvent(QGraphicsSceneResizeEvent *)
|
||||||
{
|
{
|
||||||
if (m_background->hasElementPrefix(m_testPrefix)) {
|
if (m_background->hasElementPrefix(m_customPrefix % "shadow")) {
|
||||||
m_background->setElementPrefix(m_customPrefix % "shadow");
|
m_background->setElementPrefix(m_customPrefix % "shadow");
|
||||||
m_background->resizeFrame(size());
|
m_background->resizeFrame(size());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_background->hasElementPrefix(m_customPrefix % "hover")) {
|
||||||
m_background->setElementPrefix(m_customPrefix % "hover");
|
m_background->setElementPrefix(m_customPrefix % "hover");
|
||||||
m_background->resizeFrame(size());
|
m_background->resizeFrame(size());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_background->hasElementPrefix(m_customPrefix % "focus")) {
|
||||||
m_background->setElementPrefix(m_customPrefix % "focus");
|
m_background->setElementPrefix(m_customPrefix % "focus");
|
||||||
m_background->resizeFrame(size());
|
m_background->resizeFrame(size());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user