diff options
author | Gareth Stockwell <ext-gareth.stockwell@nokia.com> | 2010-10-26 14:15:14 (GMT) |
---|---|---|
committer | Gareth Stockwell <ext-gareth.stockwell@nokia.com> | 2010-10-29 12:46:33 (GMT) |
commit | a53df3596e2061c202845f9f1c183177ca8a7eda (patch) | |
tree | 3fa4d53240388348a1fdfae16791fee8aa222e16 /demos/spectrum/app/mainwidget.cpp | |
parent | dd5ec222ce0285bd9419c9a47a8329bda41b5dd8 (diff) | |
download | Qt-a53df3596e2061c202845f9f1c183177ca8a7eda.zip Qt-a53df3596e2061c202845f9f1c183177ca8a7eda.tar.gz Qt-a53df3596e2061c202845f9f1c183177ca8a7eda.tar.bz2 |
Do not unnecessarily reset state of spectrum demo
This patch ensures that the state of the application is not reset when:
- Any of the 'Play generated tone', 'Play file' or settings
dialogs are opened
- Any of the 'Play generated tone', 'Play file' or settings
dialogs are dismissed by pressing the Cancel button
- A new input or output device is selected via the settings
dialog, and that new device supports the data format which
is currently being used within the application
- The window function is changed via the settings dialog
Note that the application is still reset if a new input or output
device is selected via the settings dialog, and this device does not
support the current data format.
Task-number: QTBUG-12935
Task-number: QTBUG-14810
Diffstat (limited to 'demos/spectrum/app/mainwidget.cpp')
-rw-r--r-- | demos/spectrum/app/mainwidget.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/demos/spectrum/app/mainwidget.cpp b/demos/spectrum/app/mainwidget.cpp index dd51a91..fba28c6 100644 --- a/demos/spectrum/app/mainwidget.cpp +++ b/demos/spectrum/app/mainwidget.cpp @@ -200,19 +200,20 @@ void MainWidget::dataDurationChanged(qint64 duration) void MainWidget::showFileDialog() { - reset(); const QString dir; const QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Open WAV file"), dir, "*.wav"); if (fileNames.count()) { + reset(); setMode(LoadFileMode); m_engine->loadFile(fileNames.front()); updateButtonStates(); + } else { + updateModeMenu(); } } void MainWidget::showSettingsDialog() { - reset(); m_settingsDialog->exec(); if (m_settingsDialog->result() == QDialog::Accepted) { m_engine->setAudioInputDevice(m_settingsDialog->inputDevice()); @@ -223,9 +224,9 @@ void MainWidget::showSettingsDialog() void MainWidget::showToneGeneratorDialog() { - reset(); m_toneGeneratorDialog->exec(); if (m_toneGeneratorDialog->result() == QDialog::Accepted) { + reset(); setMode(GenerateToneMode); const qreal amplitude = m_toneGeneratorDialog->amplitude(); if (m_toneGeneratorDialog->isFrequencySweepEnabled()) { @@ -236,6 +237,8 @@ void MainWidget::showToneGeneratorDialog() m_engine->generateTone(tone); updateButtonStates(); } + } else { + updateModeMenu(); } } @@ -445,10 +448,14 @@ void MainWidget::reset() void MainWidget::setMode(Mode mode) { - m_mode = mode; - m_loadFileAction->setChecked(LoadFileMode == mode); - m_generateToneAction->setChecked(GenerateToneMode == mode); - m_recordAction->setChecked(RecordMode == mode); + updateModeMenu(); +} + +void MainWidget::updateModeMenu() +{ + m_loadFileAction->setChecked(LoadFileMode == m_mode); + m_generateToneAction->setChecked(GenerateToneMode == m_mode); + m_recordAction->setChecked(RecordMode == m_mode); } |