Skip to content
Snippets Groups Projects
Commit ca320d87 authored by Andreas Traczyk's avatar Andreas Traczyk Committed by Adrien Béraud
Browse files

videoview: fade video overlay when mouse is not moving

Change-Id: I9095888304ba8290e6e9840b9b8bce4b2ba62028
parent 8d5e5495
Branches
Tags
No related merge requests found
...@@ -59,6 +59,12 @@ VideoView::VideoView(QWidget* parent) : ...@@ -59,6 +59,12 @@ VideoView::VideoView(QWidget* parent) :
fadeAnim_->setEndValue(0); fadeAnim_->setEndValue(0);
fadeAnim_->setEasingCurve(QEasingCurve::OutQuad); fadeAnim_->setEasingCurve(QEasingCurve::OutQuad);
// Setup the timer to start the fade when the mouse stops moving
this->setMouseTracking(true);
overlay_->setMouseTracking(true);
fadeTimer_.setSingleShot(true);
connect(&fadeTimer_, SIGNAL(timeout()), this, SLOT(fadeOverlayOut()));
this->setContextMenuPolicy(Qt::CustomContextMenu); this->setContextMenuPolicy(Qt::CustomContextMenu);
connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), connect(this, SIGNAL(customContextMenuRequested(const QPoint&)),
this, SLOT(showContextMenu(const QPoint&))); this, SLOT(showContextMenu(const QPoint&)));
...@@ -119,14 +125,26 @@ void ...@@ -119,14 +125,26 @@ void
VideoView::enterEvent(QEvent* event) VideoView::enterEvent(QEvent* event)
{ {
Q_UNUSED(event) Q_UNUSED(event)
fadeAnim_->stop(); showOverlay();
fadeAnim_->targetObject()->setProperty(fadeAnim_->propertyName(), fadeAnim_->startValue());
} }
void void
VideoView::leaveEvent(QEvent* event) VideoView::leaveEvent(QEvent* event)
{ {
Q_UNUSED(event) Q_UNUSED(event)
fadeOverlayOut();
}
void
VideoView::showOverlay()
{
fadeAnim_->stop();
fadeAnim_->targetObject()->setProperty(fadeAnim_->propertyName(), fadeAnim_->startValue());
}
void
VideoView::fadeOverlayOut()
{
if (not overlay_->isDialogVisible()) if (not overlay_->isDialogVisible())
fadeAnim_->start(QAbstractAnimation::KeepWhenStopped); fadeAnim_->start(QAbstractAnimation::KeepWhenStopped);
} }
...@@ -333,6 +351,13 @@ VideoView::mouseReleaseEvent(QMouseEvent* event) ...@@ -333,6 +351,13 @@ VideoView::mouseReleaseEvent(QMouseEvent* event)
void void
VideoView::mouseMoveEvent(QMouseEvent* event) VideoView::mouseMoveEvent(QMouseEvent* event)
{ {
// start/restart the timer after which the overlay will fade
if (fadeTimer_.isActive()) {
showOverlay();
} else {
fadeTimer_.start(startfadeOverlayTime_);
}
QRect& previewRect = ui->videoWidget->getPreviewRect(); QRect& previewRect = ui->videoWidget->getPreviewRect();
if (draggingPreview_) { if (draggingPreview_) {
if (previewRect.left() > 0 if (previewRect.left() > 0
......
...@@ -54,11 +54,14 @@ private slots: ...@@ -54,11 +54,14 @@ private slots:
void updateCall(); void updateCall();
void showContextMenu(const QPoint& pos); void showContextMenu(const QPoint& pos);
void slotVideoStarted(Video::Renderer* renderer); void slotVideoStarted(Video::Renderer* renderer);
void fadeOverlayOut();
void showOverlay();
private: private:
Ui::VideoView* ui; Ui::VideoView* ui;
VideoOverlay* overlay_; VideoOverlay* overlay_;
QPropertyAnimation* fadeAnim_; QPropertyAnimation* fadeAnim_;
QTimer fadeTimer_;
QWidget* oldParent_; QWidget* oldParent_;
QSize oldSize_; QSize oldSize_;
QMetaObject::Connection timerConnection_; QMetaObject::Connection timerConnection_;
...@@ -72,6 +75,10 @@ private: ...@@ -72,6 +75,10 @@ private:
constexpr static int resizeGrip_ = 40; constexpr static int resizeGrip_ = 40;
constexpr static int minimalSize_ = 100; constexpr static int minimalSize_ = 100;
// Time before the overlay starts fading out after the mouse stops
// moving within the videoview.
constexpr static int startfadeOverlayTime_ = 2000; //msec
// TODO: fix when changing Qt version // TODO: fix when changing Qt version
// Full(1.0) opacity bug affecting many Qt version (macOS + win10) // Full(1.0) opacity bug affecting many Qt version (macOS + win10)
// causing the render to take a buggy code path which can be avoided // causing the render to take a buggy code path which can be avoided
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment