diff options
author | David Boddie <dboddie@trolltech.com> | 2009-12-15 20:00:18 (GMT) |
---|---|---|
committer | David Boddie <dboddie@trolltech.com> | 2009-12-15 20:00:18 (GMT) |
commit | 2a2dec6666f8f38e9240784b423ce69b18e1064e (patch) | |
tree | 1d0c26a71355cc248359ed8b39b6d0c5a5729ae5 /examples/multimedia/audiodevices | |
parent | bf634fe70500d360d478d88ca70743f563673501 (diff) | |
download | Qt-2a2dec6666f8f38e9240784b423ce69b18e1064e.zip Qt-2a2dec6666f8f38e9240784b423ce69b18e1064e.tar.gz Qt-2a2dec6666f8f38e9240784b423ce69b18e1064e.tar.bz2 |
Doc: Modified the coding style of the Audio Devices example.
This commit will be a duplicate of the same change applied elsewhere.
Reviewed-by: Kurt Korbatits
Diffstat (limited to 'examples/multimedia/audiodevices')
4 files changed, 84 insertions, 69 deletions
diff --git a/examples/multimedia/audiodevices/audiodevices.cpp b/examples/multimedia/audiodevices/audiodevices.cpp index e205e03..45c7a53 100644 --- a/examples/multimedia/audiodevices/audiodevices.cpp +++ b/examples/multimedia/audiodevices/audiodevices.cpp @@ -40,45 +40,33 @@ ****************************************************************************/ -#include <QDebug> #include <QAudioDeviceInfo> #include "audiodevices.h" -AudioDevicesBase::AudioDevicesBase( QMainWindow *parent, Qt::WFlags f ) +AudioDevicesBase::AudioDevicesBase(QWidget *parent, Qt::WFlags f) + : QMainWindow(parent, f) { - Q_UNUSED(parent) - Q_UNUSED(f) - setupUi( this ); + setupUi(this); } AudioDevicesBase::~AudioDevicesBase() {} -AudioTest::AudioTest( QMainWindow *parent, Qt::WFlags f ) - : AudioDevicesBase( parent, f ) +AudioTest::AudioTest(QWidget *parent, Qt::WFlags f) + : AudioDevicesBase(parent, f) { - nearestFreq->setDisabled(true); - nearestChannel->setDisabled(true); - nearestCodec->setDisabled(true); - nearestSampleSize->setDisabled(true); - nearestSampleType->setDisabled(true); - nearestEndian->setDisabled(true); - logOutput->setDisabled(true); - mode = QAudio::AudioOutput; - modeBox->addItem("Input"); - modeBox->addItem("Output"); - connect(testButton,SIGNAL(clicked()),SLOT(test())); - connect(modeBox,SIGNAL(activated(int)),SLOT(modeChanged(int))); - connect(deviceBox,SIGNAL(activated(int)),SLOT(deviceChanged(int))); - connect(frequencyBox,SIGNAL(activated(int)),SLOT(freqChanged(int))); - connect(channelsBox,SIGNAL(activated(int)),SLOT(channelChanged(int))); - connect(codecsBox,SIGNAL(activated(int)),SLOT(codecChanged(int))); - connect(sampleSizesBox,SIGNAL(activated(int)),SLOT(sampleSizeChanged(int))); - connect(sampleTypesBox,SIGNAL(activated(int)),SLOT(sampleTypeChanged(int))); - connect(endianBox,SIGNAL(activated(int)),SLOT(endianChanged(int))); + connect(testButton, SIGNAL(clicked()), SLOT(test())); + connect(modeBox, SIGNAL(activated(int)), SLOT(modeChanged(int))); + connect(deviceBox, SIGNAL(activated(int)), SLOT(deviceChanged(int))); + connect(frequencyBox, SIGNAL(activated(int)), SLOT(freqChanged(int))); + connect(channelsBox, SIGNAL(activated(int)), SLOT(channelChanged(int))); + connect(codecsBox, SIGNAL(activated(int)), SLOT(codecChanged(int))); + connect(sampleSizesBox, SIGNAL(activated(int)), SLOT(sampleSizeChanged(int))); + connect(sampleTypesBox, SIGNAL(activated(int)), SLOT(sampleTypeChanged(int))); + connect(endianBox, SIGNAL(activated(int)), SLOT(endianChanged(int))); modeBox->setCurrentIndex(0); modeChanged(0); @@ -98,7 +86,7 @@ void AudioTest::test() if (!deviceInfo.isNull()) { if (deviceInfo.isFormatSupported(settings)) { - logOutput->append("Success"); + logOutput->append(tr("Success")); nearestFreq->setText(""); nearestChannel->setText(""); nearestCodec->setText(""); @@ -136,16 +124,16 @@ void AudioTest::test() } } else - logOutput->append("No Device"); + logOutput->append(tr("No Device")); } void AudioTest::modeChanged(int idx) { // mode has changed - if(idx == 0) - mode=QAudio::AudioInput; + if (idx == 0) + mode = QAudio::AudioInput; else - mode=QAudio::AudioOutput; + mode = QAudio::AudioOutput; deviceBox->clear(); foreach (const QAudioDeviceInfo &deviceInfo, QAudioDeviceInfo::availableDevices(mode)) @@ -162,37 +150,37 @@ void AudioTest::deviceChanged(int idx) frequencyBox->clear(); QList<int> freqz = deviceInfo.supportedFrequencies(); - for(int i = 0; i < freqz.size(); ++i) + for (int i = 0; i < freqz.size(); ++i) frequencyBox->addItem(QString("%1").arg(freqz.at(i))); - if(freqz.size()) + if (freqz.size()) settings.setFrequency(freqz.at(0)); channelsBox->clear(); QList<int> chz = deviceInfo.supportedChannels(); - for(int i = 0; i < chz.size(); ++i) + for (int i = 0; i < chz.size(); ++i) channelsBox->addItem(QString("%1").arg(chz.at(i))); - if(chz.size()) + if (chz.size()) settings.setChannels(chz.at(0)); codecsBox->clear(); QStringList codecz = deviceInfo.supportedCodecs(); - for(int i = 0; i < codecz.size(); ++i) + for (int i = 0; i < codecz.size(); ++i) codecsBox->addItem(QString("%1").arg(codecz.at(i))); - if(codecz.size()) + if (codecz.size()) settings.setCodec(codecz.at(0)); // Add false to create failed condition! codecsBox->addItem("audio/test"); sampleSizesBox->clear(); QList<int> sampleSizez = deviceInfo.supportedSampleSizes(); - for(int i = 0; i < sampleSizez.size(); ++i) + for (int i = 0; i < sampleSizez.size(); ++i) sampleSizesBox->addItem(QString("%1").arg(sampleSizez.at(i))); - if(sampleSizez.size()) + if (sampleSizez.size()) settings.setSampleSize(sampleSizez.at(0)); sampleTypesBox->clear(); QList<QAudioFormat::SampleType> sampleTypez = deviceInfo.supportedSampleTypes(); - for(int i = 0; i < sampleTypez.size(); ++i) { + for (int i = 0; i < sampleTypez.size(); ++i) { switch(sampleTypez.at(i)) { case QAudioFormat::SignedInt: sampleTypesBox->addItem("SignedInt"); @@ -206,14 +194,14 @@ void AudioTest::deviceChanged(int idx) case QAudioFormat::Unknown: sampleTypesBox->addItem("Unknown"); } - if(sampleTypez.size()) + if (sampleTypez.size()) settings.setSampleType(sampleTypez.at(0)); } endianBox->clear(); QList<QAudioFormat::Endian> endianz = deviceInfo.supportedByteOrders(); - for(int i = 0; i < endianz.size(); ++i) { - switch(endianz.at(i)) { + for (int i = 0; i < endianz.size(); ++i) { + switch (endianz.at(i)) { case QAudioFormat::LittleEndian: endianBox->addItem("Little Endian"); break; @@ -222,7 +210,7 @@ void AudioTest::deviceChanged(int idx) break; } } - if(endianz.size()) + if (endianz.size()) settings.setByteOrder(endianz.at(0)); } @@ -249,7 +237,7 @@ void AudioTest::sampleSizeChanged(int idx) void AudioTest::sampleTypeChanged(int idx) { - switch(sampleTypesBox->itemText(idx).toInt()) { + switch (sampleTypesBox->itemText(idx).toInt()) { case QAudioFormat::SignedInt: settings.setSampleType(QAudioFormat::SignedInt); break; @@ -263,7 +251,7 @@ void AudioTest::sampleTypeChanged(int idx) void AudioTest::endianChanged(int idx) { - switch(endianBox->itemText(idx).toInt()) { + switch (endianBox->itemText(idx).toInt()) { case QAudioFormat::LittleEndian: settings.setByteOrder(QAudioFormat::LittleEndian); break; @@ -271,4 +259,3 @@ void AudioTest::endianChanged(int idx) settings.setByteOrder(QAudioFormat::BigEndian); } } - diff --git a/examples/multimedia/audiodevices/audiodevices.h b/examples/multimedia/audiodevices/audiodevices.h index 5fe5547..bd4b7c4 100644 --- a/examples/multimedia/audiodevices/audiodevices.h +++ b/examples/multimedia/audiodevices/audiodevices.h @@ -49,7 +49,7 @@ class AudioDevicesBase : public QMainWindow, public Ui::AudioDevicesBase { public: - AudioDevicesBase( QMainWindow *parent = 0, Qt::WFlags f = 0 ); + AudioDevicesBase(QWidget *parent = 0, Qt::WFlags f = 0); virtual ~AudioDevicesBase(); }; @@ -57,10 +57,10 @@ class AudioTest : public AudioDevicesBase { Q_OBJECT public: - AudioTest( QMainWindow *parent = 0, Qt::WFlags f = 0 ); + AudioTest(QWidget *parent = 0, Qt::WFlags f = 0); virtual ~AudioTest(); - QAudioDeviceInfo deviceInfo; + QAudioDeviceInfo deviceInfo; QAudioFormat settings; QAudio::Mode mode; diff --git a/examples/multimedia/audiodevices/audiodevices.pro b/examples/multimedia/audiodevices/audiodevices.pro index 232da09..1cb4679 100644 --- a/examples/multimedia/audiodevices/audiodevices.pro +++ b/examples/multimedia/audiodevices/audiodevices.pro @@ -1,7 +1,7 @@ HEADERS = audiodevices.h SOURCES = audiodevices.cpp \ main.cpp -FORMS += audiodevicesbase.ui +FORMS += audiodevicesbase.ui QT += multimedia diff --git a/examples/multimedia/audiodevices/audiodevicesbase.ui b/examples/multimedia/audiodevices/audiodevicesbase.ui index 5207338..faa39dc 100644 --- a/examples/multimedia/audiodevices/audiodevicesbase.ui +++ b/examples/multimedia/audiodevices/audiodevicesbase.ui @@ -11,7 +11,7 @@ </rect> </property> <property name="windowTitle"> - <string>AudioDevicesBase</string> + <string>Audio Devices</string> </property> <widget class="QWidget" name="centralwidget"> <layout class="QVBoxLayout" name="verticalLayout"> @@ -41,7 +41,18 @@ <widget class="QComboBox" name="deviceBox"/> </item> <item row="1" column="1"> - <widget class="QComboBox" name="modeBox"/> + <widget class="QComboBox" name="modeBox"> + <item> + <property name="text"> + <string>Input</string> + </property> + </item> + <item> + <property name="text"> + <string>Output</string> + </property> + </item> + </widget> </item> <item row="2" column="0"> <widget class="QLabel" name="actualLabel"> @@ -93,7 +104,11 @@ <widget class="QComboBox" name="frequencyBox"/> </item> <item row="4" column="1"> - <widget class="QLineEdit" name="nearestFreq"/> + <widget class="QLineEdit" name="nearestFreq"> + <property name="enabled"> + <bool>false</bool> + </property> + </widget> </item> <item row="5" column="0"> <widget class="QLabel" name="actualChannelsLabel"> @@ -113,7 +128,11 @@ <widget class="QComboBox" name="channelsBox"/> </item> <item row="6" column="1"> - <widget class="QLineEdit" name="nearestChannel"/> + <widget class="QLineEdit" name="nearestChannel"> + <property name="enabled"> + <bool>false</bool> + </property> + </widget> </item> <item row="7" column="0"> <widget class="QLabel" name="actualCodecLabel"> @@ -133,7 +152,11 @@ <widget class="QComboBox" name="codecsBox"/> </item> <item row="8" column="1"> - <widget class="QLineEdit" name="nearestCodec"/> + <widget class="QLineEdit" name="nearestCodec"> + <property name="enabled"> + <bool>false</bool> + </property> + </widget> </item> <item row="9" column="0"> <widget class="QLabel" name="actualSampleSizeLabel"> @@ -153,7 +176,11 @@ <widget class="QComboBox" name="sampleSizesBox"/> </item> <item row="10" column="1"> - <widget class="QLineEdit" name="nearestSampleSize"/> + <widget class="QLineEdit" name="nearestSampleSize"> + <property name="enabled"> + <bool>false</bool> + </property> + </widget> </item> <item row="11" column="0"> <widget class="QLabel" name="actualSampleTypeLabel"> @@ -173,7 +200,11 @@ <widget class="QComboBox" name="sampleTypesBox"/> </item> <item row="12" column="1"> - <widget class="QLineEdit" name="nearestSampleType"/> + <widget class="QLineEdit" name="nearestSampleType"> + <property name="enabled"> + <bool>false</bool> + </property> + </widget> </item> <item row="13" column="0"> <widget class="QLabel" name="actualEndianLabel"> @@ -193,10 +224,17 @@ <widget class="QComboBox" name="endianBox"/> </item> <item row="14" column="1"> - <widget class="QLineEdit" name="nearestEndian"/> + <widget class="QLineEdit" name="nearestEndian"> + <property name="enabled"> + <bool>false</bool> + </property> + </widget> </item> <item row="15" column="0" colspan="2"> <widget class="QTextEdit" name="logOutput"> + <property name="enabled"> + <bool>false</bool> + </property> <property name="minimumSize"> <size> <width>0</width> @@ -216,16 +254,6 @@ </item> </layout> </widget> - <widget class="QMenuBar" name="menubar"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>504</width> - <height>19</height> - </rect> - </property> - </widget> <widget class="QStatusBar" name="statusbar"/> </widget> <resources/> |