Skip to content

Commit 03333f0

Browse files
committed
Moved FadeAnimation to WidgetUtils
1 parent c7d2cdb commit 03333f0

File tree

5 files changed

+36
-57
lines changed

5 files changed

+36
-57
lines changed

fadeanimation.cpp

Lines changed: 0 additions & 41 deletions
This file was deleted.

fadeanimation.h

Lines changed: 0 additions & 14 deletions
This file was deleted.

reverscreen.pro

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ SOURCES += main.cpp\
1313
cv/cvmodel.cpp \
1414
cv/cvmodelbuilderoptions.cpp \
1515
fullscreenselectiondialog.cpp \
16-
fadeanimation.cpp \
1716
dock/colorswidget.cpp \
1817
dock/accentwidget.cpp \
1918
controls/coloractionwidget.cpp \
@@ -31,7 +30,6 @@ HEADERS += mainwindow.h \
3130
cv/cvmodel.h \
3231
cv/cvmodelbuilderoptions.h \
3332
fullscreenselectiondialog.h \
34-
fadeanimation.h \
3533
dock/colorswidget.h \
3634
dock/accentwidget.h \
3735
controls/coloractionwidget.h \

widgetutils.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#include <QGuiApplication>
77
#include <QDesktopWidget>
88
#include <QApplication>
9+
#include <QGraphicsOpacityEffect>
10+
#include <QPropertyAnimation>
911

1012

1113
QWidget *WidgetUtils::createHSeparator()
@@ -36,3 +38,35 @@ void WidgetUtils::centerWindow(QWidget* widget)
3638
)
3739
);
3840
}
41+
42+
void WidgetUtils::fadeIn(QWidget *widget)
43+
{
44+
Q_ASSERT(widget != NULL);
45+
46+
QGraphicsOpacityEffect *effect = new QGraphicsOpacityEffect(widget);
47+
widget->setGraphicsEffect(effect);
48+
49+
QPropertyAnimation *animation = new QPropertyAnimation(effect, "opacity");
50+
animation->setDuration(600);
51+
animation->setStartValue(0);
52+
animation->setEndValue(1);
53+
animation->setEasingCurve(QEasingCurve::InBack);
54+
animation->start(QPropertyAnimation::DeleteWhenStopped);
55+
}
56+
57+
void WidgetUtils::fadeOut(QWidget *widget)
58+
{
59+
Q_ASSERT(widget != NULL);
60+
61+
QGraphicsOpacityEffect *effect = new QGraphicsOpacityEffect(widget);
62+
widget->setGraphicsEffect(effect);
63+
64+
QPropertyAnimation *animation = new QPropertyAnimation(effect, "opacity");
65+
animation->setDuration(600);
66+
animation->setStartValue(1);
67+
animation->setEndValue(0);
68+
animation->setEasingCurve(QEasingCurve::OutBack);
69+
animation->start(QPropertyAnimation::DeleteWhenStopped);
70+
71+
animation->connect(animation, &animation->finished, widget, widget->hide);
72+
}

widgetutils.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ class WidgetUtils
1212
static QWidget* createHSeparator();
1313
static QLabel* createInfoLabel(const QString& text);
1414
static void centerWindow(QWidget* widget);
15+
static void fadeIn(QWidget* widget);
16+
static void fadeOut(QWidget* widget);
1517

1618
private:
1719
WidgetUtils() {}

0 commit comments

Comments
 (0)