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