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 | 2e56a30b1e7ab4d31b40605a4b064012bd5f9181 (patch) | |
tree | b1e3700517591bc474fd80de600431ad72ae06fc | |
parent | 4a553355ddac0ccdb08648e026aae0f0ad617411 (diff) | |
download | qtmultimedia-2e56a30b1e7ab4d31b40605a4b064012bd5f9181.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 dafe7c142..d71996ec5 100644 --- a/src/multimediawidgets/qvideowidget.cpp +++ b/src/multimediawidgets/qvideowidget.cpp @@ -106,6 +106,8 @@ void QVideoWidget::setAspectRatioMode(Qt::AspectRatioMode mode) void QVideoWidget::setFullScreen(bool fullScreen) { Q_D(QVideoWidget); + if (isFullScreen() == fullScreen) + return; Qt::WindowFlags flags = windowFlags(); @@ -131,7 +133,6 @@ void QVideoWidget::setFullScreen(bool fullScreen) move(d_ptr->nonFullscreenPos); d_ptr->nonFullscreenPos = {}; } - d->wasFullScreen = fullScreen; } /*! @@ -157,12 +158,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; } } |