diff options
author | Michael Goddard <michael.goddard@nokia.com> | 2012-03-02 00:21:04 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-03-02 09:30:34 +0100 |
commit | 2a8463711c7fd683ddf46f716bfff47c1603e863 (patch) | |
tree | 88a504ca27afe1891cce66f678cee5be9cba7993 /src/imports/multimedia/qdeclarativeradio.cpp | |
parent | d1b6bf5fac54a39d911079ba792ca95424c5c70c (diff) |
Expose availability from the backend to C++ and QML.
The availabilityError property was static based on the service, but it
can change at run time, so add the plumbing to allow the backend to
report it itself.
Also make sure that both QML and C++ expose the availability.
The radio tuner and data controls previously had properties (but no
signals) for availability - these have been removed.
Change-Id: I9240cf93e2a51b14cd38642f9312ae3c75f05361
Reviewed-by: Ling Hu <ling.hu@nokia.com>
Diffstat (limited to 'src/imports/multimedia/qdeclarativeradio.cpp')
-rw-r--r-- | src/imports/multimedia/qdeclarativeradio.cpp | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/src/imports/multimedia/qdeclarativeradio.cpp b/src/imports/multimedia/qdeclarativeradio.cpp index c029cae12..1c7ea4cae 100644 --- a/src/imports/multimedia/qdeclarativeradio.cpp +++ b/src/imports/multimedia/qdeclarativeradio.cpp @@ -112,6 +112,9 @@ QDeclarativeRadio::QDeclarativeRadio(QObject *parent) : connect(m_radioTuner, SIGNAL(stationFound(int, QString)), this, SIGNAL(stationFound(int, QString))); connect(m_radioTuner, SIGNAL(antennaConnectedChanged(bool)), this, SIGNAL(antennaConnectedChanged(bool))); + // Note we map availabilityError->availability + connect(m_radioTuner, SIGNAL(availabilityErrorChanged(QtMultimedia::AvailabilityError)), this, SLOT(_q_availabilityChanged(QtMultimedia::AvailabilityError))); + connect(m_radioTuner, SIGNAL(error(QRadioTuner::Error)), this, SLOT(_q_error(QRadioTuner::Error))); } @@ -306,13 +309,33 @@ bool QDeclarativeRadio::isAntennaConnected() const } /*! - \qmlmethod bool QtMultimedia5::Radio::isAvailable() + \qmlproperty enumeration QtMultimedia5::Radio::availability + + Returns the availability state of the radio. + + This is one of: - Returns whether the radio is ready to use. + \table + \header \li Value \li Description + \row \li Available + \li The radio is available to use + \row \li Busy + \li The radio is usually available to use, but is currently busy. + This can happen when some other process needs to use the audio + hardware. + \row \li Unavailable + \li The radio is not available to use (there may be no radio + hardware) + \row \li ResourceMissing + \li There is one or more resources missing, so the radio cannot + be used. It may be possible to try again at a later time. This + can occur if there is no antenna connected - see the \l antennaConnected + property as well. + \endtable */ -bool QDeclarativeRadio::isAvailable() const +QDeclarativeRadio::Availability QDeclarativeRadio::availability() const { - return m_radioTuner->isAvailable(); + return Availability(m_radioTuner->availabilityError()); } void QDeclarativeRadio::setBand(QDeclarativeRadio::Band band) @@ -462,7 +485,7 @@ void QDeclarativeRadio::tuneUp() /*! \qmlmethod QtMultimedia5::Radio::start() - Starts the radio. If the radio is available, as determined by the \l isAvailable method, + Starts the radio. If the radio is available, as determined by the \l availability property, this will result in the \l state becoming \c ActiveState. */ void QDeclarativeRadio::start() @@ -496,6 +519,11 @@ void QDeclarativeRadio::_q_error(QRadioTuner::Error errorCode) emit errorChanged(); } +void QDeclarativeRadio::_q_availabilityChanged(QtMultimedia::AvailabilityError error) +{ + emit availabilityChanged(Availability(error)); +} + /*! \qmlsignal QtMultimedia5::Radio::stationFound(int frequency, string stationId) |