1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#ifndef QCAMERAFOCUS_H
41#define QCAMERAFOCUS_H
42
43#include <QtCore/qstringlist.h>
44#include <QtCore/qpair.h>
45#include <QtCore/qsize.h>
46#include <QtCore/qpoint.h>
47#include <QtCore/qrect.h>
48#include <QtCore/qshareddata.h>
49
50#include <QtMultimedia/qmediaobject.h>
51#include <QtMultimedia/qmediaenumdebug.h>
52
53QT_BEGIN_NAMESPACE
54
55
56class QCamera;
57
58class QCameraFocusZoneData;
59
60class Q_MULTIMEDIA_EXPORT QCameraFocusZone {
61public:
62 enum FocusZoneStatus {
63 Invalid,
64 Unused,
65 Selected,
66 Focused
67 };
68
69 QCameraFocusZone();
70 QCameraFocusZone(const QRectF &area, FocusZoneStatus status = Selected);
71 QCameraFocusZone(const QCameraFocusZone &other);
72
73 QCameraFocusZone& operator=(const QCameraFocusZone &other);
74 bool operator==(const QCameraFocusZone &other) const;
75 bool operator!=(const QCameraFocusZone &other) const;
76
77 ~QCameraFocusZone();
78
79 bool isValid() const;
80
81 QRectF area() const;
82
83 FocusZoneStatus status() const;
84 void setStatus(FocusZoneStatus status);
85
86private:
87 QSharedDataPointer<QCameraFocusZoneData> d;
88};
89
90typedef QList<QCameraFocusZone> QCameraFocusZoneList;
91
92
93class QCameraFocusPrivate;
94class Q_MULTIMEDIA_EXPORT QCameraFocus : public QObject
95{
96 Q_OBJECT
97
98 Q_PROPERTY(FocusModes focusMode READ focusMode WRITE setFocusMode)
99 Q_PROPERTY(FocusPointMode focusPointMode READ focusPointMode WRITE setFocusPointMode)
100 Q_PROPERTY(QPointF customFocusPoint READ customFocusPoint WRITE setCustomFocusPoint)
101 Q_PROPERTY(QCameraFocusZoneList focusZones READ focusZones NOTIFY focusZonesChanged)
102 Q_PROPERTY(qreal opticalZoom READ opticalZoom NOTIFY opticalZoomChanged)
103 Q_PROPERTY(qreal digitalZoom READ digitalZoom NOTIFY digitalZoomChanged)
104
105 Q_ENUMS(FocusMode)
106 Q_ENUMS(FocusPointMode)
107public:
108 enum FocusMode {
109 ManualFocus = 0x1,
110 HyperfocalFocus = 0x02,
111 InfinityFocus = 0x04,
112 AutoFocus = 0x8,
113 ContinuousFocus = 0x10,
114 MacroFocus = 0x20
115 };
116 Q_DECLARE_FLAGS(FocusModes, FocusMode)
117
118 enum FocusPointMode {
119 FocusPointAuto,
120 FocusPointCenter,
121 FocusPointFaceDetection,
122 FocusPointCustom
123 };
124
125 bool isAvailable() const;
126
127 FocusModes focusMode() const;
128 void setFocusMode(FocusModes mode);
129 bool isFocusModeSupported(FocusModes mode) const;
130
131 FocusPointMode focusPointMode() const;
132 void setFocusPointMode(FocusPointMode mode);
133 bool isFocusPointModeSupported(FocusPointMode) const;
134 QPointF customFocusPoint() const;
135 void setCustomFocusPoint(const QPointF &point);
136
137 QCameraFocusZoneList focusZones() const;
138
139 qreal maximumOpticalZoom() const;
140 qreal maximumDigitalZoom() const;
141 qreal opticalZoom() const;
142 qreal digitalZoom() const;
143
144 void zoomTo(qreal opticalZoom, qreal digitalZoom);
145
146Q_SIGNALS:
147 void opticalZoomChanged(qreal);
148 void digitalZoomChanged(qreal);
149
150 void focusZonesChanged();
151
152 void maximumOpticalZoomChanged(qreal);
153 void maximumDigitalZoomChanged(qreal);
154
155protected:
156 ~QCameraFocus();
157
158private:
159 friend class QCamera;
160 friend class QCameraPrivate;
161 QCameraFocus(QCamera *camera);
162
163 Q_DISABLE_COPY(QCameraFocus)
164 Q_DECLARE_PRIVATE(QCameraFocus)
165#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
166 QCameraFocusPrivate *d_ptr_deprecated;
167#endif
168};
169
170Q_DECLARE_OPERATORS_FOR_FLAGS(QCameraFocus::FocusModes)
171
172QT_END_NAMESPACE
173
174Q_DECLARE_METATYPE(QCameraFocus::FocusModes)
175Q_DECLARE_METATYPE(QCameraFocus::FocusPointMode)
176
177Q_MEDIA_ENUM_DEBUG(QCameraFocus, FocusMode)
178Q_MEDIA_ENUM_DEBUG(QCameraFocus, FocusPointMode)
179
180#endif // QCAMERAFOCUS_H
181

source code of qtmultimedia/src/multimedia/camera/qcamerafocus.h