mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 15:15:50 +08:00
refs #883, added functions for fade in/out
This commit is contained in:
committed by
Mathew Sutcliffe
parent
873823eaa1
commit
1690c560b7
@@ -29,8 +29,11 @@
|
||||
#include <QTabWidget>
|
||||
#include <QThreadStorage>
|
||||
#include <QWidget>
|
||||
#include <QTimer>
|
||||
#include <Qt>
|
||||
#include <QtGlobal>
|
||||
#include <QGraphicsOpacityEffect>
|
||||
#include <QPropertyAnimation>
|
||||
|
||||
using namespace BlackMisc;
|
||||
|
||||
@@ -345,4 +348,33 @@ namespace BlackGui
|
||||
{
|
||||
return QApplication::topLevelWidgets().contains(widget);
|
||||
}
|
||||
|
||||
QGraphicsOpacityEffect *CGuiUtility::fadeInWidget(int durationMs, QWidget *widget, double startValue, double endValue)
|
||||
{
|
||||
// http://stackoverflow.com/questions/19087822/how-to-make-qt-widgets-fade-in-or-fade-out#
|
||||
Q_ASSERT(widget);
|
||||
QGraphicsOpacityEffect *effect = new QGraphicsOpacityEffect(widget);
|
||||
widget->setGraphicsEffect(effect);
|
||||
QPropertyAnimation *a = new QPropertyAnimation(effect, "opacity");
|
||||
a->setDuration(durationMs);
|
||||
a->setStartValue(startValue);
|
||||
a->setEndValue(endValue);
|
||||
a->setEasingCurve(QEasingCurve::InBack);
|
||||
a->start(QPropertyAnimation::DeleteWhenStopped);
|
||||
return effect;
|
||||
}
|
||||
|
||||
QGraphicsOpacityEffect *CGuiUtility::fadeOutWidget(int durationMs, QWidget *widget, double startValue, double endValue)
|
||||
{
|
||||
Q_ASSERT(widget);
|
||||
QGraphicsOpacityEffect *effect = new QGraphicsOpacityEffect(widget);
|
||||
widget->setGraphicsEffect(effect);
|
||||
QPropertyAnimation *a = new QPropertyAnimation(effect, "opacity");
|
||||
a->setDuration(durationMs);
|
||||
a->setStartValue(startValue);
|
||||
a->setEndValue(endValue);
|
||||
a->setEasingCurve(QEasingCurve::OutBack);
|
||||
a->start(QPropertyAnimation::DeleteWhenStopped);
|
||||
return effect;
|
||||
}
|
||||
} // ns
|
||||
|
||||
Reference in New Issue
Block a user