Added QML API for getting the limits for a specific radio band.
Using properties for the frequency step, minimum and maximum frequency of the currently selected band. Also updated the declarative-radio example to use the minimum and maximum frequencies to show a tuner band for the radio. Change-Id: I9f28f10e98e008c14b10bdc12b0727086cd45f0b Reviewed-on: http://codereview.qt.nokia.com/3829 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Dmytro Poplavskiy <dmytro.poplavskiy@nokia.com>
This commit is contained in:
@@ -46,11 +46,13 @@ Rectangle {
|
||||
|
||||
Radio {
|
||||
id: radio
|
||||
band: Radio.FM
|
||||
}
|
||||
|
||||
Column {
|
||||
anchors.fill: parent
|
||||
anchors.margins: 5
|
||||
spacing: 5
|
||||
|
||||
Row {
|
||||
|
||||
@@ -61,7 +63,7 @@ Rectangle {
|
||||
height: 200
|
||||
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
text: "" + radio.frequency / 1000 + " kHz";
|
||||
text: "" + radio.frequency / 1000 + " kHz"
|
||||
}
|
||||
Text {
|
||||
id: sig
|
||||
@@ -74,6 +76,28 @@ Rectangle {
|
||||
}
|
||||
}
|
||||
|
||||
Row {
|
||||
spacing: 5
|
||||
|
||||
Rectangle {
|
||||
width: 350
|
||||
height: 10
|
||||
|
||||
color: "black"
|
||||
|
||||
Rectangle {
|
||||
width: 5
|
||||
height: 10
|
||||
color: "red"
|
||||
|
||||
y: 0
|
||||
x: (parent.width - 5) * ((radio.frequency - radio.minimumFrequency) / (radio.maximumFrequency -
|
||||
radio.minimumFrequency))
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Row {
|
||||
spacing: 5
|
||||
@@ -119,7 +143,7 @@ Rectangle {
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
var f = radio.frequency;
|
||||
f = f - radio.frequencyStep(Radio.FM);
|
||||
f = f - radio.frequencyStep;
|
||||
radio.setFrequency(f);
|
||||
}
|
||||
}
|
||||
@@ -144,7 +168,7 @@ Rectangle {
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
var f = radio.frequency;
|
||||
f = f + radio.frequencyStep(Radio.FM);
|
||||
f = f + radio.frequencyStep;
|
||||
radio.setFrequency(f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,16 +111,26 @@ bool QDeclarativeRadio::searching() const
|
||||
return m_radioTuner->isSearching();
|
||||
}
|
||||
|
||||
int QDeclarativeRadio::frequencyStep() const
|
||||
{
|
||||
return m_radioTuner->frequencyStep(m_radioTuner->band());
|
||||
}
|
||||
|
||||
int QDeclarativeRadio::minimumFrequency() const
|
||||
{
|
||||
return m_radioTuner->frequencyRange(m_radioTuner->band()).first;
|
||||
}
|
||||
|
||||
int QDeclarativeRadio::maximumFrequency() const
|
||||
{
|
||||
return m_radioTuner->frequencyRange(m_radioTuner->band()).second;
|
||||
}
|
||||
|
||||
bool QDeclarativeRadio::isAvailable() const
|
||||
{
|
||||
return m_radioTuner->isAvailable();
|
||||
}
|
||||
|
||||
int QDeclarativeRadio::frequencyStep(QDeclarativeRadio::Band band) const
|
||||
{
|
||||
return m_radioTuner->frequencyStep(static_cast<QRadioTuner::Band>(band));
|
||||
}
|
||||
|
||||
void QDeclarativeRadio::setBand(QDeclarativeRadio::Band band)
|
||||
{
|
||||
m_radioTuner->setBand(static_cast<QRadioTuner::Band>(band));
|
||||
|
||||
@@ -72,6 +72,9 @@ class QDeclarativeRadio : public QObject
|
||||
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_ENUMS(State)
|
||||
Q_ENUMS(Band)
|
||||
Q_ENUMS(Error)
|
||||
@@ -118,8 +121,11 @@ public:
|
||||
int signalStrength() const;
|
||||
bool searching() const;
|
||||
|
||||
int frequencyStep() const;
|
||||
int minimumFrequency() const;
|
||||
int maximumFrequency() const;
|
||||
|
||||
Q_INVOKABLE bool isAvailable() const;
|
||||
Q_INVOKABLE int frequencyStep(QDeclarativeRadio::Band band) const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void setBand(QDeclarativeRadio::Band band);
|
||||
|
||||
Reference in New Issue
Block a user