summaryrefslogtreecommitdiffstats
path: root/src/imports/multimedia/qdeclarativeradio_p.h
blob: e7fcde13b790a04e73631cbd7a853821dedcdd7b (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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
/****************************************************************************
**
** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:COMM$
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** $QT_END_LICENSE$
**
**
**
**
**
**
**
**
**
**
**
**
**
**
**
**
**
**
**
****************************************************************************/

#ifndef QDECLARATIVERADIO_P_H
#define QDECLARATIVERADIO_P_H

//
//  W A R N I N G
//  -------------
//
// This file is not part of the Qt API.  It exists for the convenience
// of other Qt classes.  This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//

#include <qradiotuner.h>
#include <QtQml/qqml.h>

QT_BEGIN_NAMESPACE

class QDeclarativeRadioData;

class QDeclarativeRadio : public QObject
{
    Q_OBJECT
    Q_PROPERTY(State state READ state NOTIFY stateChanged)
    Q_PROPERTY(Band band READ band WRITE setBand NOTIFY bandChanged)
    Q_PROPERTY(int frequency READ frequency WRITE setFrequency NOTIFY frequencyChanged)
    Q_PROPERTY(bool stereo READ stereo NOTIFY stereoStatusChanged)
    Q_PROPERTY(StereoMode stereoMode READ stereoMode WRITE setStereoMode)
    Q_PROPERTY(int signalStrength READ signalStrength NOTIFY signalStrengthChanged)
    Q_PROPERTY(int volume READ volume WRITE setVolume NOTIFY volumeChanged)
    Q_PROPERTY(bool muted READ muted WRITE setMuted NOTIFY mutedChanged)
    Q_PROPERTY(bool searching READ searching NOTIFY searchingChanged)
    Q_PROPERTY(int frequencyStep READ frequencyStep NOTIFY bandChanged)
    Q_PROPERTY(int minimumFrequency READ minimumFrequency NOTIFY bandChanged)
    Q_PROPERTY(int maximumFrequency READ maximumFrequency NOTIFY bandChanged)
    Q_PROPERTY(bool antennaConnected READ isAntennaConnected NOTIFY antennaConnectedChanged)
    Q_PROPERTY(Availability availability READ availability NOTIFY availabilityChanged)
    Q_PROPERTY(QDeclarativeRadioData* radioData READ radioData CONSTANT)
    Q_ENUMS(State)
    Q_ENUMS(Band)
    Q_ENUMS(Error)
    Q_ENUMS(StereoMode)
    Q_ENUMS(SearchMode)
    Q_ENUMS(Availability)

public:
    enum State {
        ActiveState = QRadioTuner::ActiveState,
        StoppedState = QRadioTuner::StoppedState
    };

    enum Band {
        AM = QRadioTuner::AM,
        FM = QRadioTuner::FM,
        SW = QRadioTuner::SW,
        LW = QRadioTuner::LW,
        FM2 = QRadioTuner::FM2
    };

    enum Error {
        NoError = QRadioTuner::NoError,
        ResourceError = QRadioTuner::ResourceError,
        OpenError = QRadioTuner::OpenError,
        OutOfRangeError = QRadioTuner::OutOfRangeError
    };

    enum StereoMode {
        ForceStereo = QRadioTuner::ForceStereo,
        ForceMono = QRadioTuner::ForceMono,
        Auto = QRadioTuner::Auto
    };

    enum SearchMode {
        SearchFast = QRadioTuner::SearchFast,
        SearchGetStationId = QRadioTuner::SearchGetStationId
    };

    enum Availability {
        Available = QMultimedia::Available,
        Busy = QMultimedia::Busy,
        Unavailable = QMultimedia::ServiceMissing,
        ResourceMissing = QMultimedia::ResourceError
    };

    QDeclarativeRadio(QObject *parent = 0);
    ~QDeclarativeRadio();

    QDeclarativeRadio::State state() const;
    QDeclarativeRadio::Band band() const;
    int frequency() const;
    QDeclarativeRadio::StereoMode stereoMode() const;
    int volume() const;
    bool muted() const;

    bool stereo() const;
    int signalStrength() const;
    bool searching() const;

    int frequencyStep() const;
    int minimumFrequency() const;
    int maximumFrequency() const;

    bool isAntennaConnected() const;

    Q_INVOKABLE bool isAvailable() const {return availability() == Available;}
    Availability availability() const;

    QDeclarativeRadioData *radioData() { return m_radioData; }

public Q_SLOTS:
    void setBand(QDeclarativeRadio::Band band);
    void setFrequency(int frequency);
    void setStereoMode(QDeclarativeRadio::StereoMode stereoMode);
    void setVolume(int volume);
    void setMuted(bool muted);

    void cancelScan();
    void scanDown();
    void scanUp();
    void tuneUp();
    void tuneDown();
    void searchAllStations(QDeclarativeRadio::SearchMode searchMode = QDeclarativeRadio::SearchFast );

    void start();
    void stop();

Q_SIGNALS:
    void stateChanged(QDeclarativeRadio::State state);
    void bandChanged(QDeclarativeRadio::Band band);
    void frequencyChanged(int frequency);
    void stereoStatusChanged(bool stereo);
    void searchingChanged(bool searching);
    void signalStrengthChanged(int signalStrength);
    void volumeChanged(int volume);
    void mutedChanged(bool muted);
    void stationFound(int frequency, QString stationId);
    void antennaConnectedChanged(bool connectionStatus);

    void availabilityChanged(Availability availability);

    void errorChanged();
    void error(QDeclarativeRadio::Error errorCode);

private Q_SLOTS:
    void _q_stateChanged(QRadioTuner::State state);
    void _q_bandChanged(QRadioTuner::Band band);
    void _q_error(QRadioTuner::Error errorCode);
    void _q_availabilityChanged(QMultimedia::AvailabilityStatus);

private:
    Q_DISABLE_COPY(QDeclarativeRadio)

    QRadioTuner *m_radioTuner;
    QDeclarativeRadioData *m_radioData;
};

QT_END_NAMESPACE

QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QDeclarativeRadio))

#endif // QDECLARATIVERADIO_P_H