# HG changeset patch # User Chris Cannam # Date 1213391383 0 # Node ID 9d47adc3e32dd7bd55f7e04dbced1998d0fc6b1d # Parent f3df0494ae33685682ac105e495a6111348fb15e * Add audio device selection to preferences * Add (not yet functional) insert, delete, edit buttons to data edit window * Add proper set methods for time fields in data edit window (using general sparse model base class) diff -r f3df0494ae33 -r 9d47adc3e32d icons/datadelete.png Binary file icons/datadelete.png has changed diff -r f3df0494ae33 -r 9d47adc3e32d icons/dataedit.png Binary file icons/dataedit.png has changed diff -r f3df0494ae33 -r 9d47adc3e32d icons/datainsert.png Binary file icons/datainsert.png has changed diff -r f3df0494ae33 -r 9d47adc3e32d main/PreferencesDialog.cpp --- a/main/PreferencesDialog.cpp Thu Jun 12 10:47:11 2008 +0000 +++ b/main/PreferencesDialog.cpp Fri Jun 13 21:09:43 2008 +0000 @@ -31,13 +31,16 @@ #include #include #include +#include #include "widgets/WindowTypeSelector.h" #include "widgets/IconLoader.h" #include "base/Preferences.h" +#include "audioio/AudioTargetFactory.h" PreferencesDialog::PreferencesDialog(QWidget *parent, Qt::WFlags flags) : QDialog(parent, flags), + m_audioDevice(0), m_changesOnRestart(false) { setWindowTitle(tr("Sonic Visualiser: Application Preferences")); @@ -111,6 +114,24 @@ connect(frequency, SIGNAL(valueChanged(double)), this, SLOT(tuningFrequencyChanged(double))); + QComboBox *audioDevice = new QComboBox; + std::vector devices = + AudioTargetFactory::getInstance()->getCallbackTargetNames(); + + QSettings settings; + settings.beginGroup("Preferences"); + QString targetName = settings.value("audio-target", "").toString(); + settings.endGroup(); + + for (int i = 0; i < devices.size(); ++i) { + audioDevice->addItem(AudioTargetFactory::getInstance() + ->getCallbackTargetDescription(devices[i])); + if (targetName == devices[i]) audioDevice->setCurrentIndex(i); + } + + connect(audioDevice, SIGNAL(currentIndexChanged(int)), + this, SLOT(audioDeviceChanged(int))); + QComboBox *resampleQuality = new QComboBox; int rsq = prefs->getPropertyRangeAndValue("Resample Quality", &min, &max, @@ -188,6 +209,37 @@ int row = 0; subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel + ("Temporary Directory Root"))), + row, 0); + subgrid->addWidget(m_tempDirRootEdit, row, 1, 1, 1); + subgrid->addWidget(tempDirButton, row, 2, 1, 1); + row++; + + subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel + ("Resample On Load"))), + row, 0); + subgrid->addWidget(resampleOnLoad, row++, 1, 1, 1); + + subgrid->addWidget(new QLabel(tr("Playback audio device:")), row, 0); + subgrid->addWidget(audioDevice, row++, 1, 1, 2); + + subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel + ("Resample Quality"))), + row, 0); + subgrid->addWidget(resampleQuality, row++, 1, 1, 2); + + subgrid->setRowStretch(row, 10); + + tab->addTab(frame, tr("&General")); + + // Appearance tab + + frame = new QFrame; + subgrid = new QGridLayout; + frame->setLayout(subgrid); + row = 0; + + subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel ("Property Box Layout"))), row, 0); subgrid->addWidget(propertyLayout, row++, 1, 1, 2); @@ -209,26 +261,9 @@ row, 0); subgrid->addWidget(showSplash, row++, 1, 1, 1); - subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel - ("Temporary Directory Root"))), - row, 0); - subgrid->addWidget(m_tempDirRootEdit, row, 1, 1, 1); - subgrid->addWidget(tempDirButton, row, 2, 1, 1); - row++; - - subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel - ("Resample On Load"))), - row, 0); - subgrid->addWidget(resampleOnLoad, row++, 1, 1, 1); - - subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel - ("Resample Quality"))), - row, 0); - subgrid->addWidget(resampleQuality, row++, 1, 1, 2); - subgrid->setRowStretch(row, 10); - tab->addTab(frame, tr("&General")); + tab->addTab(frame, tr("&Appearance")); // Analysis tab @@ -256,7 +291,7 @@ subgrid->setRowStretch(row, 10); - tab->addTab(frame, tr("&Analysis")); + tab->addTab(frame, tr("Anal&ysis")); QDialogButtonBox *bb = new QDialogButtonBox(Qt::Horizontal); grid->addWidget(bb, 1, 0); @@ -307,6 +342,14 @@ } void +PreferencesDialog::audioDeviceChanged(int s) +{ + m_audioDevice = s; + m_applyButton->setEnabled(true); + m_changesOnRestart = true; +} + +void PreferencesDialog::resampleQualityChanged(int q) { m_resampleQuality = q; @@ -386,6 +429,14 @@ prefs->setTemporaryDirectoryRoot(m_tempDirRoot); prefs->setBackgroundMode(Preferences::BackgroundMode(m_backgroundMode)); prefs->setViewFontSize(m_viewFontSize); + + std::vector devices = + AudioTargetFactory::getInstance()->getCallbackTargetNames(); + + QSettings settings; + settings.beginGroup("Preferences"); + settings.setValue("audio-target", devices[m_audioDevice]); + settings.endGroup(); m_applyButton->setEnabled(false); diff -r f3df0494ae33 -r 9d47adc3e32d main/PreferencesDialog.h --- a/main/PreferencesDialog.h Thu Jun 12 10:47:11 2008 +0000 +++ b/main/PreferencesDialog.h Fri Jun 13 21:09:43 2008 +0000 @@ -40,6 +40,7 @@ void spectrogramSmoothingChanged(int state); void propertyLayoutChanged(int layout); void tuningFrequencyChanged(double freq); + void audioDeviceChanged(int device); void resampleQualityChanged(int quality); void resampleOnLoadChanged(int state); void tempDirRootChanged(QString root); @@ -63,6 +64,7 @@ int m_spectrogramSmoothing; int m_propertyLayout; float m_tuningFrequency; + int m_audioDevice; int m_resampleQuality; bool m_resampleOnLoad; QString m_tempDirRoot; diff -r f3df0494ae33 -r 9d47adc3e32d sonic-visualiser.qrc --- a/sonic-visualiser.qrc Thu Jun 12 10:47:11 2008 +0000 +++ b/sonic-visualiser.qrc Fri Jun 13 21:09:43 2008 +0000 @@ -61,6 +61,9 @@ icons/editcut.png icons/editcopy.png icons/editpaste.png + icons/datadelete.png + icons/dataedit.png + icons/datainsert.png icons/mono.png icons/stereo.png icons/sharpen.png