summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2023-02-08 11:52:48 +0100
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2023-02-14 09:27:07 +0100
commit705a76e8dce924a72153b0fb75880a1eeb65652e (patch)
treed2b0b699e1d693c8de7943ba61a44029da7ccb6d
parentb094c2dd7a5ebff91113a93000786588773d83ab (diff)
downloadqtmultimedia-705a76e8dce924a72153b0fb75880a1eeb65652e.tar.gz
QScreenCapture: Remove the window API
The implementation isn't ready on all platforms and too unstable, so remove it from Qt 6.5. This removes the public API and documents the respective error enum as internal. The adjustments to the implementations is as mininmal as possible to avoid conflicts with cherry-picking changes from dev into the 6.5 branch. Change-Id: I1a695a3d00c32d19a7805cb97fda6a5d525e43c8 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
-rw-r--r--src/multimedia/recording/qscreencapture.cpp70
-rw-r--r--src/multimedia/recording/qscreencapture.h10
-rw-r--r--src/plugins/multimedia/ffmpeg/qffmpegscreencapturebase.cpp9
-rw-r--r--tests/auto/integration/qscreencapture_integration/tst_qscreencapture_integration.cpp48
4 files changed, 14 insertions, 123 deletions
diff --git a/src/multimedia/recording/qscreencapture.cpp b/src/multimedia/recording/qscreencapture.cpp
index 5d65257c2..b0eb841db 100644
--- a/src/multimedia/recording/qscreencapture.cpp
+++ b/src/multimedia/recording/qscreencapture.cpp
@@ -22,28 +22,25 @@ public:
\ingroup multimedia_video
\since 6.5
- \brief The QScreenCapture class is used for capturing a screen view or
- a window view.
+ \brief The QScreenCapture class is used for capturing a screen.
- The class captures a screen view or window view. It is managed by
- the QMediaCaptureSession class where the captured view can be displayed
- in a window or recorded to a file.
+ The class captures a screen. It is managed by the QMediaCaptureSession
+ class where the captured view can be displayed in a window or recorded to a
+ file.
\snippet multimedia-snippets/media.cpp Media recorder
*/
/*!
\qmltype ScreenCapture
\instantiates QScreenCapture
- \brief The ScreenCapture type is used for capturing a screen view or
- a window view.
+ \brief The ScreenCapture type is used for capturing a screen.
\inqmlmodule QtMultimedia
\ingroup multimedia_qml
\ingroup multimedia_video_qml
- ScreenCapture captures a screen view or a window view. It is managed by
- MediaCaptureSession where the captured view can be displayed in a window
- or recorded to a file.
+ ScreenCapture captures a screen. It is managed by MediaCaptureSession where
+ the captured view can be displayed in a window or recorded to a file.
\since 6.5
The code below shows a simple capture session with ScreenCapture playing
@@ -91,7 +88,7 @@ QScreenCapture::~QScreenCapture()
\value NoError No error
\value InternalError Internal screen capturing driver error
\value CapturingNotSupported Capturing is not supported
- \value WindowCapturingNotSupported Window capturing is not supported
+ \omitvalue WindowCapturingNotSupported Window capturing is not supported
\value CaptureFailed Capturing screen or window view failed
\value NotFound Selected screen or window not found
*/
@@ -115,57 +112,6 @@ QMediaCaptureSession *QScreenCapture::captureSession() const
*/
/*!
- \property QScreenCapture::window
- \brief the window for capturing.
-*/
-void QScreenCapture::setWindow(QWindow *window)
-{
- Q_D(QScreenCapture);
-
- if (d->platformScreenCapture) {
- d->platformScreenCapture->setScreen(nullptr);
- d->platformScreenCapture->setWindowId(0);
- d->platformScreenCapture->setWindow(window);
- }
-}
-
-QWindow *QScreenCapture::window() const
-{
- Q_D(const QScreenCapture);
-
- return d->platformScreenCapture ? d->platformScreenCapture->window()
- : nullptr;
-}
-
-/*!
- \qmlproperty Window QtMultimedia::ScreenCapture::windowId
- Describes the window ID for capturing.
-*/
-
-/*!
- \property QScreenCapture::windowId
- \brief the window ID for capturing.
-*/
-void QScreenCapture::setWindowId(WId id)
-{
- Q_D(QScreenCapture);
-
- if (d->platformScreenCapture) {
- d->platformScreenCapture->setScreen(nullptr);
- d->platformScreenCapture->setWindow(nullptr);
- d->platformScreenCapture->setWindowId(id);
- }
-}
-
-WId QScreenCapture::windowId() const
-{
- Q_D(const QScreenCapture);
-
- return d->platformScreenCapture ? d->platformScreenCapture->windowId()
- : 0;
-}
-
-/*!
\qmlproperty bool QtMultimedia::ScreenCapture::active
Describes whether the capturing is currently active.
*/
diff --git a/src/multimedia/recording/qscreencapture.h b/src/multimedia/recording/qscreencapture.h
index 4dc2cc1d3..02c3de995 100644
--- a/src/multimedia/recording/qscreencapture.h
+++ b/src/multimedia/recording/qscreencapture.h
@@ -22,8 +22,6 @@ class Q_MULTIMEDIA_EXPORT QScreenCapture : public QObject
{
Q_OBJECT
Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged)
- Q_PROPERTY(WId windowId READ windowId WRITE setWindowId NOTIFY windowIdChanged)
- Q_PROPERTY(QWindow *window READ window WRITE setWindow NOTIFY windowChanged)
Q_PROPERTY(QScreen *screen READ screen WRITE setScreen NOTIFY screenChanged)
Q_PROPERTY(Error error READ error NOTIFY errorChanged)
Q_PROPERTY(QString errorString READ errorString NOTIFY errorChanged)
@@ -44,12 +42,6 @@ public:
QMediaCaptureSession *captureSession() const;
- void setWindow(QWindow *window);
- QWindow *window() const;
-
- void setWindowId(WId id);
- WId windowId() const;
-
void setScreen(QScreen *screen);
QScreen *screen() const;
@@ -66,8 +58,6 @@ public Q_SLOTS:
Q_SIGNALS:
void activeChanged(bool);
void errorChanged();
- void windowIdChanged(WId);
- void windowChanged(QWindow *);
void screenChanged(QScreen *);
void errorOccurred(QScreenCapture::Error error, const QString &errorString);
diff --git a/src/plugins/multimedia/ffmpeg/qffmpegscreencapturebase.cpp b/src/plugins/multimedia/ffmpeg/qffmpegscreencapturebase.cpp
index 3d791d054..f4be035e1 100644
--- a/src/plugins/multimedia/ffmpeg/qffmpegscreencapturebase.cpp
+++ b/src/plugins/multimedia/ffmpeg/qffmpegscreencapturebase.cpp
@@ -38,7 +38,7 @@ QScreen *QFFmpegScreenCaptureBase::screen() const
void QFFmpegScreenCaptureBase::setWindow(QWindow *w)
{
- setSource(m_window, w, &QScreenCapture::windowChanged);
+ setSource(m_window, w, nullptr);
}
QWindow *QFFmpegScreenCaptureBase::window() const
@@ -48,7 +48,7 @@ QWindow *QFFmpegScreenCaptureBase::window() const
void QFFmpegScreenCaptureBase::setWindowId(WId id)
{
- setSource(m_wid, id, &QScreenCapture::windowIdChanged);
+ setSource(m_wid, id, nullptr);
}
WId QFFmpegScreenCaptureBase::windowId() const
@@ -79,7 +79,10 @@ void QFFmpegScreenCaptureBase::setSource(Source &source, NewSource newSource, Si
if (m_active && newSource)
setActiveInternal(true);
- emit (screenCapture()->*sig)(newSource);
+ if constexpr (!std::is_same_v<Signal, std::nullptr_t>)
+ emit (screenCapture()->*sig)(newSource);
+ else
+ Q_UNUSED(sig);
}
QT_END_NAMESPACE
diff --git a/tests/auto/integration/qscreencapture_integration/tst_qscreencapture_integration.cpp b/tests/auto/integration/qscreencapture_integration/tst_qscreencapture_integration.cpp
index 617eacf97..4e7b7ea1f 100644
--- a/tests/auto/integration/qscreencapture_integration/tst_qscreencapture_integration.cpp
+++ b/tests/auto/integration/qscreencapture_integration/tst_qscreencapture_integration.cpp
@@ -108,13 +108,9 @@ class tst_QScreenCaptureIntegration : public QObject
private slots:
void initTestCase();
void startStop();
- void captureWindowById();
- void captureWindow();
- void captureOverlappedWindow();
void captureScreen();
void captureScreenByDefault();
void captureSecondaryScreen();
- void removeWindowWhileCapture();
void removeScreenWhileCapture(); // Keep the test last defined. TODO: find a way to restore
// application screens.
@@ -282,41 +278,6 @@ void tst_QScreenCaptureIntegration::initTestCase()
QSKIP("Screen capturing not supported");
}
-void tst_QScreenCaptureIntegration::captureWindowById()
-{
- auto widget = QTestWidget::createAndShow(Qt::Window | Qt::FramelessWindowHint,
- QRect{ 200, 100, 430, 351 });
- QVERIFY(QTest::qWaitForWindowExposed(widget.get()));
-
- capture(*widget, { 0, 0 }, { 430, 351 },
- [&widget](QScreenCapture &sc) { sc.setWindowId(widget->winId()); });
-}
-
-void tst_QScreenCaptureIntegration::captureWindow()
-{
- auto widget = QTestWidget::createAndShow(Qt::Window | Qt::FramelessWindowHint,
- QRect{ 200, 100, 430, 351 });
- QVERIFY(QTest::qWaitForWindowExposed(widget.get()));
-
- capture(*widget, { 0, 0 }, { 430, 351 },
- [&widget](QScreenCapture &sc) { sc.setWindow(widget->windowHandle()); });
-}
-
-void tst_QScreenCaptureIntegration::captureOverlappedWindow()
-{
- auto overlappedWidget = QTestWidget::createAndShow(Qt::Window | Qt::FramelessWindowHint,
- QRect{ 200, 100, 430, 351 });
- QVERIFY(QTest::qWaitForWindowExposed(overlappedWidget.get()));
-
- auto overlappingWidget = QTestWidget::createAndShow(Qt::Window | Qt::FramelessWindowHint,
- QRect{ 210, 110, 430, 351 });
- QVERIFY(QTest::qWaitForWindowExposed(overlappingWidget.get()));
-
- capture(*overlappedWidget, { 0, 0 }, { 430, 351 }, [&overlappedWidget](QScreenCapture &sc) {
- sc.setWindow(overlappedWidget->windowHandle());
- });
-}
-
void tst_QScreenCaptureIntegration::captureScreen()
{
auto widget = QTestWidget::createAndShow(Qt::Window | Qt::FramelessWindowHint
@@ -359,15 +320,6 @@ void tst_QScreenCaptureIntegration::captureSecondaryScreen()
[&screens](QScreenCapture &sc) { sc.setScreen(screens.back()); });
}
-void tst_QScreenCaptureIntegration::removeWindowWhileCapture()
-{
- auto widget = QTestWidget::createAndShow(Qt::Window, QRect{ 200, 100, 430, 351 });
- QVERIFY(QTest::qWaitForWindowExposed(widget.get()));
-
- removeWhileCapture([&widget](QScreenCapture &sc) { sc.setWindowId(widget->winId()); },
- [&widget]() { widget.reset(); });
-}
-
void tst_QScreenCaptureIntegration::removeScreenWhileCapture()
{
QSKIP("TODO: find a reliable way to emulate it");