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