10 #include <QMessageBox>
11 #include <QCloseEvent>
14 #include "mainwindow.h"
15 #include "ui_mainwindow.h"
20 char backend_name
[16];
26 #ifdef HAVE_PULSEAUDIO
27 { "pulse", "PulseAudio" },
33 { "core", "CoreAudio" },
39 { "solaris", "Solaris" },
42 { "sndio", "SoundIO" },
48 { "mmdevapi", "MMDevAPI" },
51 { "dsound", "DirectSound" },
54 { "winmm", "Windows Multimedia" },
57 { "port", "PortAudio" },
60 { "opensl", "OpenSL" },
63 { "null", "Null Output" },
65 { "wave", "Wave Writer" },
70 static const struct NameValuePair
{
73 } speakerModeList
[] = {
76 { "Stereo", "stereo" },
77 { "Quadrophonic", "quad" },
78 { "5.1 Surround (Side)", "surround51" },
79 { "5.1 Surround (Rear)", "surround51rear" },
80 { "6.1 Surround", "surround61" },
81 { "7.1 Surround", "surround71" },
83 { "Ambisonic, 1st Order", "ambi1" },
84 { "Ambisonic, 2nd Order", "ambi2" },
85 { "Ambisonic, 3rd Order", "ambi3" },
88 }, sampleTypeList
[] = {
90 { "8-bit int", "int8" },
91 { "8-bit uint", "uint8" },
92 { "16-bit int", "int16" },
93 { "16-bit uint", "uint16" },
94 { "32-bit int", "int32" },
95 { "32-bit uint", "uint32" },
96 { "32-bit float", "float32" },
99 }, resamplerList
[] = {
100 { "Point", "point" },
101 { "Linear", "linear" },
102 { "Default (Linear)", "" },
103 { "4-Point Sinc", "sinc4" },
104 { "Band-limited Sinc", "bsinc" },
107 }, stereoModeList
[] = {
108 { "Autodetect", "" },
109 { "Speakers", "speakers" },
110 { "Headphones", "headphones" },
113 }, stereoEncList
[] = {
115 { "Pan Pot", "panpot" },
119 }, ambiFormatList
[] = {
121 { "ACN + SN3D", "acn+sn3d" },
122 { "ACN + N3D", "acn+n3d" },
123 { "Furse-Malham", "fuma" },
128 static QString
getDefaultConfigName()
131 static const char fname
[] = "alsoft.ini";
132 QByteArray base
= qgetenv("AppData");
134 static const char fname
[] = "alsoft.conf";
135 QByteArray base
= qgetenv("XDG_CONFIG_HOME");
138 base
= qgetenv("HOME");
139 if(base
.isEmpty() == false)
143 if(base
.isEmpty() == false)
144 return base
+'/'+ fname
;
148 static QString
getBaseDataPath()
151 QByteArray base
= qgetenv("AppData");
153 QByteArray base
= qgetenv("XDG_DATA_HOME");
156 base
= qgetenv("HOME");
158 base
+= "/.local/share";
164 static QStringList
getAllDataPaths(QString append
=QString())
167 list
.append(getBaseDataPath());
169 // TODO: Common AppData path
171 QString paths
= qgetenv("XDG_DATA_DIRS");
173 paths
= "/usr/local/share/:/usr/share/";
174 list
+= paths
.split(QChar(':'), QString::SkipEmptyParts
);
176 QStringList::iterator iter
= list
.begin();
177 while(iter
!= list
.end())
180 iter
= list
.erase(iter
);
183 iter
->append(append
);
191 static QString
getValueFromName(const NameValuePair (&list
)[N
], const QString
&str
)
193 for(size_t i
= 0;i
< N
-1;i
++)
195 if(str
== list
[i
].name
)
196 return list
[i
].value
;
202 static QString
getNameFromValue(const NameValuePair (&list
)[N
], const QString
&str
)
204 for(size_t i
= 0;i
< N
-1;i
++)
206 if(str
== list
[i
].value
)
214 MainWindow::MainWindow(QWidget
*parent
) :
216 ui(new Ui::MainWindow
),
217 mPeriodSizeValidator(NULL
),
218 mPeriodCountValidator(NULL
),
219 mSourceCountValidator(NULL
),
220 mEffectSlotValidator(NULL
),
221 mSourceSendValidator(NULL
),
222 mSampleRateValidator(NULL
),
223 mJackBufferValidator(NULL
),
228 for(int i
= 0;speakerModeList
[i
].name
[0];i
++)
229 ui
->channelConfigCombo
->addItem(speakerModeList
[i
].name
);
230 ui
->channelConfigCombo
->adjustSize();
231 for(int i
= 0;sampleTypeList
[i
].name
[0];i
++)
232 ui
->sampleFormatCombo
->addItem(sampleTypeList
[i
].name
);
233 ui
->sampleFormatCombo
->adjustSize();
234 for(int i
= 0;stereoModeList
[i
].name
[0];i
++)
235 ui
->stereoModeCombo
->addItem(stereoModeList
[i
].name
);
236 ui
->stereoModeCombo
->adjustSize();
237 for(int i
= 0;stereoEncList
[i
].name
[0];i
++)
238 ui
->stereoEncodingComboBox
->addItem(stereoEncList
[i
].name
);
239 ui
->stereoEncodingComboBox
->adjustSize();
240 for(int i
= 0;ambiFormatList
[i
].name
[0];i
++)
241 ui
->ambiFormatComboBox
->addItem(ambiFormatList
[i
].name
);
242 ui
->ambiFormatComboBox
->adjustSize();
245 for(count
= 0;resamplerList
[count
].name
[0];count
++) {
247 ui
->resamplerSlider
->setRange(0, count
-1);
249 ui
->hrtfStateComboBox
->adjustSize();
251 #if !defined(HAVE_NEON) && !defined(HAVE_SSE)
252 ui
->cpuExtDisabledLabel
->move(ui
->cpuExtDisabledLabel
->x(), ui
->cpuExtDisabledLabel
->y() - 60);
254 ui
->cpuExtDisabledLabel
->setVisible(false);
263 ui
->enableSSECheckBox
->setVisible(false);
265 ui
->enableSSE2CheckBox
->setVisible(false);
267 ui
->enableSSE3CheckBox
->setVisible(false);
269 ui
->enableSSE41CheckBox
->setVisible(false);
271 ui
->enableNeonCheckBox
->setVisible(false);
279 ui
->enableNeonCheckBox
->move(ui
->enableNeonCheckBox
->x(), ui
->enableNeonCheckBox
->y() - 30);
280 ui
->enableSSECheckBox
->setVisible(false);
282 ui
->enableSSE2CheckBox
->setVisible(false);
284 ui
->enableSSE3CheckBox
->setVisible(false);
286 ui
->enableSSE41CheckBox
->setVisible(false);
291 mPeriodSizeValidator
= new QIntValidator(64, 8192, this);
292 ui
->periodSizeEdit
->setValidator(mPeriodSizeValidator
);
293 mPeriodCountValidator
= new QIntValidator(2, 16, this);
294 ui
->periodCountEdit
->setValidator(mPeriodCountValidator
);
296 mSourceCountValidator
= new QIntValidator(0, 4096, this);
297 ui
->srcCountLineEdit
->setValidator(mSourceCountValidator
);
298 mEffectSlotValidator
= new QIntValidator(0, 64, this);
299 ui
->effectSlotLineEdit
->setValidator(mEffectSlotValidator
);
300 mSourceSendValidator
= new QIntValidator(0, 16, this);
301 ui
->srcSendLineEdit
->setValidator(mSourceSendValidator
);
302 mSampleRateValidator
= new QIntValidator(8000, 192000, this);
303 ui
->sampleRateCombo
->lineEdit()->setValidator(mSampleRateValidator
);
305 mJackBufferValidator
= new QIntValidator(0, 8192, this);
306 ui
->jackBufferSizeLine
->setValidator(mJackBufferValidator
);
308 connect(ui
->actionLoad
, SIGNAL(triggered()), this, SLOT(loadConfigFromFile()));
309 connect(ui
->actionSave_As
, SIGNAL(triggered()), this, SLOT(saveConfigAsFile()));
311 connect(ui
->actionAbout
, SIGNAL(triggered()), this, SLOT(showAboutPage()));
313 connect(ui
->closeCancelButton
, SIGNAL(clicked()), this, SLOT(cancelCloseAction()));
314 connect(ui
->applyButton
, SIGNAL(clicked()), this, SLOT(saveCurrentConfig()));
316 connect(ui
->channelConfigCombo
, SIGNAL(currentIndexChanged(const QString
&)), this, SLOT(enableApplyButton()));
317 connect(ui
->sampleFormatCombo
, SIGNAL(currentIndexChanged(const QString
&)), this, SLOT(enableApplyButton()));
318 connect(ui
->stereoModeCombo
, SIGNAL(currentIndexChanged(const QString
&)), this, SLOT(enableApplyButton()));
319 connect(ui
->sampleRateCombo
, SIGNAL(currentIndexChanged(const QString
&)), this, SLOT(enableApplyButton()));
320 connect(ui
->sampleRateCombo
, SIGNAL(editTextChanged(const QString
&)), this, SLOT(enableApplyButton()));
322 connect(ui
->resamplerSlider
, SIGNAL(valueChanged(int)), this, SLOT(updateResamplerLabel(int)));
324 connect(ui
->periodSizeSlider
, SIGNAL(valueChanged(int)), this, SLOT(updatePeriodSizeEdit(int)));
325 connect(ui
->periodSizeEdit
, SIGNAL(editingFinished()), this, SLOT(updatePeriodSizeSlider()));
326 connect(ui
->periodCountSlider
, SIGNAL(valueChanged(int)), this, SLOT(updatePeriodCountEdit(int)));
327 connect(ui
->periodCountEdit
, SIGNAL(editingFinished()), this, SLOT(updatePeriodCountSlider()));
329 connect(ui
->stereoEncodingComboBox
, SIGNAL(currentIndexChanged(QString
)), this, SLOT(enableApplyButton()));
330 connect(ui
->ambiFormatComboBox
, SIGNAL(currentIndexChanged(QString
)), this, SLOT(enableApplyButton()));
331 connect(ui
->outputLimiterCheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
332 connect(ui
->outputDitherCheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
334 connect(ui
->decoderHQModeCheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
335 connect(ui
->decoderDistCompCheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
336 connect(ui
->decoderNFEffectsCheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
337 connect(ui
->decoderNFRefDelaySpinBox
, SIGNAL(valueChanged(double)), this, SLOT(enableApplyButton()));
338 connect(ui
->decoderQuadLineEdit
, SIGNAL(textChanged(QString
)), this, SLOT(enableApplyButton()));
339 connect(ui
->decoderQuadButton
, SIGNAL(clicked()), this, SLOT(selectQuadDecoderFile()));
340 connect(ui
->decoder51LineEdit
, SIGNAL(textChanged(QString
)), this, SLOT(enableApplyButton()));
341 connect(ui
->decoder51Button
, SIGNAL(clicked()), this, SLOT(select51DecoderFile()));
342 connect(ui
->decoder61LineEdit
, SIGNAL(textChanged(QString
)), this, SLOT(enableApplyButton()));
343 connect(ui
->decoder61Button
, SIGNAL(clicked()), this, SLOT(select61DecoderFile()));
344 connect(ui
->decoder71LineEdit
, SIGNAL(textChanged(QString
)), this, SLOT(enableApplyButton()));
345 connect(ui
->decoder71Button
, SIGNAL(clicked()), this, SLOT(select71DecoderFile()));
347 connect(ui
->preferredHrtfComboBox
, SIGNAL(currentIndexChanged(const QString
&)), this, SLOT(enableApplyButton()));
348 connect(ui
->hrtfStateComboBox
, SIGNAL(currentIndexChanged(const QString
&)), this, SLOT(enableApplyButton()));
349 connect(ui
->hrtfAddButton
, SIGNAL(clicked()), this, SLOT(addHrtfFile()));
350 connect(ui
->hrtfRemoveButton
, SIGNAL(clicked()), this, SLOT(removeHrtfFile()));
351 connect(ui
->hrtfFileList
, SIGNAL(itemSelectionChanged()), this, SLOT(updateHrtfRemoveButton()));
352 connect(ui
->defaultHrtfPathsCheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
354 connect(ui
->srcCountLineEdit
, SIGNAL(editingFinished()), this, SLOT(enableApplyButton()));
355 connect(ui
->srcSendLineEdit
, SIGNAL(editingFinished()), this, SLOT(enableApplyButton()));
356 connect(ui
->effectSlotLineEdit
, SIGNAL(editingFinished()), this, SLOT(enableApplyButton()));
358 connect(ui
->enableSSECheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
359 connect(ui
->enableSSE2CheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
360 connect(ui
->enableSSE3CheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
361 connect(ui
->enableSSE41CheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
362 connect(ui
->enableNeonCheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
364 ui
->enabledBackendList
->setContextMenuPolicy(Qt::CustomContextMenu
);
365 connect(ui
->enabledBackendList
, SIGNAL(customContextMenuRequested(QPoint
)), this, SLOT(showEnabledBackendMenu(QPoint
)));
367 ui
->disabledBackendList
->setContextMenuPolicy(Qt::CustomContextMenu
);
368 connect(ui
->disabledBackendList
, SIGNAL(customContextMenuRequested(QPoint
)), this, SLOT(showDisabledBackendMenu(QPoint
)));
369 connect(ui
->backendCheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
371 connect(ui
->defaultReverbComboBox
, SIGNAL(currentIndexChanged(const QString
&)), this, SLOT(enableApplyButton()));
372 connect(ui
->emulateEaxCheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
373 connect(ui
->enableEaxReverbCheck
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
374 connect(ui
->enableStdReverbCheck
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
375 connect(ui
->enableChorusCheck
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
376 connect(ui
->enableCompressorCheck
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
377 connect(ui
->enableDistortionCheck
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
378 connect(ui
->enableEchoCheck
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
379 connect(ui
->enableEqualizerCheck
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
380 connect(ui
->enableFlangerCheck
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
381 connect(ui
->enableModulatorCheck
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
382 connect(ui
->enableDedicatedCheck
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
384 connect(ui
->pulseAutospawnCheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
385 connect(ui
->pulseAllowMovesCheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
386 connect(ui
->pulseFixRateCheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
388 connect(ui
->jackAutospawnCheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
389 connect(ui
->jackBufferSizeSlider
, SIGNAL(valueChanged(int)), this, SLOT(updateJackBufferSizeEdit(int)));
390 connect(ui
->jackBufferSizeLine
, SIGNAL(editingFinished()), this, SLOT(updateJackBufferSizeSlider()));
392 connect(ui
->alsaDefaultDeviceLine
, SIGNAL(textChanged(QString
)), this, SLOT(enableApplyButton()));
393 connect(ui
->alsaDefaultCaptureLine
, SIGNAL(textChanged(QString
)), this, SLOT(enableApplyButton()));
394 connect(ui
->alsaResamplerCheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
395 connect(ui
->alsaMmapCheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
397 connect(ui
->ossDefaultDeviceLine
, SIGNAL(textChanged(QString
)), this, SLOT(enableApplyButton()));
398 connect(ui
->ossPlaybackPushButton
, SIGNAL(clicked(bool)), this, SLOT(selectOSSPlayback()));
399 connect(ui
->ossDefaultCaptureLine
, SIGNAL(textChanged(QString
)), this, SLOT(enableApplyButton()));
400 connect(ui
->ossCapturePushButton
, SIGNAL(clicked(bool)), this, SLOT(selectOSSCapture()));
402 connect(ui
->solarisDefaultDeviceLine
, SIGNAL(textChanged(QString
)), this, SLOT(enableApplyButton()));
403 connect(ui
->solarisPlaybackPushButton
, SIGNAL(clicked(bool)), this, SLOT(selectSolarisPlayback()));
405 connect(ui
->waveOutputLine
, SIGNAL(textChanged(QString
)), this, SLOT(enableApplyButton()));
406 connect(ui
->waveOutputButton
, SIGNAL(clicked(bool)), this, SLOT(selectWaveOutput()));
407 connect(ui
->waveBFormatCheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
409 ui
->backendListWidget
->setCurrentRow(0);
410 ui
->tabWidget
->setCurrentIndex(0);
412 for(int i
= 1;i
< ui
->backendListWidget
->count();i
++)
413 ui
->backendListWidget
->setRowHidden(i
, true);
414 for(int i
= 0;backendList
[i
].backend_name
[0];i
++)
416 QList
<QListWidgetItem
*> items
= ui
->backendListWidget
->findItems(
417 backendList
[i
].full_string
, Qt::MatchFixedString
419 foreach(const QListWidgetItem
*item
, items
)
420 ui
->backendListWidget
->setItemHidden(item
, false);
423 loadConfig(getDefaultConfigName());
426 MainWindow::~MainWindow()
429 delete mPeriodSizeValidator
;
430 delete mPeriodCountValidator
;
431 delete mSourceCountValidator
;
432 delete mEffectSlotValidator
;
433 delete mSourceSendValidator
;
434 delete mSampleRateValidator
;
435 delete mJackBufferValidator
;
438 void MainWindow::closeEvent(QCloseEvent
*event
)
444 QMessageBox::StandardButton btn
= QMessageBox::warning(this,
445 tr("Apply changes?"), tr("Save changes before quitting?"),
446 QMessageBox::Save
| QMessageBox::No
| QMessageBox::Cancel
448 if(btn
== QMessageBox::Save
)
450 if(btn
== QMessageBox::Cancel
)
457 void MainWindow::cancelCloseAction()
464 void MainWindow::showAboutPage()
466 QMessageBox::information(this, tr("About"),
467 tr("OpenAL Soft Configuration Utility.\nBuilt for OpenAL Soft library version ")+
468 (ALSOFT_VERSION
"-" ALSOFT_GIT_COMMIT_HASH
" (" ALSOFT_GIT_BRANCH
" branch).")
473 QStringList
MainWindow::collectHrtfs()
476 QStringList processed
;
478 for(int i
= 0;i
< ui
->hrtfFileList
->count();i
++)
480 QDir
dir(ui
->hrtfFileList
->item(i
)->text());
481 QStringList fnames
= dir
.entryList(QDir::Files
| QDir::Readable
, QDir::Name
);
482 foreach(const QString
&fname
, fnames
)
484 if(!fname
.endsWith(".mhr", Qt::CaseInsensitive
))
486 QString fullname
= dir
.absoluteFilePath(fname
);
487 if(processed
.contains(fullname
))
489 processed
.push_back(fullname
);
491 QString name
= fname
.left(fname
.length()-4);
492 if(!ret
.contains(name
))
498 QString s
= name
+" #"+QString::number(i
);
510 if(ui
->defaultHrtfPathsCheckBox
->isChecked())
512 QStringList paths
= getAllDataPaths("/openal/hrtf");
513 foreach(const QString
&name
, paths
)
516 QStringList fnames
= dir
.entryList(QDir::Files
| QDir::Readable
, QDir::Name
);
517 foreach(const QString
&fname
, fnames
)
519 if(!fname
.endsWith(".mhr", Qt::CaseInsensitive
))
521 QString fullname
= dir
.absoluteFilePath(fname
);
522 if(processed
.contains(fullname
))
524 processed
.push_back(fullname
);
526 QString name
= fname
.left(fname
.length()-4);
527 if(!ret
.contains(name
))
533 QString s
= name
+" #"+QString::number(i
);
545 #ifdef ALSOFT_EMBED_HRTF_DATA
546 ret
.push_back("Built-In 44100hz");
547 ret
.push_back("Built-In 48000hz");
554 void MainWindow::loadConfigFromFile()
556 QString fname
= QFileDialog::getOpenFileName(this, tr("Select Files"));
557 if(fname
.isEmpty() == false)
561 void MainWindow::loadConfig(const QString
&fname
)
563 QSettings
settings(fname
, QSettings::IniFormat
);
565 QString sampletype
= settings
.value("sample-type").toString();
566 ui
->sampleFormatCombo
->setCurrentIndex(0);
567 if(sampletype
.isEmpty() == false)
569 QString str
= getNameFromValue(sampleTypeList
, sampletype
);
572 int j
= ui
->sampleFormatCombo
->findText(str
);
573 if(j
> 0) ui
->sampleFormatCombo
->setCurrentIndex(j
);
577 QString channelconfig
= settings
.value("channels").toString();
578 ui
->channelConfigCombo
->setCurrentIndex(0);
579 if(channelconfig
.isEmpty() == false)
581 QString str
= getNameFromValue(speakerModeList
, channelconfig
);
584 int j
= ui
->channelConfigCombo
->findText(str
);
585 if(j
> 0) ui
->channelConfigCombo
->setCurrentIndex(j
);
589 QString srate
= settings
.value("frequency").toString();
591 ui
->sampleRateCombo
->setCurrentIndex(0);
594 ui
->sampleRateCombo
->lineEdit()->clear();
595 ui
->sampleRateCombo
->lineEdit()->insert(srate
);
598 ui
->srcCountLineEdit
->clear();
599 ui
->srcCountLineEdit
->insert(settings
.value("sources").toString());
600 ui
->effectSlotLineEdit
->clear();
601 ui
->effectSlotLineEdit
->insert(settings
.value("slots").toString());
602 ui
->srcSendLineEdit
->clear();
603 ui
->srcSendLineEdit
->insert(settings
.value("sends").toString());
605 QString resampler
= settings
.value("resampler").toString().trimmed();
606 ui
->resamplerSlider
->setValue(2);
607 ui
->resamplerLabel
->setText(resamplerList
[2].name
);
608 /* The "cubic" and "sinc8" resamplers are no longer supported. Use "sinc4"
611 if(resampler
== "cubic" || resampler
== "sinc8")
613 for(int i
= 0;resamplerList
[i
].name
[0];i
++)
615 if(resampler
== resamplerList
[i
].value
)
617 ui
->resamplerSlider
->setValue(i
);
618 ui
->resamplerLabel
->setText(resamplerList
[i
].name
);
623 QString stereomode
= settings
.value("stereo-mode").toString().trimmed();
624 ui
->stereoModeCombo
->setCurrentIndex(0);
625 if(stereomode
.isEmpty() == false)
627 QString str
= getNameFromValue(stereoModeList
, stereomode
);
630 int j
= ui
->stereoModeCombo
->findText(str
);
631 if(j
> 0) ui
->stereoModeCombo
->setCurrentIndex(j
);
635 int periodsize
= settings
.value("period_size").toInt();
636 ui
->periodSizeEdit
->clear();
639 ui
->periodSizeEdit
->insert(QString::number(periodsize
));
640 updatePeriodSizeSlider();
643 int periodcount
= settings
.value("periods").toInt();
644 ui
->periodCountEdit
->clear();
647 ui
->periodCountEdit
->insert(QString::number(periodcount
));
648 updatePeriodCountSlider();
651 if(settings
.value("output-limiter").isNull())
652 ui
->outputLimiterCheckBox
->setCheckState(Qt::PartiallyChecked
);
654 ui
->outputLimiterCheckBox
->setCheckState(
655 settings
.value("output-limiter").toBool() ? Qt::Checked
: Qt::Unchecked
658 if(settings
.value("dither").isNull())
659 ui
->outputDitherCheckBox
->setCheckState(Qt::PartiallyChecked
);
661 ui
->outputDitherCheckBox
->setCheckState(
662 settings
.value("dither").toBool() ? Qt::Checked
: Qt::Unchecked
665 QString stereopan
= settings
.value("stereo-encoding").toString();
666 ui
->stereoEncodingComboBox
->setCurrentIndex(0);
667 if(stereopan
.isEmpty() == false)
669 QString str
= getNameFromValue(stereoEncList
, stereopan
);
672 int j
= ui
->stereoEncodingComboBox
->findText(str
);
673 if(j
> 0) ui
->stereoEncodingComboBox
->setCurrentIndex(j
);
677 QString ambiformat
= settings
.value("ambi-format").toString();
678 ui
->ambiFormatComboBox
->setCurrentIndex(0);
679 if(ambiformat
.isEmpty() == false)
681 QString str
= getNameFromValue(ambiFormatList
, ambiformat
);
684 int j
= ui
->ambiFormatComboBox
->findText(str
);
685 if(j
> 0) ui
->ambiFormatComboBox
->setCurrentIndex(j
);
689 bool hqmode
= settings
.value("decoder/hq-mode", false).toBool();
690 ui
->decoderHQModeCheckBox
->setChecked(hqmode
);
691 bool distcomp
= settings
.value("decoder/distance-comp", true).toBool();
692 ui
->decoderDistCompCheckBox
->setChecked(distcomp
);
693 bool nfeffects
= settings
.value("decoder/nfc", true).toBool();
694 ui
->decoderNFEffectsCheckBox
->setChecked(nfeffects
);
695 double refdelay
= settings
.value("decoder/nfc-ref-delay", 0.0).toDouble();
696 ui
->decoderNFRefDelaySpinBox
->setValue(refdelay
);
698 ui
->decoderQuadLineEdit
->setText(settings
.value("decoder/quad").toString());
699 ui
->decoder51LineEdit
->setText(settings
.value("decoder/surround51").toString());
700 ui
->decoder61LineEdit
->setText(settings
.value("decoder/surround61").toString());
701 ui
->decoder71LineEdit
->setText(settings
.value("decoder/surround71").toString());
703 QStringList disabledCpuExts
= settings
.value("disable-cpu-exts").toStringList();
704 if(disabledCpuExts
.size() == 1)
705 disabledCpuExts
= disabledCpuExts
[0].split(QChar(','));
706 for(QStringList::iterator iter
= disabledCpuExts
.begin();iter
!= disabledCpuExts
.end();iter
++)
707 *iter
= iter
->trimmed();
708 ui
->enableSSECheckBox
->setChecked(!disabledCpuExts
.contains("sse", Qt::CaseInsensitive
));
709 ui
->enableSSE2CheckBox
->setChecked(!disabledCpuExts
.contains("sse2", Qt::CaseInsensitive
));
710 ui
->enableSSE3CheckBox
->setChecked(!disabledCpuExts
.contains("sse3", Qt::CaseInsensitive
));
711 ui
->enableSSE41CheckBox
->setChecked(!disabledCpuExts
.contains("sse4.1", Qt::CaseInsensitive
));
712 ui
->enableNeonCheckBox
->setChecked(!disabledCpuExts
.contains("neon", Qt::CaseInsensitive
));
714 QStringList hrtf_paths
= settings
.value("hrtf-paths").toStringList();
715 if(hrtf_paths
.size() == 1)
716 hrtf_paths
= hrtf_paths
[0].split(QChar(','));
717 for(QStringList::iterator iter
= hrtf_paths
.begin();iter
!= hrtf_paths
.end();iter
++)
718 *iter
= iter
->trimmed();
719 if(!hrtf_paths
.empty() && !hrtf_paths
.back().isEmpty())
720 ui
->defaultHrtfPathsCheckBox
->setCheckState(Qt::Unchecked
);
723 hrtf_paths
.removeAll(QString());
724 ui
->defaultHrtfPathsCheckBox
->setCheckState(Qt::Checked
);
726 hrtf_paths
.removeDuplicates();
727 ui
->hrtfFileList
->clear();
728 ui
->hrtfFileList
->addItems(hrtf_paths
);
729 updateHrtfRemoveButton();
731 QString hrtfstate
= settings
.value("hrtf").toString().toLower();
732 if(hrtfstate
== "true")
733 ui
->hrtfStateComboBox
->setCurrentIndex(1);
734 else if(hrtfstate
== "false")
735 ui
->hrtfStateComboBox
->setCurrentIndex(2);
737 ui
->hrtfStateComboBox
->setCurrentIndex(0);
739 ui
->preferredHrtfComboBox
->clear();
740 ui
->preferredHrtfComboBox
->addItem("- Any -");
741 if(ui
->defaultHrtfPathsCheckBox
->isChecked())
743 QStringList hrtfs
= collectHrtfs();
744 foreach(const QString
&name
, hrtfs
)
745 ui
->preferredHrtfComboBox
->addItem(name
);
748 QString defaulthrtf
= settings
.value("default-hrtf").toString();
749 ui
->preferredHrtfComboBox
->setCurrentIndex(0);
750 if(defaulthrtf
.isEmpty() == false)
752 int i
= ui
->preferredHrtfComboBox
->findText(defaulthrtf
);
754 ui
->preferredHrtfComboBox
->setCurrentIndex(i
);
757 i
= ui
->preferredHrtfComboBox
->count();
758 ui
->preferredHrtfComboBox
->addItem(defaulthrtf
);
759 ui
->preferredHrtfComboBox
->setCurrentIndex(i
);
762 ui
->preferredHrtfComboBox
->adjustSize();
764 ui
->enabledBackendList
->clear();
765 ui
->disabledBackendList
->clear();
766 QStringList drivers
= settings
.value("drivers").toStringList();
767 if(drivers
.size() == 0)
768 ui
->backendCheckBox
->setChecked(true);
771 if(drivers
.size() == 1)
772 drivers
= drivers
[0].split(QChar(','));
773 for(QStringList::iterator iter
= drivers
.begin();iter
!= drivers
.end();iter
++)
774 *iter
= iter
->trimmed();
776 bool lastWasEmpty
= false;
777 foreach(const QString
&backend
, drivers
)
779 lastWasEmpty
= backend
.isEmpty();
780 if(lastWasEmpty
) continue;
782 if(!backend
.startsWith(QChar('-')))
783 for(int j
= 0;backendList
[j
].backend_name
[0];j
++)
785 if(backend
== backendList
[j
].backend_name
)
787 ui
->enabledBackendList
->addItem(backendList
[j
].full_string
);
791 else if(backend
.size() > 1)
793 QStringRef backendref
= backend
.rightRef(backend
.size()-1);
794 for(int j
= 0;backendList
[j
].backend_name
[0];j
++)
796 if(backendref
== backendList
[j
].backend_name
)
798 ui
->disabledBackendList
->addItem(backendList
[j
].full_string
);
804 ui
->backendCheckBox
->setChecked(lastWasEmpty
);
807 QString defaultreverb
= settings
.value("default-reverb").toString().toLower();
808 ui
->defaultReverbComboBox
->setCurrentIndex(0);
809 if(defaultreverb
.isEmpty() == false)
811 for(int i
= 0;i
< ui
->defaultReverbComboBox
->count();i
++)
813 if(defaultreverb
.compare(ui
->defaultReverbComboBox
->itemText(i
).toLower()) == 0)
815 ui
->defaultReverbComboBox
->setCurrentIndex(i
);
821 ui
->emulateEaxCheckBox
->setChecked(settings
.value("reverb/emulate-eax", false).toBool());
823 QStringList excludefx
= settings
.value("excludefx").toStringList();
824 if(excludefx
.size() == 1)
825 excludefx
= excludefx
[0].split(QChar(','));
826 for(QStringList::iterator iter
= excludefx
.begin();iter
!= excludefx
.end();iter
++)
827 *iter
= iter
->trimmed();
828 ui
->enableEaxReverbCheck
->setChecked(!excludefx
.contains("eaxreverb", Qt::CaseInsensitive
));
829 ui
->enableStdReverbCheck
->setChecked(!excludefx
.contains("reverb", Qt::CaseInsensitive
));
830 ui
->enableChorusCheck
->setChecked(!excludefx
.contains("chorus", Qt::CaseInsensitive
));
831 ui
->enableCompressorCheck
->setChecked(!excludefx
.contains("compressor", Qt::CaseInsensitive
));
832 ui
->enableDistortionCheck
->setChecked(!excludefx
.contains("distortion", Qt::CaseInsensitive
));
833 ui
->enableEchoCheck
->setChecked(!excludefx
.contains("echo", Qt::CaseInsensitive
));
834 ui
->enableEqualizerCheck
->setChecked(!excludefx
.contains("equalizer", Qt::CaseInsensitive
));
835 ui
->enableFlangerCheck
->setChecked(!excludefx
.contains("flanger", Qt::CaseInsensitive
));
836 ui
->enableModulatorCheck
->setChecked(!excludefx
.contains("modulator", Qt::CaseInsensitive
));
837 ui
->enableDedicatedCheck
->setChecked(!excludefx
.contains("dedicated", Qt::CaseInsensitive
));
839 ui
->pulseAutospawnCheckBox
->setChecked(settings
.value("pulse/spawn-server", true).toBool());
840 ui
->pulseAllowMovesCheckBox
->setChecked(settings
.value("pulse/allow-moves", false).toBool());
841 ui
->pulseFixRateCheckBox
->setChecked(settings
.value("pulse/fix-rate", false).toBool());
843 ui
->jackAutospawnCheckBox
->setChecked(settings
.value("jack/spawn-server", false).toBool());
844 ui
->jackBufferSizeLine
->setText(settings
.value("jack/buffer-size", QString()).toString());
845 updateJackBufferSizeSlider();
847 ui
->alsaDefaultDeviceLine
->setText(settings
.value("alsa/device", QString()).toString());
848 ui
->alsaDefaultCaptureLine
->setText(settings
.value("alsa/capture", QString()).toString());
849 ui
->alsaResamplerCheckBox
->setChecked(settings
.value("alsa/allow-resampler", false).toBool());
850 ui
->alsaMmapCheckBox
->setChecked(settings
.value("alsa/mmap", true).toBool());
852 ui
->ossDefaultDeviceLine
->setText(settings
.value("oss/device", QString()).toString());
853 ui
->ossDefaultCaptureLine
->setText(settings
.value("oss/capture", QString()).toString());
855 ui
->solarisDefaultDeviceLine
->setText(settings
.value("solaris/device", QString()).toString());
857 ui
->waveOutputLine
->setText(settings
.value("wave/file", QString()).toString());
858 ui
->waveBFormatCheckBox
->setChecked(settings
.value("wave/bformat", false).toBool());
860 ui
->applyButton
->setEnabled(false);
861 ui
->closeCancelButton
->setText(tr("Close"));
865 void MainWindow::saveCurrentConfig()
867 saveConfig(getDefaultConfigName());
868 ui
->applyButton
->setEnabled(false);
869 ui
->closeCancelButton
->setText(tr("Close"));
871 QMessageBox::information(this, tr("Information"),
872 tr("Applications using OpenAL need to be restarted for changes to take effect."));
875 void MainWindow::saveConfigAsFile()
877 QString fname
= QFileDialog::getOpenFileName(this, tr("Select Files"));
878 if(fname
.isEmpty() == false)
881 ui
->applyButton
->setEnabled(false);
886 void MainWindow::saveConfig(const QString
&fname
) const
888 QSettings
settings(fname
, QSettings::IniFormat
);
890 /* HACK: Compound any stringlist values into a comma-separated string. */
891 QStringList allkeys
= settings
.allKeys();
892 foreach(const QString
&key
, allkeys
)
894 QStringList vals
= settings
.value(key
).toStringList();
896 settings
.setValue(key
, vals
.join(QChar(',')));
899 settings
.setValue("sample-type", getValueFromName(sampleTypeList
, ui
->sampleFormatCombo
->currentText()));
900 settings
.setValue("channels", getValueFromName(speakerModeList
, ui
->channelConfigCombo
->currentText()));
902 uint rate
= ui
->sampleRateCombo
->currentText().toUInt();
904 settings
.setValue("frequency", QString());
906 settings
.setValue("frequency", rate
);
908 settings
.setValue("period_size", ui
->periodSizeEdit
->text());
909 settings
.setValue("periods", ui
->periodCountEdit
->text());
911 settings
.setValue("sources", ui
->srcCountLineEdit
->text());
912 settings
.setValue("slots", ui
->effectSlotLineEdit
->text());
914 settings
.setValue("resampler", resamplerList
[ui
->resamplerSlider
->value()].value
);
916 settings
.setValue("stereo-mode", getValueFromName(stereoModeList
, ui
->stereoModeCombo
->currentText()));
917 settings
.setValue("stereo-encoding", getValueFromName(stereoEncList
, ui
->stereoEncodingComboBox
->currentText()));
918 settings
.setValue("ambi-format", getValueFromName(ambiFormatList
, ui
->ambiFormatComboBox
->currentText()));
920 Qt::CheckState limiter
= ui
->outputLimiterCheckBox
->checkState();
921 if(limiter
== Qt::PartiallyChecked
)
922 settings
.setValue("output-limiter", QString());
923 else if(limiter
== Qt::Checked
)
924 settings
.setValue("output-limiter", QString("true"));
925 else if(limiter
== Qt::Unchecked
)
926 settings
.setValue("output-limiter", QString("false"));
928 Qt::CheckState dither
= ui
->outputDitherCheckBox
->checkState();
929 if(dither
== Qt::PartiallyChecked
)
930 settings
.setValue("dither", QString());
931 else if(dither
== Qt::Checked
)
932 settings
.setValue("dither", QString("true"));
933 else if(dither
== Qt::Unchecked
)
934 settings
.setValue("dither", QString("false"));
936 settings
.setValue("decoder/hq-mode",
937 ui
->decoderHQModeCheckBox
->isChecked() ? QString("true") : QString(/*"false"*/)
939 settings
.setValue("decoder/distance-comp",
940 ui
->decoderDistCompCheckBox
->isChecked() ? QString(/*"true"*/) : QString("false")
942 settings
.setValue("decoder/nfc",
943 ui
->decoderNFEffectsCheckBox
->isChecked() ? QString(/*"true"*/) : QString("false")
945 double refdelay
= ui
->decoderNFRefDelaySpinBox
->value();
946 settings
.setValue("decoder/nfc-ref-delay",
947 (refdelay
> 0.0) ? QString::number(refdelay
) : QString()
950 settings
.setValue("decoder/quad", ui
->decoderQuadLineEdit
->text());
951 settings
.setValue("decoder/surround51", ui
->decoder51LineEdit
->text());
952 settings
.setValue("decoder/surround61", ui
->decoder61LineEdit
->text());
953 settings
.setValue("decoder/surround71", ui
->decoder71LineEdit
->text());
956 if(!ui
->enableSSECheckBox
->isChecked())
957 strlist
.append("sse");
958 if(!ui
->enableSSE2CheckBox
->isChecked())
959 strlist
.append("sse2");
960 if(!ui
->enableSSE3CheckBox
->isChecked())
961 strlist
.append("sse3");
962 if(!ui
->enableSSE41CheckBox
->isChecked())
963 strlist
.append("sse4.1");
964 if(!ui
->enableNeonCheckBox
->isChecked())
965 strlist
.append("neon");
966 settings
.setValue("disable-cpu-exts", strlist
.join(QChar(',')));
968 if(ui
->hrtfStateComboBox
->currentIndex() == 1)
969 settings
.setValue("hrtf", "true");
970 else if(ui
->hrtfStateComboBox
->currentIndex() == 2)
971 settings
.setValue("hrtf", "false");
973 settings
.setValue("hrtf", QString());
975 if(ui
->preferredHrtfComboBox
->currentIndex() == 0)
976 settings
.setValue("default-hrtf", QString());
979 QString str
= ui
->preferredHrtfComboBox
->currentText();
980 settings
.setValue("default-hrtf", str
);
984 for(int i
= 0;i
< ui
->hrtfFileList
->count();i
++)
985 strlist
.append(ui
->hrtfFileList
->item(i
)->text());
986 if(!strlist
.empty() && ui
->defaultHrtfPathsCheckBox
->isChecked())
987 strlist
.append(QString());
988 settings
.setValue("hrtf-paths", strlist
.join(QChar(',')));
991 for(int i
= 0;i
< ui
->enabledBackendList
->count();i
++)
993 QString label
= ui
->enabledBackendList
->item(i
)->text();
994 for(int j
= 0;backendList
[j
].backend_name
[0];j
++)
996 if(label
== backendList
[j
].full_string
)
998 strlist
.append(backendList
[j
].backend_name
);
1003 for(int i
= 0;i
< ui
->disabledBackendList
->count();i
++)
1005 QString label
= ui
->disabledBackendList
->item(i
)->text();
1006 for(int j
= 0;backendList
[j
].backend_name
[0];j
++)
1008 if(label
== backendList
[j
].full_string
)
1010 strlist
.append(QChar('-')+QString(backendList
[j
].backend_name
));
1015 if(strlist
.size() == 0 && !ui
->backendCheckBox
->isChecked())
1016 strlist
.append("-all");
1017 else if(ui
->backendCheckBox
->isChecked())
1018 strlist
.append(QString());
1019 settings
.setValue("drivers", strlist
.join(QChar(',')));
1021 // TODO: Remove check when we can properly match global values.
1022 if(ui
->defaultReverbComboBox
->currentIndex() == 0)
1023 settings
.setValue("default-reverb", QString());
1026 QString str
= ui
->defaultReverbComboBox
->currentText().toLower();
1027 settings
.setValue("default-reverb", str
);
1030 if(ui
->emulateEaxCheckBox
->isChecked())
1031 settings
.setValue("reverb/emulate-eax", "true");
1033 settings
.remove("reverb/emulate-eax"/*, "false"*/);
1036 if(!ui
->enableEaxReverbCheck
->isChecked())
1037 strlist
.append("eaxreverb");
1038 if(!ui
->enableStdReverbCheck
->isChecked())
1039 strlist
.append("reverb");
1040 if(!ui
->enableChorusCheck
->isChecked())
1041 strlist
.append("chorus");
1042 if(!ui
->enableDistortionCheck
->isChecked())
1043 strlist
.append("distortion");
1044 if(!ui
->enableCompressorCheck
->isChecked())
1045 strlist
.append("compressor");
1046 if(!ui
->enableEchoCheck
->isChecked())
1047 strlist
.append("echo");
1048 if(!ui
->enableEqualizerCheck
->isChecked())
1049 strlist
.append("equalizer");
1050 if(!ui
->enableFlangerCheck
->isChecked())
1051 strlist
.append("flanger");
1052 if(!ui
->enableModulatorCheck
->isChecked())
1053 strlist
.append("modulator");
1054 if(!ui
->enableDedicatedCheck
->isChecked())
1055 strlist
.append("dedicated");
1056 settings
.setValue("excludefx", strlist
.join(QChar(',')));
1058 settings
.setValue("pulse/spawn-server",
1059 ui
->pulseAutospawnCheckBox
->isChecked() ? QString(/*"true"*/) : QString("false")
1061 settings
.setValue("pulse/allow-moves",
1062 ui
->pulseAllowMovesCheckBox
->isChecked() ? QString("true") : QString(/*"false"*/)
1064 settings
.setValue("pulse/fix-rate",
1065 ui
->pulseFixRateCheckBox
->isChecked() ? QString("true") : QString(/*"false"*/)
1068 settings
.setValue("jack/spawn-server",
1069 ui
->jackAutospawnCheckBox
->isChecked() ? QString("true") : QString(/*"false"*/)
1071 settings
.setValue("jack/buffer-size", ui
->jackBufferSizeLine
->text());
1073 settings
.setValue("alsa/device", ui
->alsaDefaultDeviceLine
->text());
1074 settings
.setValue("alsa/capture", ui
->alsaDefaultCaptureLine
->text());
1075 settings
.setValue("alsa/allow-resampler",
1076 ui
->alsaResamplerCheckBox
->isChecked() ? QString("true") : QString(/*"false"*/)
1078 settings
.setValue("alsa/mmap",
1079 ui
->alsaMmapCheckBox
->isChecked() ? QString(/*"true"*/) : QString("false")
1082 settings
.setValue("oss/device", ui
->ossDefaultDeviceLine
->text());
1083 settings
.setValue("oss/capture", ui
->ossDefaultCaptureLine
->text());
1085 settings
.setValue("solaris/device", ui
->solarisDefaultDeviceLine
->text());
1087 settings
.setValue("wave/file", ui
->waveOutputLine
->text());
1088 settings
.setValue("wave/bformat",
1089 ui
->waveBFormatCheckBox
->isChecked() ? QString("true") : QString(/*"false"*/)
1092 /* Remove empty keys
1093 * FIXME: Should only remove keys whose value matches the globally-specified value.
1095 allkeys
= settings
.allKeys();
1096 foreach(const QString
&key
, allkeys
)
1098 QString str
= settings
.value(key
).toString();
1099 if(str
== QString())
1100 settings
.remove(key
);
1105 void MainWindow::enableApplyButton()
1108 ui
->applyButton
->setEnabled(true);
1110 ui
->closeCancelButton
->setText(tr("Cancel"));
1114 void MainWindow::updateResamplerLabel(int num
)
1116 ui
->resamplerLabel
->setText(resamplerList
[num
].name
);
1117 enableApplyButton();
1121 void MainWindow::updatePeriodSizeEdit(int size
)
1123 ui
->periodSizeEdit
->clear();
1126 size
= (size
+32)&~0x3f;
1127 ui
->periodSizeEdit
->insert(QString::number(size
));
1129 enableApplyButton();
1132 void MainWindow::updatePeriodSizeSlider()
1134 int pos
= ui
->periodSizeEdit
->text().toInt();
1139 ui
->periodSizeSlider
->setSliderPosition(pos
);
1141 enableApplyButton();
1144 void MainWindow::updatePeriodCountEdit(int count
)
1146 ui
->periodCountEdit
->clear();
1148 ui
->periodCountEdit
->insert(QString::number(count
));
1149 enableApplyButton();
1152 void MainWindow::updatePeriodCountSlider()
1154 int pos
= ui
->periodCountEdit
->text().toInt();
1159 ui
->periodCountSlider
->setSliderPosition(pos
);
1160 enableApplyButton();
1164 void MainWindow::selectQuadDecoderFile()
1165 { selectDecoderFile(ui
->decoderQuadLineEdit
, "Select Quadrophonic Decoder");}
1166 void MainWindow::select51DecoderFile()
1167 { selectDecoderFile(ui
->decoder51LineEdit
, "Select 5.1 Surround Decoder");}
1168 void MainWindow::select61DecoderFile()
1169 { selectDecoderFile(ui
->decoder61LineEdit
, "Select 6.1 Surround Decoder");}
1170 void MainWindow::select71DecoderFile()
1171 { selectDecoderFile(ui
->decoder71LineEdit
, "Select 7.1 Surround Decoder");}
1172 void MainWindow::selectDecoderFile(QLineEdit
*line
, const char *caption
)
1174 QString dir
= line
->text();
1175 if(dir
.isEmpty() || QDir::isRelativePath(dir
))
1177 QStringList paths
= getAllDataPaths("/openal/presets");
1178 while(!paths
.isEmpty())
1180 if(QDir(paths
.last()).exists())
1188 QString fname
= QFileDialog::getOpenFileName(this, tr(caption
),
1189 dir
, tr("AmbDec Files (*.ambdec);;All Files (*.*)")
1191 if(!fname
.isEmpty())
1193 line
->setText(fname
);
1194 enableApplyButton();
1199 void MainWindow::updateJackBufferSizeEdit(int size
)
1201 ui
->jackBufferSizeLine
->clear();
1203 ui
->jackBufferSizeLine
->insert(QString::number(1<<size
));
1204 enableApplyButton();
1207 void MainWindow::updateJackBufferSizeSlider()
1209 int value
= ui
->jackBufferSizeLine
->text().toInt();
1210 int pos
= (int)floor(log2(value
) + 0.5);
1211 ui
->jackBufferSizeSlider
->setSliderPosition(pos
);
1212 enableApplyButton();
1216 void MainWindow::addHrtfFile()
1218 QString path
= QFileDialog::getExistingDirectory(this, tr("Select HRTF Path"));
1219 if(path
.isEmpty() == false && !getAllDataPaths("/openal/hrtf").contains(path
))
1221 ui
->hrtfFileList
->addItem(path
);
1222 enableApplyButton();
1226 void MainWindow::removeHrtfFile()
1228 QList
<QListWidgetItem
*> selected
= ui
->hrtfFileList
->selectedItems();
1229 if(!selected
.isEmpty())
1231 foreach(QListWidgetItem
*item
, selected
)
1233 enableApplyButton();
1237 void MainWindow::updateHrtfRemoveButton()
1239 ui
->hrtfRemoveButton
->setEnabled(ui
->hrtfFileList
->selectedItems().size() != 0);
1242 void MainWindow::showEnabledBackendMenu(QPoint pt
)
1244 QMap
<QAction
*,QString
> actionMap
;
1246 pt
= ui
->enabledBackendList
->mapToGlobal(pt
);
1249 QAction
*removeAction
= ctxmenu
.addAction(QIcon::fromTheme("list-remove"), "Remove");
1250 if(ui
->enabledBackendList
->selectedItems().size() == 0)
1251 removeAction
->setEnabled(false);
1252 ctxmenu
.addSeparator();
1253 for(size_t i
= 0;backendList
[i
].backend_name
[0];i
++)
1255 QString backend
= backendList
[i
].full_string
;
1256 QAction
*action
= ctxmenu
.addAction(QString("Add ")+backend
);
1257 actionMap
[action
] = backend
;
1258 if(ui
->enabledBackendList
->findItems(backend
, Qt::MatchFixedString
).size() != 0 ||
1259 ui
->disabledBackendList
->findItems(backend
, Qt::MatchFixedString
).size() != 0)
1260 action
->setEnabled(false);
1263 QAction
*gotAction
= ctxmenu
.exec(pt
);
1264 if(gotAction
== removeAction
)
1266 QList
<QListWidgetItem
*> selected
= ui
->enabledBackendList
->selectedItems();
1267 foreach(QListWidgetItem
*item
, selected
)
1269 enableApplyButton();
1271 else if(gotAction
!= NULL
)
1273 QMap
<QAction
*,QString
>::const_iterator iter
= actionMap
.find(gotAction
);
1274 if(iter
!= actionMap
.end())
1275 ui
->enabledBackendList
->addItem(iter
.value());
1276 enableApplyButton();
1280 void MainWindow::showDisabledBackendMenu(QPoint pt
)
1282 QMap
<QAction
*,QString
> actionMap
;
1284 pt
= ui
->disabledBackendList
->mapToGlobal(pt
);
1287 QAction
*removeAction
= ctxmenu
.addAction(QIcon::fromTheme("list-remove"), "Remove");
1288 if(ui
->disabledBackendList
->selectedItems().size() == 0)
1289 removeAction
->setEnabled(false);
1290 ctxmenu
.addSeparator();
1291 for(size_t i
= 0;backendList
[i
].backend_name
[0];i
++)
1293 QString backend
= backendList
[i
].full_string
;
1294 QAction
*action
= ctxmenu
.addAction(QString("Add ")+backend
);
1295 actionMap
[action
] = backend
;
1296 if(ui
->disabledBackendList
->findItems(backend
, Qt::MatchFixedString
).size() != 0 ||
1297 ui
->enabledBackendList
->findItems(backend
, Qt::MatchFixedString
).size() != 0)
1298 action
->setEnabled(false);
1301 QAction
*gotAction
= ctxmenu
.exec(pt
);
1302 if(gotAction
== removeAction
)
1304 QList
<QListWidgetItem
*> selected
= ui
->disabledBackendList
->selectedItems();
1305 foreach(QListWidgetItem
*item
, selected
)
1307 enableApplyButton();
1309 else if(gotAction
!= NULL
)
1311 QMap
<QAction
*,QString
>::const_iterator iter
= actionMap
.find(gotAction
);
1312 if(iter
!= actionMap
.end())
1313 ui
->disabledBackendList
->addItem(iter
.value());
1314 enableApplyButton();
1318 void MainWindow::selectOSSPlayback()
1320 QString current
= ui
->ossDefaultDeviceLine
->text();
1321 if(current
.isEmpty()) current
= ui
->ossDefaultDeviceLine
->placeholderText();
1322 QString fname
= QFileDialog::getOpenFileName(this, tr("Select Playback Device"), current
);
1323 if(!fname
.isEmpty())
1325 ui
->ossDefaultDeviceLine
->setText(fname
);
1326 enableApplyButton();
1330 void MainWindow::selectOSSCapture()
1332 QString current
= ui
->ossDefaultCaptureLine
->text();
1333 if(current
.isEmpty()) current
= ui
->ossDefaultCaptureLine
->placeholderText();
1334 QString fname
= QFileDialog::getOpenFileName(this, tr("Select Capture Device"), current
);
1335 if(!fname
.isEmpty())
1337 ui
->ossDefaultCaptureLine
->setText(fname
);
1338 enableApplyButton();
1342 void MainWindow::selectSolarisPlayback()
1344 QString current
= ui
->solarisDefaultDeviceLine
->text();
1345 if(current
.isEmpty()) current
= ui
->solarisDefaultDeviceLine
->placeholderText();
1346 QString fname
= QFileDialog::getOpenFileName(this, tr("Select Playback Device"), current
);
1347 if(!fname
.isEmpty())
1349 ui
->solarisDefaultDeviceLine
->setText(fname
);
1350 enableApplyButton();
1354 void MainWindow::selectWaveOutput()
1356 QString fname
= QFileDialog::getSaveFileName(this, tr("Select Wave File Output"),
1357 ui
->waveOutputLine
->text(), tr("Wave Files (*.wav *.amb);;All Files (*.*)")
1359 if(!fname
.isEmpty())
1361 ui
->waveOutputLine
->setText(fname
);
1362 enableApplyButton();