summaryrefslogtreecommitdiffstats
path: root/src/multimedia/recording/qcapturablewindow.cpp
blob: 34b6a1f5d191f2047b1fb85939abc65a7673846e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#include "qcapturablewindow.h"
#include "qcapturablewindow_p.h"
#include "qplatformmediaintegration_p.h"

QT_BEGIN_NAMESPACE

QT_DEFINE_QESDP_SPECIALIZATION_DTOR(QCapturableWindowPrivate)

/*!
    \class QCapturableWindow
    \inmodule QtMultimedia
    \ingroup multimedia
    \ingroup multimedia_video
    \since 6.6

    \brief Used for getting the basic information of a capturable window.

    The class contains a set of window information, except the method
    QCapturableWindow::isValid which pulls the current state
    whenever it's called.

    \sa QWindowCapture
*/
/*!
    \qmlvaluetype CapturableWindow
    \instantiates QCapturableWindow
    \brief The CapturableWindow type is used getting basic
    of a window that is available for capturing via WindowCapture.

    \inqmlmodule QtMultimedia
    \ingroup multimedia_qml
    \ingroup multimedia_video_qml
    \since 6.6

    The class contains a dump of window information, except the property
    'isValid' which pulls the actual window state every time.

    \sa WindowCapture
*/

/*!
    \fn  QCapturableWindow::QCapturableWindow(QCapturableWindow &&other)

    Constructs a QCapturableWindow by moving from \a other.
*/

/*!
    \fn void QCapturableWindow::swap(QCapturableWindow &other) noexcept

    Swaps the current window information with \a other.
*/

/*!
    \fn  QCapturableWindow &QCapturableWindow::operator=(QCapturableWindow &&other)

    Moves \a other into this QCapturableWindow.
*/

/*!
    Constructs a null capturable window information that doesn't refer to any window.
*/
QCapturableWindow::QCapturableWindow() = default;

/*!
    Destroys the window information.
 */
QCapturableWindow::~QCapturableWindow() = default;

/*!
    Construct a new window information using \a other QCapturableWindow.
*/
QCapturableWindow::QCapturableWindow(const QCapturableWindow &other) = default;

/*!
    Assigns the \a other window information to this QCapturableWindow.
*/
QCapturableWindow& QCapturableWindow::operator=(const QCapturableWindow &other) = default;

/*!
    \fn bool QCapturableWindow::operator==(const QCapturableWindow &lhs, const QCapturableWindow &rhs)

    Returns \c true if window information \a lhs and \a rhs refer to the same window,
    otherwise returns \c false.
*/

/*!
    \fn bool QCapturableWindow::operator!=(const QCapturableWindow &lhs, const QCapturableWindow &rhs)

    Returns \c true if window information \a lhs and \a rhs refer to different windows,
    otherwise returns \c false.
*/
bool operator==(const QCapturableWindow &lhs, const QCapturableWindow &rhs) noexcept
{
    return lhs.d == rhs.d || (lhs.d && rhs.d && lhs.d->id == rhs.d->id);
}

/*!
    \qmlproperty string QtMultimedia::CapturableWindow::isValid

    This property identifies whether a window information is valid.

    An invalid window information refers to non-existing window or doesn't refer to any one.
*/

/*!
    Identifies whether a window information is valid.

    An invalid window information refers to non-existing window or doesn't refer to any one.

    Returns true if the window is valid, and false if it is not.
*/
bool QCapturableWindow::isValid() const
{
    return d && QPlatformMediaIntegration::instance()->isCapturableWindowValid(*d);
}

/*!
    \qmlproperty string QtMultimedia::CapturableWindow::description

    This property holds the description of the reffered window.
*/

/*!
    Returns a description of the window. In most cases it represents the window title.
*/
QString QCapturableWindow::description() const
{
    if (!d)
        return {};

    if (d->description.isEmpty() && d->id)
        return QLatin1String("Window 0x") + QString::number(d->id, 16);

    return d->description;
}

QCapturableWindow::QCapturableWindow(QCapturableWindowPrivate *capturablePrivate)
    : d(capturablePrivate)
{
}

#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QCapturableWindow &window)
{
    dbg << QStringLiteral("Capturable window '%1'").arg(window.description());
    return dbg;
}
#endif


QT_END_NAMESPACE

#include "moc_qcapturablewindow.cpp"