diff options
author | Piotr Srebrny <piotr.srebrny@qt.io> | 2022-08-16 17:13:41 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-08-17 08:59:40 +0000 |
commit | bb2062a8a7a40912a6b65cc9e82fd3c4fe375fac (patch) | |
tree | 301a0db9a736037aba15086a0c2d19c332b321c4 | |
parent | 31b89d7b029326ee54723a5827a48529b333514d (diff) | |
download | qtmultimedia-bb2062a8a7a40912a6b65cc9e82fd3c4fe375fac.tar.gz |
Do not call showFullScreen or showNormal when it is already set
With QVideoWidget window can go fullscreen either by calling
setFullScreen or directly QWidget::showFullScreen. However, a variable
describing window state is only updated when using setFullScreen
function, which becomes inconsisten when using QWidget::showNormal
when going out of full screen mode. This patch fixes this inconsistency
and test tst_QVideoWidget::fullScreen().
Change-Id: I82c496fcd32fda6a32f928564d2502073faf0064
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
(cherry picked from commit 5b3a09b84aa80d02cf3f0fc63d273b49af24faba)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/multimediawidgets/qvideowidget.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/multimediawidgets/qvideowidget.cpp b/src/multimediawidgets/qvideowidget.cpp index 511489dd9..313bac477 100644 --- a/src/multimediawidgets/qvideowidget.cpp +++ b/src/multimediawidgets/qvideowidget.cpp @@ -142,6 +142,8 @@ void QVideoWidget::setAspectRatioMode(Qt::AspectRatioMode mode) void QVideoWidget::setFullScreen(bool fullScreen) { Q_D(QVideoWidget); + if (isFullScreen() == fullScreen) + return; Qt::WindowFlags flags = windowFlags(); @@ -167,7 +169,6 @@ void QVideoWidget::setFullScreen(bool fullScreen) move(d_ptr->nonFullscreenPos); d_ptr->nonFullscreenPos = {}; } - d->wasFullScreen = fullScreen; } /*! @@ -201,12 +202,10 @@ bool QVideoWidget::event(QEvent *event) Q_D(QVideoWidget); if (event->type() == QEvent::WindowStateChange) { - if (windowState() & Qt::WindowFullScreen) { - if (!d->wasFullScreen) - emit fullScreenChanged(d->wasFullScreen = true); - } else { - if (d->wasFullScreen) - emit fullScreenChanged(d->wasFullScreen = false); + bool fullScreen = bool(windowState() & Qt::WindowFullScreen); + if (fullScreen != d->wasFullScreen) { + emit fullScreenChanged(fullScreen); + d->wasFullScreen = fullScreen; } } |