Changeset 846 for trunk/demos/spectrum/app/mainwidget.cpp
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/demos/spectrum/app/mainwidget.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 66 66 , m_engine(new Engine(this)) 67 67 #ifndef DISABLE_WAVEFORM 68 , m_waveform(new Waveform( m_engine->buffer(),this))68 , m_waveform(new Waveform(this)) 69 69 #endif 70 70 , m_progressBar(new ProgressBar(this)) … … 167 167 } 168 168 169 void MainWidget::positionChanged(qint64 positionUs) 170 { 171 #ifndef DISABLE_WAVEFORM 172 qint64 positionBytes = audioLength(m_engine->format(), positionUs); 173 m_waveform->positionChanged(positionBytes); 169 void MainWidget::audioPositionChanged(qint64 position) 170 { 171 #ifndef DISABLE_WAVEFORM 172 m_waveform->audioPositionChanged(position); 174 173 #else 175 Q_UNUSED(position Us)176 #endif 177 } 178 179 void MainWidget::buffer DurationChanged(qint64 durationUs)180 { 181 m_progressBar->buffer DurationChanged(durationUs);174 Q_UNUSED(position) 175 #endif 176 } 177 178 void MainWidget::bufferLengthChanged(qint64 length) 179 { 180 m_progressBar->bufferLengthChanged(length); 182 181 } 183 182 … … 187 186 //----------------------------------------------------------------------------- 188 187 189 void MainWidget::dataDurationChanged(qint64 duration)190 {191 #ifndef DISABLE_WAVEFORM192 const qint64 dataLength = audioLength(m_engine->format(), duration);193 m_waveform->dataLengthChanged(dataLength);194 #else195 Q_UNUSED(duration)196 #endif197 198 updateButtonStates();199 }200 201 188 void MainWidget::showFileDialog() 202 189 { 203 reset();204 190 const QString dir; 205 191 const QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Open WAV file"), dir, "*.wav"); 206 192 if (fileNames.count()) { 193 reset(); 207 194 setMode(LoadFileMode); 208 195 m_engine->loadFile(fileNames.front()); 209 196 updateButtonStates(); 197 } else { 198 updateModeMenu(); 210 199 } 211 200 } … … 213 202 void MainWidget::showSettingsDialog() 214 203 { 215 reset();216 204 m_settingsDialog->exec(); 217 205 if (m_settingsDialog->result() == QDialog::Accepted) { … … 224 212 void MainWidget::showToneGeneratorDialog() 225 213 { 226 reset();227 214 m_toneGeneratorDialog->exec(); 228 215 if (m_toneGeneratorDialog->result() == QDialog::Accepted) { 216 reset(); 229 217 setMode(GenerateToneMode); 230 218 const qreal amplitude = m_toneGeneratorDialog->amplitude(); … … 237 225 updateButtonStates(); 238 226 } 227 } else { 228 updateModeMenu(); 239 229 } 240 230 } … … 361 351 this, SLOT(formatChanged(const QAudioFormat &))); 362 352 363 m_progressBar->buffer DurationChanged(m_engine->bufferDuration());364 365 CHECKED_CONNECT(m_engine, SIGNAL(buffer DurationChanged(qint64)),366 this, SLOT(buffer DurationChanged(qint64)));367 368 CHECKED_CONNECT(m_engine, SIGNAL(data DurationChanged(qint64)),369 this, SLOT( dataDurationChanged(qint64)));353 m_progressBar->bufferLengthChanged(m_engine->bufferLength()); 354 355 CHECKED_CONNECT(m_engine, SIGNAL(bufferLengthChanged(qint64)), 356 this, SLOT(bufferLengthChanged(qint64))); 357 358 CHECKED_CONNECT(m_engine, SIGNAL(dataLengthChanged(qint64)), 359 this, SLOT(updateButtonStates())); 370 360 371 361 CHECKED_CONNECT(m_engine, SIGNAL(recordPositionChanged(qint64)), … … 376 366 377 367 CHECKED_CONNECT(m_engine, SIGNAL(recordPositionChanged(qint64)), 378 this, SLOT( positionChanged(qint64)));368 this, SLOT(audioPositionChanged(qint64))); 379 369 380 370 CHECKED_CONNECT(m_engine, SIGNAL(playPositionChanged(qint64)), 381 this, SLOT( positionChanged(qint64)));371 this, SLOT(audioPositionChanged(qint64))); 382 372 383 373 CHECKED_CONNECT(m_engine, SIGNAL(levelChanged(qreal, qreal, int)), … … 395 385 CHECKED_CONNECT(m_spectrograph, SIGNAL(infoMessage(QString, int)), 396 386 this, SLOT(infoMessage(QString, int))); 387 388 #ifndef DISABLE_WAVEFORM 389 CHECKED_CONNECT(m_engine, SIGNAL(bufferChanged(qint64, qint64, const QByteArray &)), 390 m_waveform, SLOT(bufferChanged(qint64, qint64, const QByteArray &))); 391 #endif 397 392 } 398 393 … … 426 421 m_pauseButton->setEnabled(pauseEnabled); 427 422 428 const bool playEnabled = ( m_engine->dataDuration() &&423 const bool playEnabled = (/*m_engine->dataLength() &&*/ 429 424 (QAudio::AudioOutput != m_engine->mode() || 430 425 (QAudio::ActiveState != m_engine->state() && … … 446 441 void MainWidget::setMode(Mode mode) 447 442 { 448 449 443 m_mode = mode; 450 m_loadFileAction->setChecked(LoadFileMode == mode); 451 m_generateToneAction->setChecked(GenerateToneMode == mode); 452 m_recordAction->setChecked(RecordMode == mode); 453 } 454 444 updateModeMenu(); 445 } 446 447 void MainWidget::updateModeMenu() 448 { 449 m_loadFileAction->setChecked(LoadFileMode == m_mode); 450 m_generateToneAction->setChecked(GenerateToneMode == m_mode); 451 m_recordAction->setChecked(RecordMode == m_mode); 452 } 453
Note:
See TracChangeset
for help on using the changeset viewer.