comparison main/PreferencesDialog.cpp @ 1413:a89ca5ccb958 3.0-integration

Reopen the audio device directly when preference is changed
author Chris Cannam
date Mon, 12 Dec 2016 15:45:33 +0000
parents 558347e7e1ab
children 13eb1d55f129
comparison
equal deleted inserted replaced
1410:f724d092be7b 1413:a89ca5ccb958
51 PreferencesDialog::PreferencesDialog(QWidget *parent) : 51 PreferencesDialog::PreferencesDialog(QWidget *parent) :
52 QDialog(parent), 52 QDialog(parent),
53 m_audioImplementation(0), 53 m_audioImplementation(0),
54 m_audioPlaybackDevice(0), 54 m_audioPlaybackDevice(0),
55 m_audioRecordDevice(0), 55 m_audioRecordDevice(0),
56 m_audioDeviceChanged(false),
56 m_changesOnRestart(false) 57 m_changesOnRestart(false)
57 { 58 {
58 setWindowTitle(tr("Sonic Visualiser: Application Preferences")); 59 setWindowTitle(tr("Sonic Visualiser: Application Preferences"));
59 60
60 Preferences *prefs = Preferences::getInstance(); 61 Preferences *prefs = Preferences::getInstance();
217 } 218 }
218 } 219 }
219 settings.endGroup(); 220 settings.endGroup();
220 221
221 rebuildDeviceCombos(); 222 rebuildDeviceCombos();
222 m_changesOnRestart = false; // the rebuild will have changed this 223 m_audioDeviceChanged = false; // the rebuild will have changed this
223 224
224 QCheckBox *resampleOnLoad = new QCheckBox; 225 QCheckBox *resampleOnLoad = new QCheckBox;
225 m_resampleOnLoad = prefs->getResampleOnLoad(); 226 m_resampleOnLoad = prefs->getResampleOnLoad();
226 resampleOnLoad->setCheckState(m_resampleOnLoad ? Qt::Checked : 227 resampleOnLoad->setCheckState(m_resampleOnLoad ? Qt::Checked :
227 Qt::Unchecked); 228 Qt::Unchecked);
693 { 694 {
694 if (m_audioImplementation != s) { 695 if (m_audioImplementation != s) {
695 m_audioImplementation = s; 696 m_audioImplementation = s;
696 rebuildDeviceCombos(); 697 rebuildDeviceCombos();
697 m_applyButton->setEnabled(true); 698 m_applyButton->setEnabled(true);
698 m_changesOnRestart = true; 699 m_audioDeviceChanged = true;
699 } 700 }
700 } 701 }
701 702
702 void 703 void
703 PreferencesDialog::audioPlaybackDeviceChanged(int s) 704 PreferencesDialog::audioPlaybackDeviceChanged(int s)
704 { 705 {
705 if (m_audioPlaybackDevice != s) { 706 if (m_audioPlaybackDevice != s) {
706 m_audioPlaybackDevice = s; 707 m_audioPlaybackDevice = s;
707 m_applyButton->setEnabled(true); 708 m_applyButton->setEnabled(true);
708 m_changesOnRestart = true; 709 m_audioDeviceChanged = true;
709 } 710 }
710 } 711 }
711 712
712 void 713 void
713 PreferencesDialog::audioRecordDeviceChanged(int s) 714 PreferencesDialog::audioRecordDeviceChanged(int s)
714 { 715 {
715 if (m_audioRecordDevice != s) { 716 if (m_audioRecordDevice != s) {
716 m_audioRecordDevice = s; 717 m_audioRecordDevice = s;
717 m_applyButton->setEnabled(true); 718 m_applyButton->setEnabled(true);
718 m_changesOnRestart = true; 719 m_audioDeviceChanged = true;
719 } 720 }
720 } 721 }
721 722
722 void 723 void
723 PreferencesDialog::resampleOnLoadChanged(int state) 724 PreferencesDialog::resampleOnLoadChanged(int state)
916 if (m_changesOnRestart) { 917 if (m_changesOnRestart) {
917 QMessageBox::information(this, tr("Preferences"), 918 QMessageBox::information(this, tr("Preferences"),
918 tr("<b>Restart required</b><p>One or more of the application preferences you have changed may not take full effect until Sonic Visualiser is restarted.</p><p>Please exit and restart the application now if you want these changes to take effect immediately.</p>")); 919 tr("<b>Restart required</b><p>One or more of the application preferences you have changed may not take full effect until Sonic Visualiser is restarted.</p><p>Please exit and restart the application now if you want these changes to take effect immediately.</p>"));
919 m_changesOnRestart = false; 920 m_changesOnRestart = false;
920 } 921 }
922
923 if (m_audioDeviceChanged) {
924 emit audioDeviceChanged();
925 }
921 } 926 }
922 927
923 void 928 void
924 PreferencesDialog::cancelClicked() 929 PreferencesDialog::cancelClicked()
925 { 930 {