mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Support Animation Speed via Settings.
This is very userfull for a ( yet to be implemented ) preference dialog about the animation speed, so the user can enable / disable the animations or make it a bit faster for it's taste. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
466f160c01
commit
9f37bac07a
3 changed files with 19 additions and 11 deletions
|
@ -1,6 +1,7 @@
|
||||||
#include "animationfunctions.h"
|
#include "animationfunctions.h"
|
||||||
#include <QPropertyAnimation>
|
#include <QPropertyAnimation>
|
||||||
#include <QPointF>
|
#include <QPointF>
|
||||||
|
#include <QSettings>
|
||||||
|
|
||||||
namespace Animations
|
namespace Animations
|
||||||
{
|
{
|
||||||
|
@ -22,17 +23,24 @@ namespace Animations
|
||||||
animation->start(QAbstractAnimation::DeleteWhenStopped);
|
animation->start(QAbstractAnimation::DeleteWhenStopped);
|
||||||
}
|
}
|
||||||
|
|
||||||
void moveTo(QObject *obj, qreal x, qreal y, int msecs)
|
void moveTo(QObject *obj, qreal x, qreal y)
|
||||||
{
|
{
|
||||||
QPropertyAnimation *animation = new QPropertyAnimation(obj, "pos");
|
QSettings s;
|
||||||
animation->setDuration(msecs);
|
int msecs = s.value("animation_speed", 500).toInt();
|
||||||
animation->setStartValue(obj->property("pos").toPointF());
|
if (msecs != 0){
|
||||||
animation->setEndValue(QPointF(x, y));
|
QPropertyAnimation *animation = new QPropertyAnimation(obj, "pos");
|
||||||
animation->start(QAbstractAnimation::DeleteWhenStopped);
|
animation->setDuration(msecs);
|
||||||
|
animation->setStartValue(obj->property("pos").toPointF());
|
||||||
|
animation->setEndValue(QPointF(x, y));
|
||||||
|
animation->start(QAbstractAnimation::DeleteWhenStopped);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
obj->setProperty("pos", QPointF(x,y));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void moveTo(QObject *obj, const QPointF &pos, int msecs)
|
void moveTo(QObject *obj, const QPointF &pos)
|
||||||
{
|
{
|
||||||
moveTo(obj, pos.x(), pos.y(), msecs);
|
moveTo(obj, pos.x(), pos.y());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,8 +9,8 @@ class QObject;
|
||||||
namespace Animations
|
namespace Animations
|
||||||
{
|
{
|
||||||
void hide(QObject *obj);
|
void hide(QObject *obj);
|
||||||
void moveTo(QObject *obj, qreal x, qreal y, int msecs = 500);
|
void moveTo(QObject *obj, qreal x, qreal y);
|
||||||
void moveTo(QObject *obj, const QPointF &pos, int msecs = 500);
|
void moveTo(QObject *obj, const QPointF &pos);
|
||||||
void animDelete(QObject *obj);
|
void animDelete(QObject *obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -123,7 +123,7 @@ void DiveEventItem::recalculatePos(bool instant)
|
||||||
qreal x = hAxis->posAtValue(internalEvent->time.seconds);
|
qreal x = hAxis->posAtValue(internalEvent->time.seconds);
|
||||||
qreal y = vAxis->posAtValue(depth);
|
qreal y = vAxis->posAtValue(depth);
|
||||||
if (!instant)
|
if (!instant)
|
||||||
Animations::moveTo(this, x, y, 500);
|
Animations::moveTo(this, x, y);
|
||||||
else
|
else
|
||||||
setPos(x, y);
|
setPos(x, y);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue