Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qplatformsurfacecapture.cpp
Go to the documentation of this file.
1// Copyright (C) 2022 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
5
6#include <QtMultimedia/qvideoframe.h>
7#include <QtGui/qguiapplication.h>
8#include <QtCore/qdebug.h>
9
11
12QPlatformSurfaceCapture::QPlatformSurfaceCapture(Source initialSource) : m_source(initialSource)
13{
14 Q_ASSERT(std::visit([](const auto &source) {
15 return source == decltype(source){};
16 }, initialSource));
17 qRegisterMetaType<QVideoFrame>();
18}
19
20void QPlatformSurfaceCapture::setActive(bool active)
21{
22 if (m_active == active)
23 return;
24
25 if (!setActiveInternal(active))
26 return;
27
28 m_active = active;
29 emit activeChanged(active);
30}
31
32bool QPlatformSurfaceCapture::isActive() const
33{
34 return m_active;
35}
36
37void QPlatformSurfaceCapture::setSource(Source source)
38{
39 Q_ASSERT(source.index() == m_source.index());
40
41 if (m_source == source)
42 return;
43
44 if (m_active)
45 setActiveInternal(false);
46
47 m_source = std::move(source);
48
49 if (m_active && !setActiveInternal(true)) {
50 m_active = false;
51 emit activeChanged(false);
52 }
53
54 std::visit([this](const auto &source) {
55 emit sourceChanged(source);
56 }, m_source);
57}
58
59QPlatformSurfaceCapture::Error QPlatformSurfaceCapture::error() const
60{
61 return m_error.code();
62}
63
64QString QPlatformSurfaceCapture::errorString() const
65{
66 return m_error.description();
67}
68
69void QPlatformSurfaceCapture::updateError(Error error, const QString &errorString)
70{
71 m_error.setAndNotify(error, errorString, *this);
72}
73
74bool QPlatformSurfaceCapture::checkScreenWithError(ScreenSource &screen)
75{
76 if (!screen)
77 screen = QGuiApplication::primaryScreen();
78
79 if (screen)
80 return true;
81
82 updateError(NotFound, QLatin1String("No screens found"));
83 return false;
84}
85
86QT_END_NAMESPACE
87
88#include "moc_qplatformsurfacecapture_p.cpp"
Combined button and popup list for selecting options.