Fix handle possibly moving to the other side if the cursor exist for a short time.
Remove the handle if the cursor goes away before we even appear, previously the handle was kept invisible until the cursor next entered. svn path=/trunk/KDE/kdelibs/; revision=929233
This commit is contained in:
parent
8fbb555bbd
commit
205a1700b2
@ -105,7 +105,7 @@ AppletHandle::AppletHandle(Containment *parent, Applet *applet, const QPointF &h
|
|||||||
m_leaveTimer->setSingleShot(true);
|
m_leaveTimer->setSingleShot(true);
|
||||||
m_leaveTimer->setInterval(500);
|
m_leaveTimer->setInterval(500);
|
||||||
|
|
||||||
connect(m_hoverTimer, SIGNAL(timeout()), this, SLOT(fadeIn()));
|
connect(m_hoverTimer, SIGNAL(timeout()), this, SLOT(hoverTimeout()));
|
||||||
connect(m_leaveTimer, SIGNAL(timeout()), this, SLOT(leaveTimeout()));
|
connect(m_leaveTimer, SIGNAL(timeout()), this, SLOT(leaveTimeout()));
|
||||||
connect(m_applet, SIGNAL(destroyed(QObject*)), this, SLOT(appletDestroyed()));
|
connect(m_applet, SIGNAL(destroyed(QObject*)), this, SLOT(appletDestroyed()));
|
||||||
|
|
||||||
@ -148,7 +148,7 @@ void AppletHandle::detachApplet ()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
disconnect(m_hoverTimer, SIGNAL(timeout()), this, SLOT(fadeIn()));
|
disconnect(m_hoverTimer, SIGNAL(timeout()), this, SLOT(hoverTimeout()));
|
||||||
disconnect(m_leaveTimer, SIGNAL(timeout()), this, SLOT(leaveTimeout()));
|
disconnect(m_leaveTimer, SIGNAL(timeout()), this, SLOT(leaveTimeout()));
|
||||||
m_applet->disconnect(this);
|
m_applet->disconnect(this);
|
||||||
|
|
||||||
@ -772,29 +772,29 @@ void AppletHandle::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
|||||||
//kDebug() << "hover enter";
|
//kDebug() << "hover enter";
|
||||||
|
|
||||||
//if a disappear was scheduled stop the timer
|
//if a disappear was scheduled stop the timer
|
||||||
|
if (m_leaveTimer->isActive()) {
|
||||||
m_leaveTimer->stop();
|
m_leaveTimer->stop();
|
||||||
|
}
|
||||||
// if we're already fading out, fade back in
|
// if we're already fading out, fade back in
|
||||||
if (m_animId != 0 && m_anim == FadeOut) {
|
else if (m_animId != 0 && m_anim == FadeOut) {
|
||||||
startFading(FadeIn, m_entryPos);
|
startFading(FadeIn, m_entryPos, true);
|
||||||
} else {
|
|
||||||
//schedule appear
|
|
||||||
m_hoverTimer->start();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppletHandle::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
|
void AppletHandle::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(event);
|
hoverEnterEvent(event);
|
||||||
m_leaveTimer->stop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppletHandle::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
void AppletHandle::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(event);
|
Q_UNUSED(event);
|
||||||
m_hoverTimer->stop();
|
|
||||||
|
|
||||||
if (m_pressedButton != NoButton) {
|
// if we haven't even showed up yet, remove the handle
|
||||||
|
if (m_hoverTimer->isActive()) {
|
||||||
|
m_hoverTimer->stop();
|
||||||
|
QTimer::singleShot(0, this, SLOT(emitDisappear()));
|
||||||
|
} else if (m_pressedButton != NoButton) {
|
||||||
m_pendingFade = true;
|
m_pendingFade = true;
|
||||||
} else {
|
} else {
|
||||||
//wait a moment to hide the handle in order to recheck the mouse position
|
//wait a moment to hide the handle in order to recheck the mouse position
|
||||||
@ -830,7 +830,7 @@ void AppletHandle::fadeAnimation(qreal progress)
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppletHandle::fadeIn()
|
void AppletHandle::hoverTimeout()
|
||||||
{
|
{
|
||||||
startFading(FadeIn, m_entryPos);
|
startFading(FadeIn, m_entryPos);
|
||||||
}
|
}
|
||||||
@ -857,20 +857,16 @@ void AppletHandle::setHoverPos(const QPointF &hoverPos)
|
|||||||
m_entryPos = hoverPos;
|
m_entryPos = hoverPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppletHandle::startFading(FadeType anim, const QPointF &hoverPos)
|
void AppletHandle::startFading(FadeType anim, const QPointF &hoverPos, bool preserveSide)
|
||||||
{
|
{
|
||||||
if (m_animId != 0) {
|
if (m_animId != 0) {
|
||||||
Animator::self()->stopCustomAnimation(m_animId);
|
Animator::self()->stopCustomAnimation(m_animId);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_hoverTimer->stop();
|
|
||||||
m_leaveTimer->stop();
|
|
||||||
|
|
||||||
m_entryPos = hoverPos;
|
m_entryPos = hoverPos;
|
||||||
qreal time = 100;
|
qreal time = 100;
|
||||||
|
|
||||||
if (!m_applet || (anim == FadeOut && m_hoverTimer->isActive())) {
|
if (!m_applet) {
|
||||||
// fading out before we've started fading in
|
|
||||||
m_anim = FadeOut;
|
m_anim = FadeOut;
|
||||||
fadeAnimation(1.0);
|
fadeAnimation(1.0);
|
||||||
return;
|
return;
|
||||||
@ -880,7 +876,9 @@ void AppletHandle::startFading(FadeType anim, const QPointF &hoverPos)
|
|||||||
//kDebug() << m_entryPos.x() << m_applet->pos().x();
|
//kDebug() << m_entryPos.x() << m_applet->pos().x();
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
bool wasOnRight = m_buttonsOnRight;
|
bool wasOnRight = m_buttonsOnRight;
|
||||||
|
if (!preserveSide) {
|
||||||
m_buttonsOnRight = m_entryPos.x() > (m_applet->size().width() / 2);
|
m_buttonsOnRight = m_entryPos.x() > (m_applet->size().width() / 2);
|
||||||
|
}
|
||||||
calculateSize();
|
calculateSize();
|
||||||
QPolygonF region = mapToParent(m_rect).intersected(parentWidget()->boundingRect());
|
QPolygonF region = mapToParent(m_rect).intersected(parentWidget()->boundingRect());
|
||||||
//kDebug() << region << m_rect << mapToParent(m_rect) << parentWidget()->boundingRect();
|
//kDebug() << region << m_rect << mapToParent(m_rect) << parentWidget()->boundingRect();
|
||||||
|
@ -63,7 +63,7 @@ class AppletHandle : public QObject, public QGraphicsItem
|
|||||||
QRectF boundingRect() const;
|
QRectF boundingRect() const;
|
||||||
QPainterPath shape() const;
|
QPainterPath shape() const;
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
|
||||||
void startFading(FadeType anim, const QPointF &hoverPos);
|
void startFading(FadeType anim, const QPointF &hoverPos, bool preserveSide = false);
|
||||||
void setHoverPos(const QPointF &hoverPos);
|
void setHoverPos(const QPointF &hoverPos);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -83,7 +83,7 @@ class AppletHandle : public QObject, public QGraphicsItem
|
|||||||
void fadeAnimation(qreal progress);
|
void fadeAnimation(qreal progress);
|
||||||
void appletDestroyed();
|
void appletDestroyed();
|
||||||
void appletResized();
|
void appletResized();
|
||||||
void fadeIn();
|
void hoverTimeout();
|
||||||
void leaveTimeout();
|
void leaveTimeout();
|
||||||
void emitDisappear();
|
void emitDisappear();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user