Commit 6dffef78 authored by Ming Rui Zhang's avatar Ming Rui Zhang Committed by Sébastien Blin

overlays: replace fade animation with size animation for videooverlay

Change-Id: I2dda3732a78ce5d0b7ffbf04b7a21546b08e9be0
parent 45c0c897
......@@ -69,3 +69,17 @@ FadeAnimation::FadeAnimation(QWidget* target,
FadeAnimation::~FadeAnimation()
{}
SizeAnimation::SizeAnimation(QWidget* target,
const QRect& startRect,
const QRect& endRect,
const quint64 duration)
:QPropertyAnimation(target, "geometry")
{
setDuration(duration);
setStartValue(startRect);
setEndValue(endRect);
}
SizeAnimation::~SizeAnimation()
{}
\ No newline at end of file
......@@ -51,4 +51,15 @@ public:
const qreal maxOpacity = MAX_OPACITY,
const QEasingCurve curve = QEasingCurve::OutQuad);
~FadeAnimation();
};
class SizeAnimation : public QPropertyAnimation
{
Q_OBJECT
public:
explicit SizeAnimation(QWidget* target,
const QRect& startRect = QRect(),
const QRect& endRect = QRect(),
const quint64 duration = 1000);
~SizeAnimation();
};
\ No newline at end of file
......@@ -83,7 +83,7 @@ VideoOverlay::updateCall(const conversation::Info& convInfo)
QObject::connect(oneSecondTimer_, &QTimer::timeout,
this, &VideoOverlay::setTime);
oneSecondTimer_->start(1000);
resetOpacity();
resetToFadeIn(true);
// close chat panel
emit setChatVisibility(false);
......@@ -157,6 +157,17 @@ VideoOverlay::shouldFadeOut()
sipInputPanel_->getContainer()->isActiveWindow());
}
void
VideoOverlay::updateGeometry(const QSize& size)
{
resize(size);
QRect endRect = rect();
setFadeOutStartLocation(endRect);
endRect.setHeight(endRect.height() + ui->bottomButtons->height() + ui->bottomButtons->height());
endRect.setY(endRect.y() - ui->bottomButtons->height() - ui->bottomButtons->height());
setFadeOutEndLocation(endRect);
}
void
VideoOverlay::simulateShowChatview(bool checked)
{
......
......@@ -49,6 +49,7 @@ public:
void simulateShowChatview(bool checked);
bool shouldFadeOut() override;
void updateGeometry(const QSize& size);
signals:
void setChatVisibility(bool visible);
......
......@@ -113,7 +113,7 @@ VideoView::resizeEvent(QResizeEvent* event)
vignette_->updateGeometry(this->size());
audioOnlyAvatar_->resize(this->size());
overlay_->resize(this->size());
overlay_->updateGeometry(this->size());
}
void
......
......@@ -18,13 +18,11 @@
#include "widgethelpers.h"
#include "utils.h"
FadeOutable::FadeOutable(QWidget* parent)
: QWidget(parent)
{
setAttribute(Qt::WA_NoSystemBackground);
fadeAnimation_ = new FadeAnimation(this, fadeTime_);
fadeAnimation_ = new SizeAnimation(this, rect(), rect());
fadeTimer_.setSingleShot(true);
connect(&fadeTimer_, SIGNAL(timeout()), this, SLOT(slotTimeout()));
}
......@@ -33,19 +31,20 @@ FadeOutable::~FadeOutable()
{}
void
FadeOutable::resetOpacity()
FadeOutable::resetToFadeIn(bool resetTimer)
{
fadeAnimation_->reset();
fadeAnimation_->stop();
fadeAnimation_->targetObject()->setProperty(fadeAnimation_->propertyName(), fadeAnimation_->startValue());
Q_EMIT willReset();
fadeTimer_.start(fadeDelay_);
if(resetTimer)
fadeTimer_.start(fadeDelay_);
}
void
FadeOutable::enterEvent(QEvent* event)
{
Q_UNUSED(event);
fadeAnimation_->reset();
Q_EMIT willReset();
resetToFadeIn(false);
event->ignore();
}
......@@ -61,9 +60,7 @@ void
FadeOutable::mouseMoveEvent(QMouseEvent* event)
{
// start/restart the timer after which the widget will fade
fadeAnimation_->reset();
fadeTimer_.start(fadeDelay_);
Q_EMIT willReset();
resetToFadeIn(true);
event->ignore();
}
......@@ -122,11 +119,10 @@ Blinkable::paintEvent(QPaintEvent *event)
}
VignetteWidget::VignetteWidget(QWidget* parent)
: QWidget(parent)
: QWidget(parent),
geometryAnimation_(new SizeAnimation(this, rect(), rect()))
{
setAttribute(Qt::WA_NoSystemBackground);
geometryAnimation_ = new QPropertyAnimation(this, "geometry");
geometryAnimation_->setDuration(1000);
}
VignetteWidget::~VignetteWidget()
......
......@@ -19,6 +19,7 @@
#include "animationhelpers.h"
#include "popupdialog.h"
#include "utils.h"
#include <QWidget>
#include <QLabel>
......@@ -34,10 +35,11 @@ public:
explicit FadeOutable(QWidget* parent = nullptr);
~FadeOutable();
void resetOpacity();
void resetToFadeIn(bool resetTimer);
void setFadeTime(const quint64 ms) { fadeTime_ = ms; }
void setFadeDelay(const quint64 ms) { fadeDelay_ = ms; }
void setFadeOutStartLocation(const QRect& rect) { Utils::whileBlocking(fadeAnimation_)->setStartValue(rect); }
void setFadeOutEndLocation(const QRect& rect) { Utils::whileBlocking(fadeAnimation_)->setEndValue(rect); }
virtual bool shouldFadeOut() { return false; };
......@@ -54,10 +56,9 @@ private slots:
void slotTimeout();
private:
FadeAnimation* fadeAnimation_;
SizeAnimation* fadeAnimation_;
QTimer fadeTimer_;
quint64 fadeTime_{ 1000 };
quint64 fadeDelay_{ 2000 };
};
......@@ -110,7 +111,7 @@ protected:
private:
void fillRoundRectPath(QPainter& painter, const QLinearGradient& gradient);
QPropertyAnimation* geometryAnimation_;
SizeAnimation* geometryAnimation_;
constexpr static qreal cornerRadius_ = 10.0f;
quint64 height_{ 128 };
quint64 fadeTime_{ 1000 };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment