changeset 263:9d47adc3e32d

* 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)
author Chris Cannam
date Fri, 13 Jun 2008 21:09:43 +0000
parents f3df0494ae33
children 15e6c49c759e
files icons/datadelete.png icons/dataedit.png icons/datainsert.png main/PreferencesDialog.cpp main/PreferencesDialog.h sonic-visualiser.qrc
diffstat 6 files changed, 75 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
Binary file icons/datadelete.png has changed
Binary file icons/dataedit.png has changed
Binary file icons/datainsert.png has changed
--- 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 <QFileDialog>
 #include <QMessageBox>
 #include <QSpinBox>
+#include <QSettings>
 
 #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<QString> 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<QString> devices =
+        AudioTargetFactory::getInstance()->getCallbackTargetNames();
+
+    QSettings settings;
+    settings.beginGroup("Preferences");
+    settings.setValue("audio-target", devices[m_audioDevice]);
+    settings.endGroup();
 
     m_applyButton->setEnabled(false);
 
--- 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;
--- 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 @@
     <file>icons/editcut.png</file>
     <file>icons/editcopy.png</file>
     <file>icons/editpaste.png</file>
+    <file>icons/datadelete.png</file>
+    <file>icons/dataedit.png</file>
+    <file>icons/datainsert.png</file>
     <file>icons/mono.png</file>
     <file>icons/stereo.png</file>
     <file>icons/sharpen.png</file>