Calculate initial m_angle, simplify _k_rotatePoint
svn path=/trunk/KDE/kdelibs/; revision=1059568
This commit is contained in:
parent
d1a3aef87a
commit
4325dd1e40
@ -62,7 +62,6 @@ AppletHandle::AppletHandle(Containment *parent, Applet *applet, const QPointF &h
|
|||||||
m_opacity(0.0),
|
m_opacity(0.0),
|
||||||
m_anim(FadeIn),
|
m_anim(FadeIn),
|
||||||
m_animId(0),
|
m_animId(0),
|
||||||
m_angle(0.0),
|
|
||||||
m_backgroundBuffer(0),
|
m_backgroundBuffer(0),
|
||||||
m_currentView(applet->view()),
|
m_currentView(applet->view()),
|
||||||
m_entryPos(hoverPos),
|
m_entryPos(hoverPos),
|
||||||
@ -77,6 +76,9 @@ AppletHandle::AppletHandle(Containment *parent, Applet *applet, const QPointF &h
|
|||||||
m_originalGeom = m_applet->geometry();
|
m_originalGeom = m_applet->geometry();
|
||||||
m_originalTransform = m_applet->transform();
|
m_originalTransform = m_applet->transform();
|
||||||
|
|
||||||
|
QPointF center = QRectF(QPointF(), m_applet->size()).center();
|
||||||
|
m_angle = _k_pointAngle(m_originalTransform.map(center + QPointF(1.0, 0.0)) - center);
|
||||||
|
|
||||||
m_hoverTimer = new QTimer(this);
|
m_hoverTimer = new QTimer(this);
|
||||||
m_hoverTimer->setSingleShot(true);
|
m_hoverTimer->setSingleShot(true);
|
||||||
m_hoverTimer->setInterval(333);
|
m_hoverTimer->setInterval(333);
|
||||||
@ -571,25 +573,9 @@ qreal _k_pointAngle(QPointF in)
|
|||||||
|
|
||||||
QPointF _k_rotatePoint(QPointF in, qreal rotateAngle)
|
QPointF _k_rotatePoint(QPointF in, qreal rotateAngle)
|
||||||
{
|
{
|
||||||
// if the point is 0, 0 it should always be the same even if rotated
|
QTransform trans;
|
||||||
// without this the function would return a NaN
|
trans.rotateRadians(rotateAngle);
|
||||||
if (in == QPointF(0, 0)) {
|
return trans.map(in);
|
||||||
return in;
|
|
||||||
}
|
|
||||||
|
|
||||||
qreal r = sqrt(in.x()*in.x() + in.y()*in.y());
|
|
||||||
qreal cosine = in.x()/r;
|
|
||||||
qreal sine = in.y()/r;
|
|
||||||
|
|
||||||
qreal angle;
|
|
||||||
if (sine>=0) {
|
|
||||||
angle = acos(cosine);
|
|
||||||
} else {
|
|
||||||
angle = -acos(cosine);
|
|
||||||
}
|
|
||||||
|
|
||||||
qreal newAngle = angle + rotateAngle;
|
|
||||||
return QPointF(r*cos(newAngle), r*sin(newAngle));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppletHandle::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
void AppletHandle::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
Loading…
Reference in New Issue
Block a user