Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qvideowidget.cpp
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include <private/qtmultimediaglobal_p.h>
5#include "qvideowidget_p.h"
6
7#include <QtCore/qobject.h>
8#include <QtMultimedia/qtmultimediaglobal.h>
9#include <qvideosink.h>
10#include <private/qvideowindow_p.h>
11
12#include <qobject.h>
13#include <qvideoframeformat.h>
14#include <qpainter.h>
15
16#include <qapplication.h>
17#include <qevent.h>
18#include <qboxlayout.h>
19#include <qnamespace.h>
20
21#include <qwindow.h>
22#include <private/qhighdpiscaling_p.h>
23
24#ifdef Q_OS_WIN
25#include <QtCore/qt_windows.h>
26#endif
27
28using namespace Qt;
29
31
74
79{
80 delete d_ptr->videoWindow;
81 delete d_ptr;
82}
83
91
101
106
112void QVideoWidget::setFullScreen(bool fullScreen)
113{
114 Q_D(QVideoWidget);
115 if (isFullScreen() == fullScreen)
116 return;
117
118 Qt::WindowFlags flags = windowFlags();
119
120 if (fullScreen) {
121 // get the position of the widget in global coordinates
123 d->nonFullScreenFlags = flags & (Qt::Window | Qt::SubWindow);
125 flags |= Qt::Window;
128 // move the widget to the position it had on screen, so that showFullScreen() will
129 // place it on the correct screen
130 move(position);
131
133 } else {
134 flags &= ~(Qt::Window | Qt::SubWindow); //clear the flags...
135 flags |= d->nonFullScreenFlags; //then we reset the flags (window and subwindow)
137
138 showNormal();
141 }
142}
143
149{
150 auto size = videoSink()->videoSize();
151 if (size.isValid())
152 return size;
153
154 return QWidget::sizeHint();
155}
156
163{
164 Q_D(QVideoWidget);
165
166 if (event->type() == QEvent::WindowStateChange) {
168 if (fullScreen != d->wasFullScreen) {
170 d->wasFullScreen = fullScreen;
171 }
172 }
173
174 return QWidget::event(event);
175}
176
185
194
204
210{
211}
212
214
215#include "moc_qvideowidget.cpp"
\inmodule QtCore
Definition qcoreevent.h:45
@ WindowStateChange
Definition qcoreevent.h:143
The QHideEvent class provides an event which is sent after a widget is hidden.
Definition qevent.h:586
The QMoveEvent class contains event parameters for move events.
Definition qevent.h:502
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2960
\inmodule QtCore\reentrant
Definition qpoint.h:25
The QResizeEvent class contains event parameters for resize events.
Definition qevent.h:548
The QShowEvent class provides an event that is sent when a widget is shown.
Definition qevent.h:578
\inmodule QtCore
Definition qsize.h:25
The QVideoSink class represents a generic sink for video data.
Definition qvideosink.h:22
QSize videoSize
Returns the size of the video currently being played back.
Definition qvideosink.h:25
QVideoWindow * videoWindow
QVideoWidget * q_ptr
The QVideoWidget class provides a widget which presents video produced by a media object.
void showEvent(QShowEvent *event) override
\reimp Handles the show event.
void setFullScreen(bool fullScreen)
~QVideoWidget()
Destroys a video widget.
QSize sizeHint() const override
Returns the size hint for the current back end, if there is one, or else the size hint from QWidget.
QVideoWidgetPrivate * d_ptr
void setAspectRatioMode(Qt::AspectRatioMode mode)
Q_INVOKABLE QVideoSink * videoSink() const
Returns the QVideoSink instance.
bool fullScreen
whether video display is confined to a window or is fullScreen.
QVideoWidget(QWidget *parent=nullptr)
\variable QVideoWidget::d_ptr
void resizeEvent(QResizeEvent *event) override
\reimp Handles the resize event.
void moveEvent(QMoveEvent *event) override
\reimp Handles the move event.
bool event(QEvent *event) override
\reimp Current event event.
void fullScreenChanged(bool fullScreen)
void aspectRatioModeChanged(Qt::AspectRatioMode mode)
Qt::AspectRatioMode aspectRatioMode
how video is scaled with respect to its aspect ratio.
void hideEvent(QHideEvent *event) override
\reimp Handles the hide event.
void setAspectRatioMode(Qt::AspectRatioMode mode)
void aspectRatioModeChanged(Qt::AspectRatioMode mode)
Qt::AspectRatioMode aspectRatioMode() const
Q_INVOKABLE QVideoSink * videoSink() const
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
Qt::WindowFlags windowFlags() const
Window flags are a combination of a type (e.g.
Definition qwidget.h:803
virtual void hideEvent(QHideEvent *event)
This event handler can be reimplemented in a subclass to receive widget hide events.
bool isFullScreen() const
Definition qwidget.cpp:2982
QSize size
the size of the widget excluding any window frame
Definition qwidget.h:113
QPointF mapToGlobal(const QPointF &) const
Translates the widget coordinate pos to global screen coordinates.
QPoint pos
the position of the widget within its parent widget
Definition qwidget.h:111
void move(int x, int y)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qwidget.h:880
void showFullScreen()
Shows the widget in full-screen mode.
Definition qwidget.cpp:3021
static QWidget * createWindowContainer(QWindow *window, QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::WindowFlags())
Creates a QWidget that makes it possible to embed window into a QWidget-based application.
QSize sizeHint
the recommended size for the widget
Definition qwidget.h:148
bool event(QEvent *event) override
This is the main event handler; it handles event event.
Definition qwidget.cpp:8866
void resize(int w, int h)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qwidget.h:883
virtual void resizeEvent(QResizeEvent *event)
This event handler can be reimplemented in a subclass to receive widget resize events which are passe...
Definition qwidget.cpp:9822
Qt::WindowStates windowState() const
Returns the current window state.
Definition qwidget.cpp:2888
void showNormal()
Restores the widget after it has been maximized or minimized.
Definition qwidget.cpp:3060
virtual void showEvent(QShowEvent *event)
This event handler can be reimplemented in a subclass to receive widget show events which are passed ...
void setWindowFlags(Qt::WindowFlags type)
Combined button and popup list for selecting options.
Definition qcompare.h:63
@ WindowFullScreen
Definition qnamespace.h:255
AspectRatioMode
@ Window
Definition qnamespace.h:207
@ WindowTransparentForInput
Definition qnamespace.h:234
@ SubWindow
Definition qnamespace.h:216
GLenum mode
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLbitfield flags
struct _cl_event * event
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
#define emit