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
qquickscreencapture.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
"qquickscreencapture_p.h"
5
6
QT_BEGIN_NAMESPACE
7
8
static
qreal
screenFrameRateToReal
(std::optional<qreal> frameRate)
9
{
10
return
frameRate.value_or(-1.f);
11
}
12
13
QQuickScreenCapture::QQuickScreenCapture(QObject *parent) : QScreenCapture(parent)
14
{
15
connect(
this
, &QScreenCapture::screenChanged,
this
, [
this
] {
16
emit QQuickScreenCapture::screenChanged(ensureQmlScreen());
17
});
18
}
19
20
void
QQuickScreenCapture::qmlSetScreen(QQuickScreenInfo *qmlScreen)
21
{
22
setScreen(qmlScreen ? qmlScreen->wrappedScreen() :
nullptr
);
23
}
24
25
QQuickScreenInfo *QQuickScreenCapture::ensureQmlScreen()
26
{
27
// Note QQuickApplication may recreate QQuickScreenInfo
28
// so we implement creating our own instance.
29
// TODO: perhaps, we should return null QQuickScreenInfo for null QScreen
30
if
(!m_qmlScreen || m_qmlScreen->wrappedScreen() != screen()) {
31
m_ownQmlScreen = std::make_unique<QQuickScreenInfo>(
this
, screen());
32
m_qmlScreen = m_ownQmlScreen.get();
33
}
34
35
return
m_qmlScreen;
36
}
37
38
/*!
39
\since 6.12
40
\qmlproperty real QtMultimedia::ScreenCapture::maximumFrameRate
41
42
The screen capture frame rate upper limit.
43
44
This can be set to override the capture frame rate used by default based on
45
e.g. display refresh rate, but only as an upper limit since screen capture
46
produces frames at a variable rate. Setting this higher than the display
47
refresh rate is not recommended and can cause errors.
48
49
If -1, a platform-dependent default is used.
50
51
Any changes to this property are applied the next time the ScreenCapture
52
goes active.
53
*/
54
55
void
QQuickScreenCapture::qmlSetMaximumFrameRate(qreal frameRate)
56
{
57
if
(qFuzzyCompare(frameRate,
static_cast
<qreal>(-1.f)))
58
setMaximumFrameRate(std::nullopt);
59
else
if
(frameRate > 0.f)
60
setMaximumFrameRate(frameRate);
61
}
62
63
qreal QQuickScreenCapture::qmlMaximumFrameRate()
const
64
{
65
return
screenFrameRateToReal(maximumFrameRate());
66
}
67
68
void
QQuickScreenCapture::qmlResetMaximumFrameRate()
69
{
70
setMaximumFrameRate(std::nullopt);
71
}
72
73
QT_END_NAMESPACE
74
75
#
include
"moc_qquickscreencapture_p.cpp"
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
screenFrameRateToReal
static QT_BEGIN_NAMESPACE qreal screenFrameRateToReal(std::optional< qreal > frameRate)
Definition
qquickscreencapture.cpp:8
qtmultimedia
src
multimediaquick
qquickscreencapture.cpp
Generated on
for Qt by
1.16.1