aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2014-03-11 17:27:05 -0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-03-11 17:41:41 -0700
commit9f37bac07a06870bc3e5d1c150496ed347a4de99 (patch)
treeeca728536fdb97a9cced0eab2fcd182dc7cf3061
parent466f160c01127c1a2aad37742f53a9a0b97eb274 (diff)
downloadsubsurface-9f37bac07a06870bc3e5d1c150496ed347a4de99.tar.gz
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>
-rw-r--r--qt-ui/profile/animationfunctions.cpp24
-rw-r--r--qt-ui/profile/animationfunctions.h4
-rw-r--r--qt-ui/profile/diveeventitem.cpp2
3 files changed, 19 insertions, 11 deletions
diff --git a/qt-ui/profile/animationfunctions.cpp b/qt-ui/profile/animationfunctions.cpp
index 8cccf616e..608c4c000 100644
--- a/qt-ui/profile/animationfunctions.cpp
+++ b/qt-ui/profile/animationfunctions.cpp
@@ -1,6 +1,7 @@
#include "animationfunctions.h"
#include <QPropertyAnimation>
#include <QPointF>
+#include <QSettings>
namespace Animations
{
@@ -22,17 +23,24 @@ namespace Animations
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");
- animation->setDuration(msecs);
- animation->setStartValue(obj->property("pos").toPointF());
- animation->setEndValue(QPointF(x, y));
- animation->start(QAbstractAnimation::DeleteWhenStopped);
+ QSettings s;
+ int msecs = s.value("animation_speed", 500).toInt();
+ if (msecs != 0){
+ QPropertyAnimation *animation = new QPropertyAnimation(obj, "pos");
+ 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());
}
}
diff --git a/qt-ui/profile/animationfunctions.h b/qt-ui/profile/animationfunctions.h
index f6c93c7ae..e0338393e 100644
--- a/qt-ui/profile/animationfunctions.h
+++ b/qt-ui/profile/animationfunctions.h
@@ -9,8 +9,8 @@ class QObject;
namespace Animations
{
void hide(QObject *obj);
- void moveTo(QObject *obj, qreal x, qreal y, int msecs = 500);
- void moveTo(QObject *obj, const QPointF &pos, int msecs = 500);
+ void moveTo(QObject *obj, qreal x, qreal y);
+ void moveTo(QObject *obj, const QPointF &pos);
void animDelete(QObject *obj);
}
diff --git a/qt-ui/profile/diveeventitem.cpp b/qt-ui/profile/diveeventitem.cpp
index 40d9e7263..1fd4ef07a 100644
--- a/qt-ui/profile/diveeventitem.cpp
+++ b/qt-ui/profile/diveeventitem.cpp
@@ -123,7 +123,7 @@ void DiveEventItem::recalculatePos(bool instant)
qreal x = hAxis->posAtValue(internalEvent->time.seconds);
qreal y = vAxis->posAtValue(depth);
if (!instant)
- Animations::moveTo(this, x, y, 500);
+ Animations::moveTo(this, x, y);
else
setPos(x, y);
}