diff options
-rw-r--r-- | profile-widget/animationfunctions.cpp | 25 | ||||
-rw-r--r-- | profile-widget/animationfunctions.h | 12 | ||||
-rw-r--r-- | profile-widget/divecartesianaxis.cpp | 19 | ||||
-rw-r--r-- | profile-widget/diveeventitem.cpp | 2 | ||||
-rw-r--r-- | profile-widget/divepixmapitem.cpp | 9 |
5 files changed, 34 insertions, 33 deletions
diff --git a/profile-widget/animationfunctions.cpp b/profile-widget/animationfunctions.cpp index 89779e3a8..a003e28ac 100644 --- a/profile-widget/animationfunctions.cpp +++ b/profile-widget/animationfunctions.cpp @@ -1,14 +1,13 @@ // SPDX-License-Identifier: GPL-2.0 #include "profile-widget/animationfunctions.h" #include "core/pref.h" -#include "core/settings/qPrefDisplay.h" #include <QPropertyAnimation> namespace Animations { - void hide(QObject *obj) + void hide(QObject *obj, int speed) { - if (qPrefDisplay::animation_speed() != 0) { + if (speed != 0) { QPropertyAnimation *animation = new QPropertyAnimation(obj, "opacity"); animation->setStartValue(1); animation->setEndValue(0); @@ -18,9 +17,9 @@ namespace Animations { } } - void show(QObject *obj) + void show(QObject *obj, int speed) { - if (qPrefDisplay::animation_speed() != 0) { + if (speed != 0) { QPropertyAnimation *animation = new QPropertyAnimation(obj, "opacity"); animation->setStartValue(0); animation->setEndValue(1); @@ -30,9 +29,9 @@ namespace Animations { } } - void animDelete(QObject *obj) + void animDelete(QObject *obj, int speed) { - if (qPrefDisplay::animation_speed() != 0) { + if (speed != 0) { QPropertyAnimation *animation = new QPropertyAnimation(obj, "opacity"); obj->connect(animation, &QPropertyAnimation::finished, &QObject::deleteLater); animation->setStartValue(1); @@ -43,9 +42,9 @@ namespace Animations { } } - void moveTo(QObject *obj, qreal x, qreal y) + void moveTo(QObject *obj, int speed, qreal x, qreal y) { - if (qPrefDisplay::animation_speed() != 0) { + if (speed != 0) { QPropertyAnimation *animation = new QPropertyAnimation(obj, "pos"); animation->setDuration(prefs.animation_speed); animation->setStartValue(obj->property("pos").toPointF()); @@ -56,9 +55,9 @@ namespace Animations { } } - void scaleTo(QObject *obj, qreal scale) + void scaleTo(QObject *obj, int speed, qreal scale) { - if (qPrefDisplay::animation_speed() != 0) { + if (speed != 0) { QPropertyAnimation *animation = new QPropertyAnimation(obj, "scale"); animation->setDuration(prefs.animation_speed); animation->setStartValue(obj->property("scale").toReal()); @@ -70,8 +69,8 @@ namespace Animations { } } - void moveTo(QObject *obj, const QPointF &pos) + void moveTo(QObject *obj, int speed, const QPointF &pos) { - moveTo(obj, pos.x(), pos.y()); + moveTo(obj, speed, pos.x(), pos.y()); } } diff --git a/profile-widget/animationfunctions.h b/profile-widget/animationfunctions.h index b13757532..f8af01859 100644 --- a/profile-widget/animationfunctions.h +++ b/profile-widget/animationfunctions.h @@ -8,12 +8,12 @@ class QObject; namespace Animations { - void hide(QObject *obj); - void show(QObject *obj); - void moveTo(QObject *obj, qreal x, qreal y); - void moveTo(QObject *obj, const QPointF &pos); - void animDelete(QObject *obj); - void scaleTo(QObject *obj, qreal scale); + void hide(QObject *obj, int speed); + void show(QObject *obj, int speed); + void moveTo(QObject *obj, int speed, qreal x, qreal y); + void moveTo(QObject *obj, int speed, const QPointF &pos); + void animDelete(QObject *obj, int speed); + void scaleTo(QObject *obj, int speed, qreal scale); } #endif // ANIMATIONFUNCTIONS_H diff --git a/profile-widget/divecartesianaxis.cpp b/profile-widget/divecartesianaxis.cpp index e37c311d3..c4beb4036 100644 --- a/profile-widget/divecartesianaxis.cpp +++ b/profile-widget/divecartesianaxis.cpp @@ -10,6 +10,7 @@ #include "profile-widget/animationfunctions.h" #include "profile-widget/divelineitem.h" #include "profile-widget/profilewidget2.h" +#include "core/settings/qPrefDisplay.h" // TODO: Remove QPen DiveCartesianAxis::gridPen() { @@ -130,7 +131,7 @@ void emptyList(QList<T *> &list, int steps) { while (list.size() > steps) { T *removedItem = list.takeLast(); - Animations::animDelete(removedItem); + Animations::animDelete(removedItem, qPrefDisplay::animation_speed()); } } @@ -177,9 +178,9 @@ void DiveCartesianAxis::updateTicks(color_index_t color) labels[i]->setText(textForValue(currValueText)); if (orientation == LeftToRight || orientation == RightToLeft) { - Animations::moveTo(labels[i],childPos, m.y1() + tick_size); + Animations::moveTo(labels[i], qPrefDisplay::animation_speed(), childPos, m.y1() + tick_size); } else { - Animations::moveTo(labels[i],m.x1() - tick_size, childPos); + Animations::moveTo(labels[i], qPrefDisplay::animation_speed() ,m.x1() - tick_size, childPos); } } @@ -189,9 +190,9 @@ void DiveCartesianAxis::updateTicks(color_index_t color) begin - i * stepSize; if (orientation == LeftToRight || orientation == RightToLeft) { - Animations::moveTo(lines[i],childPos, m.y1()); + Animations::moveTo(lines[i], qPrefDisplay::animation_speed(), childPos, m.y1()); } else { - Animations::moveTo(lines[i],m.x1(), childPos); + Animations::moveTo(lines[i], qPrefDisplay::animation_speed(), m.x1(), childPos); } } @@ -212,11 +213,11 @@ void DiveCartesianAxis::updateTicks(color_index_t color) if (orientation == RightToLeft || orientation == LeftToRight) { label->setAlignment(Qt::AlignBottom | Qt::AlignHCenter); label->setPos(scene()->sceneRect().width() + 10, m.y1() + tick_size); // position it outside of the scene); - Animations::moveTo(label,childPos, m.y1() + tick_size); + Animations::moveTo(label, qPrefDisplay::animation_speed(),childPos , m.y1() + tick_size); } else { label->setAlignment(Qt::AlignVCenter | Qt::AlignLeft); label->setPos(m.x1() - tick_size, scene()->sceneRect().height() + 10); - Animations::moveTo(label,m.x1() - tick_size, childPos); + Animations::moveTo(label, qPrefDisplay::animation_speed(), m.x1() - tick_size, childPos); } } @@ -237,13 +238,13 @@ void DiveCartesianAxis::updateTicks(color_index_t color) if (orientation == RightToLeft || orientation == LeftToRight) { line->setLine(0, -line_size, 0, 0); line->setPos(scene()->sceneRect().width() + 10, m.y1()); // position it outside of the scene); - Animations::moveTo(line,childPos, m.y1()); + Animations::moveTo(line, qPrefDisplay::animation_speed(), childPos, m.y1()); } else { QPointF p1 = mapFromScene(3, 0); QPointF p2 = mapFromScene(line_size, 0); line->setLine(p1.x(), 0, p2.x(), 0); line->setPos(m.x1(), scene()->sceneRect().height() + 10); - Animations::moveTo(line,m.x1(), childPos); + Animations::moveTo(line, qPrefDisplay::animation_speed(), m.x1(), childPos); } } diff --git a/profile-widget/diveeventitem.cpp b/profile-widget/diveeventitem.cpp index 3e1430330..6001ef0ea 100644 --- a/profile-widget/diveeventitem.cpp +++ b/profile-widget/diveeventitem.cpp @@ -288,7 +288,7 @@ void DiveEventItem::recalculatePos(int speed) qreal x = hAxis->posAtValue(internalEvent->time.seconds); qreal y = vAxis->posAtValue(depth); if (speed > 0) - Animations::moveTo(this, x, y); + Animations::moveTo(this, speed, x, y); else setPos(x, y); if (isVisible() && shouldBeHidden()) diff --git a/profile-widget/divepixmapitem.cpp b/profile-widget/divepixmapitem.cpp index 730cdf606..611f3f76a 100644 --- a/profile-widget/divepixmapitem.cpp +++ b/profile-widget/divepixmapitem.cpp @@ -4,6 +4,7 @@ #include "qt-models/divepicturemodel.h" #include "core/pref.h" #include "core/qthelper.h" +#include "core/settings/qPrefDisplay.h" #ifndef SUBSURFACE_MOBILE #include "desktop-widgets/preferences/preferencesdialog.h" #endif @@ -93,12 +94,12 @@ void DivePictureItem::setPixmap(const QPixmap &pix) void DivePictureItem::hoverEnterEvent(QGraphicsSceneHoverEvent*) { - Animations::scaleTo(this, 1.0); + Animations::scaleTo(this, qPrefDisplay::animation_speed(), 1.0); setZValue(baseZValue + 5.0); button->setOpacity(0); button->show(); - Animations::show(button); + Animations::show(button, qPrefDisplay::animation_speed()); } void DivePictureItem::setFileUrl(const QString &s) @@ -108,9 +109,9 @@ void DivePictureItem::setFileUrl(const QString &s) void DivePictureItem::hoverLeaveEvent(QGraphicsSceneHoverEvent*) { - Animations::scaleTo(this, 0.2); + Animations::scaleTo(this, qPrefDisplay::animation_speed(), 0.2); setZValue(baseZValue); - Animations::hide(button); + Animations::hide(button, qPrefDisplay::animation_speed()); } void DivePictureItem::mousePressEvent(QGraphicsSceneMouseEvent *event) |