2017-04-27 20:26:36 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2016-04-04 22:02:03 -07:00
|
|
|
#include "profile-widget/animationfunctions.h"
|
|
|
|
#include "core/pref.h"
|
2014-01-14 16:01:17 -02:00
|
|
|
#include <QPropertyAnimation>
|
|
|
|
|
2014-05-22 11:40:22 -07:00
|
|
|
namespace Animations {
|
2014-01-27 15:14:42 -02:00
|
|
|
|
2019-07-10 22:23:25 +02:00
|
|
|
void hide(QObject *obj, int speed)
|
2014-02-27 20:09:57 -08:00
|
|
|
{
|
2019-07-10 22:23:25 +02:00
|
|
|
if (speed != 0) {
|
2014-07-11 18:55:33 -03:00
|
|
|
QPropertyAnimation *animation = new QPropertyAnimation(obj, "opacity");
|
|
|
|
animation->setStartValue(1);
|
|
|
|
animation->setEndValue(0);
|
|
|
|
animation->start(QAbstractAnimation::DeleteWhenStopped);
|
|
|
|
} else {
|
|
|
|
obj->setProperty("opacity", 0);
|
|
|
|
}
|
2014-02-27 20:09:57 -08:00
|
|
|
}
|
2014-01-14 16:01:17 -02:00
|
|
|
|
2019-07-10 22:23:25 +02:00
|
|
|
void show(QObject *obj, int speed)
|
2014-07-30 17:20:38 -03:00
|
|
|
{
|
2019-07-10 22:23:25 +02:00
|
|
|
if (speed != 0) {
|
2014-07-30 17:20:38 -03:00
|
|
|
QPropertyAnimation *animation = new QPropertyAnimation(obj, "opacity");
|
|
|
|
animation->setStartValue(0);
|
|
|
|
animation->setEndValue(1);
|
|
|
|
animation->start(QAbstractAnimation::DeleteWhenStopped);
|
|
|
|
} else {
|
|
|
|
obj->setProperty("opacity", 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-02 23:59:58 +01:00
|
|
|
void scaleTo(QObject *obj, int speed, double scale)
|
2014-06-08 12:22:45 -03:00
|
|
|
{
|
2019-07-10 22:23:25 +02:00
|
|
|
if (speed != 0) {
|
2014-07-11 18:55:33 -03:00
|
|
|
QPropertyAnimation *animation = new QPropertyAnimation(obj, "scale");
|
2014-07-21 19:10:31 -03:00
|
|
|
animation->setDuration(prefs.animation_speed);
|
2014-07-11 18:55:33 -03:00
|
|
|
animation->setStartValue(obj->property("scale").toReal());
|
|
|
|
animation->setEndValue(QVariant::fromValue(scale));
|
|
|
|
animation->setEasingCurve(QEasingCurve::InCubic);
|
|
|
|
animation->start(QAbstractAnimation::DeleteWhenStopped);
|
|
|
|
} else {
|
|
|
|
obj->setProperty("scale", QVariant::fromValue(scale));
|
|
|
|
}
|
2014-06-08 12:22:45 -03:00
|
|
|
}
|
2014-01-14 16:01:17 -02:00
|
|
|
}
|