Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/demos/spectrum/app/mainwidget.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    6666    ,   m_engine(new Engine(this))
    6767#ifndef DISABLE_WAVEFORM
    68     ,   m_waveform(new Waveform(m_engine->buffer(), this))
     68    ,   m_waveform(new Waveform(this))
    6969#endif
    7070    ,   m_progressBar(new ProgressBar(this))
     
    167167}
    168168
    169 void MainWidget::positionChanged(qint64 positionUs)
    170 {
    171 #ifndef DISABLE_WAVEFORM
    172     qint64 positionBytes = audioLength(m_engine->format(), positionUs);
    173     m_waveform->positionChanged(positionBytes);
     169void MainWidget::audioPositionChanged(qint64 position)
     170{
     171#ifndef DISABLE_WAVEFORM
     172    m_waveform->audioPositionChanged(position);
    174173#else
    175     Q_UNUSED(positionUs)
    176 #endif
    177 }
    178 
    179 void MainWidget::bufferDurationChanged(qint64 durationUs)
    180 {
    181     m_progressBar->bufferDurationChanged(durationUs);
     174    Q_UNUSED(position)
     175#endif
     176}
     177
     178void MainWidget::bufferLengthChanged(qint64 length)
     179{
     180    m_progressBar->bufferLengthChanged(length);
    182181}
    183182
     
    187186//-----------------------------------------------------------------------------
    188187
    189 void MainWidget::dataDurationChanged(qint64 duration)
    190 {
    191 #ifndef DISABLE_WAVEFORM
    192     const qint64 dataLength = audioLength(m_engine->format(), duration);
    193     m_waveform->dataLengthChanged(dataLength);
    194 #else
    195     Q_UNUSED(duration)
    196 #endif
    197 
    198     updateButtonStates();
    199 }
    200 
    201188void MainWidget::showFileDialog()
    202189{
    203     reset();
    204190    const QString dir;
    205191    const QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Open WAV file"), dir, "*.wav");
    206192    if (fileNames.count()) {
     193        reset();
    207194        setMode(LoadFileMode);
    208195        m_engine->loadFile(fileNames.front());
    209196        updateButtonStates();
     197    } else {
     198        updateModeMenu();
    210199    }
    211200}
     
    213202void MainWidget::showSettingsDialog()
    214203{
    215     reset();
    216204    m_settingsDialog->exec();
    217205    if (m_settingsDialog->result() == QDialog::Accepted) {
     
    224212void MainWidget::showToneGeneratorDialog()
    225213{
    226     reset();
    227214    m_toneGeneratorDialog->exec();
    228215    if (m_toneGeneratorDialog->result() == QDialog::Accepted) {
     216        reset();
    229217        setMode(GenerateToneMode);
    230218        const qreal amplitude = m_toneGeneratorDialog->amplitude();
     
    237225            updateButtonStates();
    238226        }
     227    } else {
     228        updateModeMenu();
    239229    }
    240230}
     
    361351            this, SLOT(formatChanged(const QAudioFormat &)));
    362352
    363     m_progressBar->bufferDurationChanged(m_engine->bufferDuration());
    364 
    365     CHECKED_CONNECT(m_engine, SIGNAL(bufferDurationChanged(qint64)),
    366             this, SLOT(bufferDurationChanged(qint64)));
    367 
    368     CHECKED_CONNECT(m_engine, SIGNAL(dataDurationChanged(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()));
    370360
    371361    CHECKED_CONNECT(m_engine, SIGNAL(recordPositionChanged(qint64)),
     
    376366
    377367    CHECKED_CONNECT(m_engine, SIGNAL(recordPositionChanged(qint64)),
    378             this, SLOT(positionChanged(qint64)));
     368            this, SLOT(audioPositionChanged(qint64)));
    379369
    380370    CHECKED_CONNECT(m_engine, SIGNAL(playPositionChanged(qint64)),
    381             this, SLOT(positionChanged(qint64)));
     371            this, SLOT(audioPositionChanged(qint64)));
    382372
    383373    CHECKED_CONNECT(m_engine, SIGNAL(levelChanged(qreal, qreal, int)),
     
    395385    CHECKED_CONNECT(m_spectrograph, SIGNAL(infoMessage(QString, int)),
    396386            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
    397392}
    398393
     
    426421    m_pauseButton->setEnabled(pauseEnabled);
    427422
    428     const bool playEnabled = (m_engine->dataDuration() &&
     423    const bool playEnabled = (/*m_engine->dataLength() &&*/
    429424                              (QAudio::AudioOutput != m_engine->mode() ||
    430425                               (QAudio::ActiveState != m_engine->state() &&
     
    446441void MainWidget::setMode(Mode mode)
    447442{
    448 
    449443    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
     447void 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.