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
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#include "qvideoframe.h"
6#include "qguiapplication.h"
7#include "qdebug.h"
8
10
11QPlatformSurfaceCapture::QPlatformSurfaceCapture(Source initialSource) : m_source(initialSource)
12{
13 Q_ASSERT(std::visit([](auto source) { return source == decltype(source){}; }, initialSource));
14 qRegisterMetaType<QVideoFrame>();
15}
16
18{
19 if (m_active == active)
20 return;
21
22 if (!setActiveInternal(active))
23 return;
24
25 m_active = active;
26 emit activeChanged(active);
27}
28
30{
31 return m_active;
32}
33
35{
36 Q_ASSERT(source.index() == m_source.index());
37
38 if (m_source == source)
39 return;
40
41 if (m_active)
42 setActiveInternal(false);
43
44 m_source = source;
45
46 if (m_active && !setActiveInternal(true)) {
47 m_active = false;
48 emit activeChanged(false);
49 }
50
51 std::visit([this](auto source) { emit sourceChanged(source); }, m_source);
52}
53
58
60{
61 return m_error.description();
62}
63
65{
66 m_error.setAndNotify(error, errorString, *this);
67}
68
70{
71 if (!screen)
73
74 if (screen)
75 return true;
76
77 updateError(NotFound, QLatin1String("No screens found"));
78 return false;
79}
80
82
83#include "moc_qplatformsurfacecapture_p.cpp"
void setAndNotify(ErrorCode code, QString description, Notifier &notifier)
ErrorCode code() const
QString description() const
QScreen * primaryScreen
the primary (or default) screen of the application.
void sourceChanged(WindowSource)
void updateError(Error error, const QString &errorString)
std::variant< ScreenSource, WindowSource > Source
void setActive(bool active) override
virtual bool setActiveInternal(bool)=0
QPlatformSurfaceCapture(Source initialSource)
bool checkScreenWithError(ScreenSource &screen)
QString errorString() const final
void activeChanged(bool)
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
Combined button and popup list for selecting options.
DBusConnection const char DBusError * error
GLsizei GLsizei GLchar * source
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
QLatin1StringView QLatin1String
Definition qstringfwd.h:31
QScreen * screen
[1]
Definition main.cpp:29
#define emit