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 QDECLARATIVERADIO_P_H
41#define QDECLARATIVERADIO_P_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 <qradiotuner.h>
55#include <QtQml/qqml.h>
56
57QT_BEGIN_NAMESPACE
58
59class QDeclarativeRadioData;
60
61class QDeclarativeRadio : public QObject
62{
63 Q_OBJECT
64 Q_PROPERTY(State state READ state NOTIFY stateChanged)
65 Q_PROPERTY(Band band READ band WRITE setBand NOTIFY bandChanged)
66 Q_PROPERTY(int frequency READ frequency WRITE setFrequency NOTIFY frequencyChanged)
67 Q_PROPERTY(bool stereo READ stereo NOTIFY stereoStatusChanged)
68 Q_PROPERTY(StereoMode stereoMode READ stereoMode WRITE setStereoMode)
69 Q_PROPERTY(int signalStrength READ signalStrength NOTIFY signalStrengthChanged)
70 Q_PROPERTY(int volume READ volume WRITE setVolume NOTIFY volumeChanged)
71 Q_PROPERTY(bool muted READ muted WRITE setMuted NOTIFY mutedChanged)
72 Q_PROPERTY(bool searching READ searching NOTIFY searchingChanged)
73 Q_PROPERTY(int frequencyStep READ frequencyStep NOTIFY bandChanged)
74 Q_PROPERTY(int minimumFrequency READ minimumFrequency NOTIFY bandChanged)
75 Q_PROPERTY(int maximumFrequency READ maximumFrequency NOTIFY bandChanged)
76 Q_PROPERTY(bool antennaConnected READ isAntennaConnected NOTIFY antennaConnectedChanged)
77 Q_PROPERTY(Availability availability READ availability NOTIFY availabilityChanged)
78 Q_PROPERTY(QDeclarativeRadioData* radioData READ radioData CONSTANT)
79 Q_ENUMS(State)
80 Q_ENUMS(Band)
81 Q_ENUMS(Error)
82 Q_ENUMS(StereoMode)
83 Q_ENUMS(SearchMode)
84 Q_ENUMS(Availability)
85
86public:
87 enum State {
88 ActiveState = QRadioTuner::ActiveState,
89 StoppedState = QRadioTuner::StoppedState
90 };
91
92 enum Band {
93 AM = QRadioTuner::AM,
94 FM = QRadioTuner::FM,
95 SW = QRadioTuner::SW,
96 LW = QRadioTuner::LW,
97 FM2 = QRadioTuner::FM2
98 };
99
100 enum Error {
101 NoError = QRadioTuner::NoError,
102 ResourceError = QRadioTuner::ResourceError,
103 OpenError = QRadioTuner::OpenError,
104 OutOfRangeError = QRadioTuner::OutOfRangeError
105 };
106
107 enum StereoMode {
108 ForceStereo = QRadioTuner::ForceStereo,
109 ForceMono = QRadioTuner::ForceMono,
110 Auto = QRadioTuner::Auto
111 };
112
113 enum SearchMode {
114 SearchFast = QRadioTuner::SearchFast,
115 SearchGetStationId = QRadioTuner::SearchGetStationId
116 };
117
118 enum Availability {
119 Available = QMultimedia::Available,
120 Busy = QMultimedia::Busy,
121 Unavailable = QMultimedia::ServiceMissing,
122 ResourceMissing = QMultimedia::ResourceError
123 };
124
125 QDeclarativeRadio(QObject *parent = 0);
126 ~QDeclarativeRadio();
127
128 QDeclarativeRadio::State state() const;
129 QDeclarativeRadio::Band band() const;
130 int frequency() const;
131 QDeclarativeRadio::StereoMode stereoMode() const;
132 int volume() const;
133 bool muted() const;
134
135 bool stereo() const;
136 int signalStrength() const;
137 bool searching() const;
138
139 int frequencyStep() const;
140 int minimumFrequency() const;
141 int maximumFrequency() const;
142
143 bool isAntennaConnected() const;
144
145 Q_INVOKABLE bool isAvailable() const {return availability() == Available;}
146 Availability availability() const;
147
148 QDeclarativeRadioData *radioData() { return m_radioData; }
149
150public Q_SLOTS:
151 void setBand(QDeclarativeRadio::Band band);
152 void setFrequency(int frequency);
153 void setStereoMode(QDeclarativeRadio::StereoMode stereoMode);
154 void setVolume(int volume);
155 void setMuted(bool muted);
156
157 void cancelScan();
158 void scanDown();
159 void scanUp();
160 void tuneUp();
161 void tuneDown();
162 void searchAllStations(QDeclarativeRadio::SearchMode searchMode = QDeclarativeRadio::SearchFast );
163
164 void start();
165 void stop();
166
167Q_SIGNALS:
168 void stateChanged(QDeclarativeRadio::State state);
169 void bandChanged(QDeclarativeRadio::Band band);
170 void frequencyChanged(int frequency);
171 void stereoStatusChanged(bool stereo);
172 void searchingChanged(bool searching);
173 void signalStrengthChanged(int signalStrength);
174 void volumeChanged(int volume);
175 void mutedChanged(bool muted);
176 void stationFound(int frequency, QString stationId);
177 void antennaConnectedChanged(bool connectionStatus);
178
179 void availabilityChanged(Availability availability);
180
181 void errorChanged();
182 void error(QDeclarativeRadio::Error errorCode);
183
184private Q_SLOTS:
185 void _q_stateChanged(QRadioTuner::State state);
186 void _q_bandChanged(QRadioTuner::Band band);
187 void _q_error(QRadioTuner::Error errorCode);
188 void _q_availabilityChanged(QMultimedia::AvailabilityStatus);
189
190private:
191 Q_DISABLE_COPY(QDeclarativeRadio)
192
193 QRadioTuner *m_radioTuner;
194 QDeclarativeRadioData *m_radioData;
195};
196
197QT_END_NAMESPACE
198
199QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QDeclarativeRadio))
200
201#endif // QDECLARATIVERADIO_P_H
202

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