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 plugins 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 QDECLARATIVECAMERAFOCUS_H
41#define QDECLARATIVECAMERAFOCUS_H
42
43//
44// W A R N I N G
45// -------------
46//
47// This file is not part of the Qt API. It exists for the convenience
48// of other Qt classes. This header file may change from version to
49// version without notice, or even be removed.
50//
51// We mean it.
52//
53
54#include <QtCore/qabstractitemmodel.h>
55#include <qcamera.h>
56#include <qcamerafocus.h>
57#include "qdeclarativecamera_p.h"
58
59QT_BEGIN_NAMESPACE
60
61class FocusZonesModel;
62class QDeclarativeCamera;
63
64class QDeclarativeCameraFocus : public QObject
65{
66 Q_OBJECT
67
68 Q_PROPERTY(FocusMode focusMode READ focusMode WRITE setFocusMode NOTIFY focusModeChanged)
69 Q_PROPERTY(QVariantList supportedFocusModes READ supportedFocusModes NOTIFY supportedFocusModesChanged REVISION 1)
70
71 Q_PROPERTY(FocusPointMode focusPointMode READ focusPointMode WRITE setFocusPointMode NOTIFY focusPointModeChanged)
72 Q_PROPERTY(QVariantList supportedFocusPointModes READ supportedFocusPointModes NOTIFY supportedFocusPointModesChanged REVISION 1)
73
74 Q_PROPERTY(QPointF customFocusPoint READ customFocusPoint WRITE setCustomFocusPoint NOTIFY customFocusPointChanged)
75 Q_PROPERTY(QObject *focusZones READ focusZones CONSTANT)
76
77 Q_ENUMS(FocusMode)
78 Q_ENUMS(FocusPointMode)
79public:
80 enum FocusMode {
81 FocusManual = QCameraFocus::ManualFocus,
82 FocusHyperfocal = QCameraFocus::HyperfocalFocus,
83 FocusInfinity = QCameraFocus::InfinityFocus,
84 FocusAuto = QCameraFocus::AutoFocus,
85 FocusContinuous = QCameraFocus::ContinuousFocus,
86 FocusMacro = QCameraFocus::MacroFocus
87 };
88
89 enum FocusPointMode {
90 FocusPointAuto = QCameraFocus::FocusPointAuto,
91 FocusPointCenter = QCameraFocus::FocusPointCenter,
92 FocusPointFaceDetection = QCameraFocus::FocusPointFaceDetection,
93 FocusPointCustom = QCameraFocus::FocusPointCustom
94 };
95
96 ~QDeclarativeCameraFocus();
97
98 FocusMode focusMode() const;
99 QVariantList supportedFocusModes() const;
100
101 FocusPointMode focusPointMode() const;
102 QVariantList supportedFocusPointModes() const;
103
104 QPointF customFocusPoint() const;
105 QAbstractListModel *focusZones() const;
106
107#if QT_DEPRECATED_SINCE(5, 10)
108 Q_INVOKABLE bool isFocusModeSupported(FocusMode mode) const;
109 Q_INVOKABLE bool isFocusPointModeSupported(FocusPointMode mode) const;
110#endif
111
112public Q_SLOTS:
113 void setFocusMode(FocusMode);
114 void setFocusPointMode(FocusPointMode mode);
115 void setCustomFocusPoint(const QPointF &point);
116
117Q_SIGNALS:
118 void focusModeChanged(FocusMode);
119 void supportedFocusModesChanged();
120 void focusPointModeChanged(FocusPointMode);
121 void supportedFocusPointModesChanged();
122 void customFocusPointChanged(const QPointF &);
123
124private Q_SLOTS:
125 void updateFocusZones();
126
127private:
128 friend class QDeclarativeCamera;
129 QDeclarativeCameraFocus(QCamera *camera, QObject *parent = 0);
130
131 QCameraFocus *m_focus;
132 FocusZonesModel *m_focusZones;
133};
134
135class FocusZonesModel : public QAbstractListModel
136{
137Q_OBJECT
138public:
139 enum FocusZoneRoles {
140 StatusRole = Qt::UserRole + 1,
141 AreaRole
142 };
143
144 FocusZonesModel(QObject *parent = 0);
145
146 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
147 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
148 QHash<int,QByteArray> roleNames() const override;
149
150public slots:
151 void setFocusZones(const QCameraFocusZoneList &zones);
152
153private:
154 QCameraFocusZoneList m_focusZones;
155};
156
157
158QT_END_NAMESPACE
159
160QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QDeclarativeCameraFocus))
161
162#endif
163

source code of qtmultimedia/src/imports/multimedia/qdeclarativecamerafocus_p.h