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 { "3rd order Sinc", "sinc4" },
104 { "11th order Sinc", "bsinc12" },
105 { "23rd order Sinc", "bsinc24" },
108 }, stereoModeList
[] = {
109 { "Autodetect", "" },
110 { "Speakers", "speakers" },
111 { "Headphones", "headphones" },
114 }, stereoEncList
[] = {
116 { "Pan Pot", "panpot" },
120 }, ambiFormatList
[] = {
122 { "ACN + SN3D", "acn+sn3d" },
123 { "ACN + N3D", "acn+n3d" },
124 { "Furse-Malham", "fuma" },
129 static QString
getDefaultConfigName()
132 static const char fname
[] = "alsoft.ini";
133 QByteArray base
= qgetenv("AppData");
135 static const char fname
[] = "alsoft.conf";
136 QByteArray base
= qgetenv("XDG_CONFIG_HOME");
139 base
= qgetenv("HOME");
140 if(base
.isEmpty() == false)
144 if(base
.isEmpty() == false)
145 return base
+'/'+ fname
;
149 static QString
getBaseDataPath()
152 QByteArray base
= qgetenv("AppData");
154 QByteArray base
= qgetenv("XDG_DATA_HOME");
157 base
= qgetenv("HOME");
159 base
+= "/.local/share";
165 static QStringList
getAllDataPaths(QString append
=QString())
168 list
.append(getBaseDataPath());
170 // TODO: Common AppData path
172 QString paths
= qgetenv("XDG_DATA_DIRS");
174 paths
= "/usr/local/share/:/usr/share/";
175 list
+= paths
.split(QChar(':'), QString::SkipEmptyParts
);
177 QStringList::iterator iter
= list
.begin();
178 while(iter
!= list
.end())
181 iter
= list
.erase(iter
);
184 iter
->append(append
);
192 static QString
getValueFromName(const NameValuePair (&list
)[N
], const QString
&str
)
194 for(size_t i
= 0;i
< N
-1;i
++)
196 if(str
== list
[i
].name
)
197 return list
[i
].value
;
203 static QString
getNameFromValue(const NameValuePair (&list
)[N
], const QString
&str
)
205 for(size_t i
= 0;i
< N
-1;i
++)
207 if(str
== list
[i
].value
)
215 MainWindow::MainWindow(QWidget
*parent
) :
217 ui(new Ui::MainWindow
),
218 mPeriodSizeValidator(NULL
),
219 mPeriodCountValidator(NULL
),
220 mSourceCountValidator(NULL
),
221 mEffectSlotValidator(NULL
),
222 mSourceSendValidator(NULL
),
223 mSampleRateValidator(NULL
),
224 mJackBufferValidator(NULL
),
229 for(int i
= 0;speakerModeList
[i
].name
[0];i
++)
230 ui
->channelConfigCombo
->addItem(speakerModeList
[i
].name
);
231 ui
->channelConfigCombo
->adjustSize();
232 for(int i
= 0;sampleTypeList
[i
].name
[0];i
++)
233 ui
->sampleFormatCombo
->addItem(sampleTypeList
[i
].name
);
234 ui
->sampleFormatCombo
->adjustSize();
235 for(int i
= 0;stereoModeList
[i
].name
[0];i
++)
236 ui
->stereoModeCombo
->addItem(stereoModeList
[i
].name
);
237 ui
->stereoModeCombo
->adjustSize();
238 for(int i
= 0;stereoEncList
[i
].name
[0];i
++)
239 ui
->stereoEncodingComboBox
->addItem(stereoEncList
[i
].name
);
240 ui
->stereoEncodingComboBox
->adjustSize();
241 for(int i
= 0;ambiFormatList
[i
].name
[0];i
++)
242 ui
->ambiFormatComboBox
->addItem(ambiFormatList
[i
].name
);
243 ui
->ambiFormatComboBox
->adjustSize();
246 for(count
= 0;resamplerList
[count
].name
[0];count
++) {
248 ui
->resamplerSlider
->setRange(0, count
-1);
250 ui
->hrtfStateComboBox
->adjustSize();
252 #if !defined(HAVE_NEON) && !defined(HAVE_SSE)
253 ui
->cpuExtDisabledLabel
->move(ui
->cpuExtDisabledLabel
->x(), ui
->cpuExtDisabledLabel
->y() - 60);
255 ui
->cpuExtDisabledLabel
->setVisible(false);
264 ui
->enableSSECheckBox
->setVisible(false);
266 ui
->enableSSE2CheckBox
->setVisible(false);
268 ui
->enableSSE3CheckBox
->setVisible(false);
270 ui
->enableSSE41CheckBox
->setVisible(false);
272 ui
->enableNeonCheckBox
->setVisible(false);
280 ui
->enableNeonCheckBox
->move(ui
->enableNeonCheckBox
->x(), ui
->enableNeonCheckBox
->y() - 30);
281 ui
->enableSSECheckBox
->setVisible(false);
283 ui
->enableSSE2CheckBox
->setVisible(false);
285 ui
->enableSSE3CheckBox
->setVisible(false);
287 ui
->enableSSE41CheckBox
->setVisible(false);
292 mPeriodSizeValidator
= new QIntValidator(64, 8192, this);
293 ui
->periodSizeEdit
->setValidator(mPeriodSizeValidator
);
294 mPeriodCountValidator
= new QIntValidator(2, 16, this);
295 ui
->periodCountEdit
->setValidator(mPeriodCountValidator
);
297 mSourceCountValidator
= new QIntValidator(0, 4096, this);
298 ui
->srcCountLineEdit
->setValidator(mSourceCountValidator
);
299 mEffectSlotValidator
= new QIntValidator(0, 64, this);
300 ui
->effectSlotLineEdit
->setValidator(mEffectSlotValidator
);
301 mSourceSendValidator
= new QIntValidator(0, 16, this);
302 ui
->srcSendLineEdit
->setValidator(mSourceSendValidator
);
303 mSampleRateValidator
= new QIntValidator(8000, 192000, this);
304 ui
->sampleRateCombo
->lineEdit()->setValidator(mSampleRateValidator
);
306 mJackBufferValidator
= new QIntValidator(0, 8192, this);
307 ui
->jackBufferSizeLine
->setValidator(mJackBufferValidator
);
309 connect(ui
->actionLoad
, SIGNAL(triggered()), this, SLOT(loadConfigFromFile()));
310 connect(ui
->actionSave_As
, SIGNAL(triggered()), this, SLOT(saveConfigAsFile()));
312 connect(ui
->actionAbout
, SIGNAL(triggered()), this, SLOT(showAboutPage()));
314 connect(ui
->closeCancelButton
, SIGNAL(clicked()), this, SLOT(cancelCloseAction()));
315 connect(ui
->applyButton
, SIGNAL(clicked()), this, SLOT(saveCurrentConfig()));
317 connect(ui
->channelConfigCombo
, SIGNAL(currentIndexChanged(const QString
&)), this, SLOT(enableApplyButton()));
318 connect(ui
->sampleFormatCombo
, SIGNAL(currentIndexChanged(const QString
&)), this, SLOT(enableApplyButton()));
319 connect(ui
->stereoModeCombo
, SIGNAL(currentIndexChanged(const QString
&)), this, SLOT(enableApplyButton()));
320 connect(ui
->sampleRateCombo
, SIGNAL(currentIndexChanged(const QString
&)), this, SLOT(enableApplyButton()));
321 connect(ui
->sampleRateCombo
, SIGNAL(editTextChanged(const QString
&)), this, SLOT(enableApplyButton()));
323 connect(ui
->resamplerSlider
, SIGNAL(valueChanged(int)), this, SLOT(updateResamplerLabel(int)));
325 connect(ui
->periodSizeSlider
, SIGNAL(valueChanged(int)), this, SLOT(updatePeriodSizeEdit(int)));
326 connect(ui
->periodSizeEdit
, SIGNAL(editingFinished()), this, SLOT(updatePeriodSizeSlider()));
327 connect(ui
->periodCountSlider
, SIGNAL(valueChanged(int)), this, SLOT(updatePeriodCountEdit(int)));
328 connect(ui
->periodCountEdit
, SIGNAL(editingFinished()), this, SLOT(updatePeriodCountSlider()));
330 connect(ui
->stereoEncodingComboBox
, SIGNAL(currentIndexChanged(QString
)), this, SLOT(enableApplyButton()));
331 connect(ui
->ambiFormatComboBox
, SIGNAL(currentIndexChanged(QString
)), this, SLOT(enableApplyButton()));
332 connect(ui
->outputLimiterCheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
333 connect(ui
->outputDitherCheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
335 connect(ui
->decoderHQModeCheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
336 connect(ui
->decoderDistCompCheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
337 connect(ui
->decoderNFEffectsCheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
338 connect(ui
->decoderNFRefDelaySpinBox
, SIGNAL(valueChanged(double)), this, SLOT(enableApplyButton()));
339 connect(ui
->decoderQuadLineEdit
, SIGNAL(textChanged(QString
)), this, SLOT(enableApplyButton()));
340 connect(ui
->decoderQuadButton
, SIGNAL(clicked()), this, SLOT(selectQuadDecoderFile()));
341 connect(ui
->decoder51LineEdit
, SIGNAL(textChanged(QString
)), this, SLOT(enableApplyButton()));
342 connect(ui
->decoder51Button
, SIGNAL(clicked()), this, SLOT(select51DecoderFile()));
343 connect(ui
->decoder61LineEdit
, SIGNAL(textChanged(QString
)), this, SLOT(enableApplyButton()));
344 connect(ui
->decoder61Button
, SIGNAL(clicked()), this, SLOT(select61DecoderFile()));
345 connect(ui
->decoder71LineEdit
, SIGNAL(textChanged(QString
)), this, SLOT(enableApplyButton()));
346 connect(ui
->decoder71Button
, SIGNAL(clicked()), this, SLOT(select71DecoderFile()));
348 connect(ui
->preferredHrtfComboBox
, SIGNAL(currentIndexChanged(const QString
&)), this, SLOT(enableApplyButton()));
349 connect(ui
->hrtfStateComboBox
, SIGNAL(currentIndexChanged(const QString
&)), this, SLOT(enableApplyButton()));
350 connect(ui
->hrtfAddButton
, SIGNAL(clicked()), this, SLOT(addHrtfFile()));
351 connect(ui
->hrtfRemoveButton
, SIGNAL(clicked()), this, SLOT(removeHrtfFile()));
352 connect(ui
->hrtfFileList
, SIGNAL(itemSelectionChanged()), this, SLOT(updateHrtfRemoveButton()));
353 connect(ui
->defaultHrtfPathsCheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
355 connect(ui
->srcCountLineEdit
, SIGNAL(editingFinished()), this, SLOT(enableApplyButton()));
356 connect(ui
->srcSendLineEdit
, SIGNAL(editingFinished()), this, SLOT(enableApplyButton()));
357 connect(ui
->effectSlotLineEdit
, SIGNAL(editingFinished()), this, SLOT(enableApplyButton()));
359 connect(ui
->enableSSECheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
360 connect(ui
->enableSSE2CheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
361 connect(ui
->enableSSE3CheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
362 connect(ui
->enableSSE41CheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
363 connect(ui
->enableNeonCheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
365 ui
->enabledBackendList
->setContextMenuPolicy(Qt::CustomContextMenu
);
366 connect(ui
->enabledBackendList
, SIGNAL(customContextMenuRequested(QPoint
)), this, SLOT(showEnabledBackendMenu(QPoint
)));
368 ui
->disabledBackendList
->setContextMenuPolicy(Qt::CustomContextMenu
);
369 connect(ui
->disabledBackendList
, SIGNAL(customContextMenuRequested(QPoint
)), this, SLOT(showDisabledBackendMenu(QPoint
)));
370 connect(ui
->backendCheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
372 connect(ui
->defaultReverbComboBox
, SIGNAL(currentIndexChanged(const QString
&)), this, SLOT(enableApplyButton()));
373 connect(ui
->emulateEaxCheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
374 connect(ui
->enableEaxReverbCheck
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
375 connect(ui
->enableStdReverbCheck
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
376 connect(ui
->enableChorusCheck
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
377 connect(ui
->enableCompressorCheck
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
378 connect(ui
->enableDistortionCheck
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
379 connect(ui
->enableEchoCheck
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
380 connect(ui
->enableEqualizerCheck
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
381 connect(ui
->enableFlangerCheck
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
382 connect(ui
->enableModulatorCheck
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
383 connect(ui
->enableDedicatedCheck
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
385 connect(ui
->pulseAutospawnCheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
386 connect(ui
->pulseAllowMovesCheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
387 connect(ui
->pulseFixRateCheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
389 connect(ui
->jackAutospawnCheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
390 connect(ui
->jackBufferSizeSlider
, SIGNAL(valueChanged(int)), this, SLOT(updateJackBufferSizeEdit(int)));
391 connect(ui
->jackBufferSizeLine
, SIGNAL(editingFinished()), this, SLOT(updateJackBufferSizeSlider()));
393 connect(ui
->alsaDefaultDeviceLine
, SIGNAL(textChanged(QString
)), this, SLOT(enableApplyButton()));
394 connect(ui
->alsaDefaultCaptureLine
, SIGNAL(textChanged(QString
)), this, SLOT(enableApplyButton()));
395 connect(ui
->alsaResamplerCheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
396 connect(ui
->alsaMmapCheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
398 connect(ui
->ossDefaultDeviceLine
, SIGNAL(textChanged(QString
)), this, SLOT(enableApplyButton()));
399 connect(ui
->ossPlaybackPushButton
, SIGNAL(clicked(bool)), this, SLOT(selectOSSPlayback()));
400 connect(ui
->ossDefaultCaptureLine
, SIGNAL(textChanged(QString
)), this, SLOT(enableApplyButton()));
401 connect(ui
->ossCapturePushButton
, SIGNAL(clicked(bool)), this, SLOT(selectOSSCapture()));
403 connect(ui
->solarisDefaultDeviceLine
, SIGNAL(textChanged(QString
)), this, SLOT(enableApplyButton()));
404 connect(ui
->solarisPlaybackPushButton
, SIGNAL(clicked(bool)), this, SLOT(selectSolarisPlayback()));
406 connect(ui
->waveOutputLine
, SIGNAL(textChanged(QString
)), this, SLOT(enableApplyButton()));
407 connect(ui
->waveOutputButton
, SIGNAL(clicked(bool)), this, SLOT(selectWaveOutput()));
408 connect(ui
->waveBFormatCheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
410 ui
->backendListWidget
->setCurrentRow(0);
411 ui
->tabWidget
->setCurrentIndex(0);
413 for(int i
= 1;i
< ui
->backendListWidget
->count();i
++)
414 ui
->backendListWidget
->setRowHidden(i
, true);
415 for(int i
= 0;backendList
[i
].backend_name
[0];i
++)
417 QList
<QListWidgetItem
*> items
= ui
->backendListWidget
->findItems(
418 backendList
[i
].full_string
, Qt::MatchFixedString
420 foreach(const QListWidgetItem
*item
, items
)
421 ui
->backendListWidget
->setItemHidden(item
, false);
424 loadConfig(getDefaultConfigName());
427 MainWindow::~MainWindow()
430 delete mPeriodSizeValidator
;
431 delete mPeriodCountValidator
;
432 delete mSourceCountValidator
;
433 delete mEffectSlotValidator
;
434 delete mSourceSendValidator
;
435 delete mSampleRateValidator
;
436 delete mJackBufferValidator
;
439 void MainWindow::closeEvent(QCloseEvent
*event
)
445 QMessageBox::StandardButton btn
= QMessageBox::warning(this,
446 tr("Apply changes?"), tr("Save changes before quitting?"),
447 QMessageBox::Save
| QMessageBox::No
| QMessageBox::Cancel
449 if(btn
== QMessageBox::Save
)
451 if(btn
== QMessageBox::Cancel
)
458 void MainWindow::cancelCloseAction()
465 void MainWindow::showAboutPage()
467 QMessageBox::information(this, tr("About"),
468 tr("OpenAL Soft Configuration Utility.\nBuilt for OpenAL Soft library version ")+
469 (ALSOFT_VERSION
"-" ALSOFT_GIT_COMMIT_HASH
" (" ALSOFT_GIT_BRANCH
" branch).")
474 QStringList
MainWindow::collectHrtfs()
477 QStringList processed
;
479 for(int i
= 0;i
< ui
->hrtfFileList
->count();i
++)
481 QDir
dir(ui
->hrtfFileList
->item(i
)->text());
482 QStringList fnames
= dir
.entryList(QDir::Files
| QDir::Readable
, QDir::Name
);
483 foreach(const QString
&fname
, fnames
)
485 if(!fname
.endsWith(".mhr", Qt::CaseInsensitive
))
487 QString fullname
= dir
.absoluteFilePath(fname
);
488 if(processed
.contains(fullname
))
490 processed
.push_back(fullname
);
492 QString name
= fname
.left(fname
.length()-4);
493 if(!ret
.contains(name
))
499 QString s
= name
+" #"+QString::number(i
);
511 if(ui
->defaultHrtfPathsCheckBox
->isChecked())
513 QStringList paths
= getAllDataPaths("/openal/hrtf");
514 foreach(const QString
&name
, paths
)
517 QStringList fnames
= dir
.entryList(QDir::Files
| QDir::Readable
, QDir::Name
);
518 foreach(const QString
&fname
, fnames
)
520 if(!fname
.endsWith(".mhr", Qt::CaseInsensitive
))
522 QString fullname
= dir
.absoluteFilePath(fname
);
523 if(processed
.contains(fullname
))
525 processed
.push_back(fullname
);
527 QString name
= fname
.left(fname
.length()-4);
528 if(!ret
.contains(name
))
534 QString s
= name
+" #"+QString::number(i
);
546 #ifdef ALSOFT_EMBED_HRTF_DATA
547 ret
.push_back("Built-In 44100hz");
548 ret
.push_back("Built-In 48000hz");
555 void MainWindow::loadConfigFromFile()
557 QString fname
= QFileDialog::getOpenFileName(this, tr("Select Files"));
558 if(fname
.isEmpty() == false)
562 void MainWindow::loadConfig(const QString
&fname
)
564 QSettings
settings(fname
, QSettings::IniFormat
);
566 QString sampletype
= settings
.value("sample-type").toString();
567 ui
->sampleFormatCombo
->setCurrentIndex(0);
568 if(sampletype
.isEmpty() == false)
570 QString str
= getNameFromValue(sampleTypeList
, sampletype
);
573 int j
= ui
->sampleFormatCombo
->findText(str
);
574 if(j
> 0) ui
->sampleFormatCombo
->setCurrentIndex(j
);
578 QString channelconfig
= settings
.value("channels").toString();
579 ui
->channelConfigCombo
->setCurrentIndex(0);
580 if(channelconfig
.isEmpty() == false)
582 QString str
= getNameFromValue(speakerModeList
, channelconfig
);
585 int j
= ui
->channelConfigCombo
->findText(str
);
586 if(j
> 0) ui
->channelConfigCombo
->setCurrentIndex(j
);
590 QString srate
= settings
.value("frequency").toString();
592 ui
->sampleRateCombo
->setCurrentIndex(0);
595 ui
->sampleRateCombo
->lineEdit()->clear();
596 ui
->sampleRateCombo
->lineEdit()->insert(srate
);
599 ui
->srcCountLineEdit
->clear();
600 ui
->srcCountLineEdit
->insert(settings
.value("sources").toString());
601 ui
->effectSlotLineEdit
->clear();
602 ui
->effectSlotLineEdit
->insert(settings
.value("slots").toString());
603 ui
->srcSendLineEdit
->clear();
604 ui
->srcSendLineEdit
->insert(settings
.value("sends").toString());
606 QString resampler
= settings
.value("resampler").toString().trimmed();
607 ui
->resamplerSlider
->setValue(2);
608 ui
->resamplerLabel
->setText(resamplerList
[2].name
);
609 /* The "cubic" and "sinc8" resamplers are no longer supported. Use "sinc4"
612 if(resampler
== "cubic" || resampler
== "sinc8")
614 /* The "bsinc" resampler name is an alias for "bsinc12". */
615 else if(resampler
== "bsinc")
616 resampler
= "bsinc12";
617 for(int i
= 0;resamplerList
[i
].name
[0];i
++)
619 if(resampler
== resamplerList
[i
].value
)
621 ui
->resamplerSlider
->setValue(i
);
622 ui
->resamplerLabel
->setText(resamplerList
[i
].name
);
627 QString stereomode
= settings
.value("stereo-mode").toString().trimmed();
628 ui
->stereoModeCombo
->setCurrentIndex(0);
629 if(stereomode
.isEmpty() == false)
631 QString str
= getNameFromValue(stereoModeList
, stereomode
);
634 int j
= ui
->stereoModeCombo
->findText(str
);
635 if(j
> 0) ui
->stereoModeCombo
->setCurrentIndex(j
);
639 int periodsize
= settings
.value("period_size").toInt();
640 ui
->periodSizeEdit
->clear();
643 ui
->periodSizeEdit
->insert(QString::number(periodsize
));
644 updatePeriodSizeSlider();
647 int periodcount
= settings
.value("periods").toInt();
648 ui
->periodCountEdit
->clear();
651 ui
->periodCountEdit
->insert(QString::number(periodcount
));
652 updatePeriodCountSlider();
655 if(settings
.value("output-limiter").isNull())
656 ui
->outputLimiterCheckBox
->setCheckState(Qt::PartiallyChecked
);
658 ui
->outputLimiterCheckBox
->setCheckState(
659 settings
.value("output-limiter").toBool() ? Qt::Checked
: Qt::Unchecked
662 if(settings
.value("dither").isNull())
663 ui
->outputDitherCheckBox
->setCheckState(Qt::PartiallyChecked
);
665 ui
->outputDitherCheckBox
->setCheckState(
666 settings
.value("dither").toBool() ? Qt::Checked
: Qt::Unchecked
669 QString stereopan
= settings
.value("stereo-encoding").toString();
670 ui
->stereoEncodingComboBox
->setCurrentIndex(0);
671 if(stereopan
.isEmpty() == false)
673 QString str
= getNameFromValue(stereoEncList
, stereopan
);
676 int j
= ui
->stereoEncodingComboBox
->findText(str
);
677 if(j
> 0) ui
->stereoEncodingComboBox
->setCurrentIndex(j
);
681 QString ambiformat
= settings
.value("ambi-format").toString();
682 ui
->ambiFormatComboBox
->setCurrentIndex(0);
683 if(ambiformat
.isEmpty() == false)
685 QString str
= getNameFromValue(ambiFormatList
, ambiformat
);
688 int j
= ui
->ambiFormatComboBox
->findText(str
);
689 if(j
> 0) ui
->ambiFormatComboBox
->setCurrentIndex(j
);
693 bool hqmode
= settings
.value("decoder/hq-mode", false).toBool();
694 ui
->decoderHQModeCheckBox
->setChecked(hqmode
);
695 bool distcomp
= settings
.value("decoder/distance-comp", true).toBool();
696 ui
->decoderDistCompCheckBox
->setChecked(distcomp
);
697 bool nfeffects
= settings
.value("decoder/nfc", true).toBool();
698 ui
->decoderNFEffectsCheckBox
->setChecked(nfeffects
);
699 double refdelay
= settings
.value("decoder/nfc-ref-delay", 0.0).toDouble();
700 ui
->decoderNFRefDelaySpinBox
->setValue(refdelay
);
702 ui
->decoderQuadLineEdit
->setText(settings
.value("decoder/quad").toString());
703 ui
->decoder51LineEdit
->setText(settings
.value("decoder/surround51").toString());
704 ui
->decoder61LineEdit
->setText(settings
.value("decoder/surround61").toString());
705 ui
->decoder71LineEdit
->setText(settings
.value("decoder/surround71").toString());
707 QStringList disabledCpuExts
= settings
.value("disable-cpu-exts").toStringList();
708 if(disabledCpuExts
.size() == 1)
709 disabledCpuExts
= disabledCpuExts
[0].split(QChar(','));
710 for(QStringList::iterator iter
= disabledCpuExts
.begin();iter
!= disabledCpuExts
.end();iter
++)
711 *iter
= iter
->trimmed();
712 ui
->enableSSECheckBox
->setChecked(!disabledCpuExts
.contains("sse", Qt::CaseInsensitive
));
713 ui
->enableSSE2CheckBox
->setChecked(!disabledCpuExts
.contains("sse2", Qt::CaseInsensitive
));
714 ui
->enableSSE3CheckBox
->setChecked(!disabledCpuExts
.contains("sse3", Qt::CaseInsensitive
));
715 ui
->enableSSE41CheckBox
->setChecked(!disabledCpuExts
.contains("sse4.1", Qt::CaseInsensitive
));
716 ui
->enableNeonCheckBox
->setChecked(!disabledCpuExts
.contains("neon", Qt::CaseInsensitive
));
718 QStringList hrtf_paths
= settings
.value("hrtf-paths").toStringList();
719 if(hrtf_paths
.size() == 1)
720 hrtf_paths
= hrtf_paths
[0].split(QChar(','));
721 for(QStringList::iterator iter
= hrtf_paths
.begin();iter
!= hrtf_paths
.end();iter
++)
722 *iter
= iter
->trimmed();
723 if(!hrtf_paths
.empty() && !hrtf_paths
.back().isEmpty())
724 ui
->defaultHrtfPathsCheckBox
->setCheckState(Qt::Unchecked
);
727 hrtf_paths
.removeAll(QString());
728 ui
->defaultHrtfPathsCheckBox
->setCheckState(Qt::Checked
);
730 hrtf_paths
.removeDuplicates();
731 ui
->hrtfFileList
->clear();
732 ui
->hrtfFileList
->addItems(hrtf_paths
);
733 updateHrtfRemoveButton();
735 QString hrtfstate
= settings
.value("hrtf").toString().toLower();
736 if(hrtfstate
== "true")
737 ui
->hrtfStateComboBox
->setCurrentIndex(1);
738 else if(hrtfstate
== "false")
739 ui
->hrtfStateComboBox
->setCurrentIndex(2);
741 ui
->hrtfStateComboBox
->setCurrentIndex(0);
743 ui
->preferredHrtfComboBox
->clear();
744 ui
->preferredHrtfComboBox
->addItem("- Any -");
745 if(ui
->defaultHrtfPathsCheckBox
->isChecked())
747 QStringList hrtfs
= collectHrtfs();
748 foreach(const QString
&name
, hrtfs
)
749 ui
->preferredHrtfComboBox
->addItem(name
);
752 QString defaulthrtf
= settings
.value("default-hrtf").toString();
753 ui
->preferredHrtfComboBox
->setCurrentIndex(0);
754 if(defaulthrtf
.isEmpty() == false)
756 int i
= ui
->preferredHrtfComboBox
->findText(defaulthrtf
);
758 ui
->preferredHrtfComboBox
->setCurrentIndex(i
);
761 i
= ui
->preferredHrtfComboBox
->count();
762 ui
->preferredHrtfComboBox
->addItem(defaulthrtf
);
763 ui
->preferredHrtfComboBox
->setCurrentIndex(i
);
766 ui
->preferredHrtfComboBox
->adjustSize();
768 ui
->enabledBackendList
->clear();
769 ui
->disabledBackendList
->clear();
770 QStringList drivers
= settings
.value("drivers").toStringList();
771 if(drivers
.size() == 0)
772 ui
->backendCheckBox
->setChecked(true);
775 if(drivers
.size() == 1)
776 drivers
= drivers
[0].split(QChar(','));
777 for(QStringList::iterator iter
= drivers
.begin();iter
!= drivers
.end();iter
++)
778 *iter
= iter
->trimmed();
780 bool lastWasEmpty
= false;
781 foreach(const QString
&backend
, drivers
)
783 lastWasEmpty
= backend
.isEmpty();
784 if(lastWasEmpty
) continue;
786 if(!backend
.startsWith(QChar('-')))
787 for(int j
= 0;backendList
[j
].backend_name
[0];j
++)
789 if(backend
== backendList
[j
].backend_name
)
791 ui
->enabledBackendList
->addItem(backendList
[j
].full_string
);
795 else if(backend
.size() > 1)
797 QStringRef backendref
= backend
.rightRef(backend
.size()-1);
798 for(int j
= 0;backendList
[j
].backend_name
[0];j
++)
800 if(backendref
== backendList
[j
].backend_name
)
802 ui
->disabledBackendList
->addItem(backendList
[j
].full_string
);
808 ui
->backendCheckBox
->setChecked(lastWasEmpty
);
811 QString defaultreverb
= settings
.value("default-reverb").toString().toLower();
812 ui
->defaultReverbComboBox
->setCurrentIndex(0);
813 if(defaultreverb
.isEmpty() == false)
815 for(int i
= 0;i
< ui
->defaultReverbComboBox
->count();i
++)
817 if(defaultreverb
.compare(ui
->defaultReverbComboBox
->itemText(i
).toLower()) == 0)
819 ui
->defaultReverbComboBox
->setCurrentIndex(i
);
825 ui
->emulateEaxCheckBox
->setChecked(settings
.value("reverb/emulate-eax", false).toBool());
827 QStringList excludefx
= settings
.value("excludefx").toStringList();
828 if(excludefx
.size() == 1)
829 excludefx
= excludefx
[0].split(QChar(','));
830 for(QStringList::iterator iter
= excludefx
.begin();iter
!= excludefx
.end();iter
++)
831 *iter
= iter
->trimmed();
832 ui
->enableEaxReverbCheck
->setChecked(!excludefx
.contains("eaxreverb", Qt::CaseInsensitive
));
833 ui
->enableStdReverbCheck
->setChecked(!excludefx
.contains("reverb", Qt::CaseInsensitive
));
834 ui
->enableChorusCheck
->setChecked(!excludefx
.contains("chorus", Qt::CaseInsensitive
));
835 ui
->enableCompressorCheck
->setChecked(!excludefx
.contains("compressor", Qt::CaseInsensitive
));
836 ui
->enableDistortionCheck
->setChecked(!excludefx
.contains("distortion", Qt::CaseInsensitive
));
837 ui
->enableEchoCheck
->setChecked(!excludefx
.contains("echo", Qt::CaseInsensitive
));
838 ui
->enableEqualizerCheck
->setChecked(!excludefx
.contains("equalizer", Qt::CaseInsensitive
));
839 ui
->enableFlangerCheck
->setChecked(!excludefx
.contains("flanger", Qt::CaseInsensitive
));
840 ui
->enableModulatorCheck
->setChecked(!excludefx
.contains("modulator", Qt::CaseInsensitive
));
841 ui
->enableDedicatedCheck
->setChecked(!excludefx
.contains("dedicated", Qt::CaseInsensitive
));
843 ui
->pulseAutospawnCheckBox
->setChecked(settings
.value("pulse/spawn-server", true).toBool());
844 ui
->pulseAllowMovesCheckBox
->setChecked(settings
.value("pulse/allow-moves", false).toBool());
845 ui
->pulseFixRateCheckBox
->setChecked(settings
.value("pulse/fix-rate", false).toBool());
847 ui
->jackAutospawnCheckBox
->setChecked(settings
.value("jack/spawn-server", false).toBool());
848 ui
->jackBufferSizeLine
->setText(settings
.value("jack/buffer-size", QString()).toString());
849 updateJackBufferSizeSlider();
851 ui
->alsaDefaultDeviceLine
->setText(settings
.value("alsa/device", QString()).toString());
852 ui
->alsaDefaultCaptureLine
->setText(settings
.value("alsa/capture", QString()).toString());
853 ui
->alsaResamplerCheckBox
->setChecked(settings
.value("alsa/allow-resampler", false).toBool());
854 ui
->alsaMmapCheckBox
->setChecked(settings
.value("alsa/mmap", true).toBool());
856 ui
->ossDefaultDeviceLine
->setText(settings
.value("oss/device", QString()).toString());
857 ui
->ossDefaultCaptureLine
->setText(settings
.value("oss/capture", QString()).toString());
859 ui
->solarisDefaultDeviceLine
->setText(settings
.value("solaris/device", QString()).toString());
861 ui
->waveOutputLine
->setText(settings
.value("wave/file", QString()).toString());
862 ui
->waveBFormatCheckBox
->setChecked(settings
.value("wave/bformat", false).toBool());
864 ui
->applyButton
->setEnabled(false);
865 ui
->closeCancelButton
->setText(tr("Close"));
869 void MainWindow::saveCurrentConfig()
871 saveConfig(getDefaultConfigName());
872 ui
->applyButton
->setEnabled(false);
873 ui
->closeCancelButton
->setText(tr("Close"));
875 QMessageBox::information(this, tr("Information"),
876 tr("Applications using OpenAL need to be restarted for changes to take effect."));
879 void MainWindow::saveConfigAsFile()
881 QString fname
= QFileDialog::getOpenFileName(this, tr("Select Files"));
882 if(fname
.isEmpty() == false)
885 ui
->applyButton
->setEnabled(false);
890 void MainWindow::saveConfig(const QString
&fname
) const
892 QSettings
settings(fname
, QSettings::IniFormat
);
894 /* HACK: Compound any stringlist values into a comma-separated string. */
895 QStringList allkeys
= settings
.allKeys();
896 foreach(const QString
&key
, allkeys
)
898 QStringList vals
= settings
.value(key
).toStringList();
900 settings
.setValue(key
, vals
.join(QChar(',')));
903 settings
.setValue("sample-type", getValueFromName(sampleTypeList
, ui
->sampleFormatCombo
->currentText()));
904 settings
.setValue("channels", getValueFromName(speakerModeList
, ui
->channelConfigCombo
->currentText()));
906 uint rate
= ui
->sampleRateCombo
->currentText().toUInt();
908 settings
.setValue("frequency", QString());
910 settings
.setValue("frequency", rate
);
912 settings
.setValue("period_size", ui
->periodSizeEdit
->text());
913 settings
.setValue("periods", ui
->periodCountEdit
->text());
915 settings
.setValue("sources", ui
->srcCountLineEdit
->text());
916 settings
.setValue("slots", ui
->effectSlotLineEdit
->text());
918 settings
.setValue("resampler", resamplerList
[ui
->resamplerSlider
->value()].value
);
920 settings
.setValue("stereo-mode", getValueFromName(stereoModeList
, ui
->stereoModeCombo
->currentText()));
921 settings
.setValue("stereo-encoding", getValueFromName(stereoEncList
, ui
->stereoEncodingComboBox
->currentText()));
922 settings
.setValue("ambi-format", getValueFromName(ambiFormatList
, ui
->ambiFormatComboBox
->currentText()));
924 Qt::CheckState limiter
= ui
->outputLimiterCheckBox
->checkState();
925 if(limiter
== Qt::PartiallyChecked
)
926 settings
.setValue("output-limiter", QString());
927 else if(limiter
== Qt::Checked
)
928 settings
.setValue("output-limiter", QString("true"));
929 else if(limiter
== Qt::Unchecked
)
930 settings
.setValue("output-limiter", QString("false"));
932 Qt::CheckState dither
= ui
->outputDitherCheckBox
->checkState();
933 if(dither
== Qt::PartiallyChecked
)
934 settings
.setValue("dither", QString());
935 else if(dither
== Qt::Checked
)
936 settings
.setValue("dither", QString("true"));
937 else if(dither
== Qt::Unchecked
)
938 settings
.setValue("dither", QString("false"));
940 settings
.setValue("decoder/hq-mode",
941 ui
->decoderHQModeCheckBox
->isChecked() ? QString("true") : QString(/*"false"*/)
943 settings
.setValue("decoder/distance-comp",
944 ui
->decoderDistCompCheckBox
->isChecked() ? QString(/*"true"*/) : QString("false")
946 settings
.setValue("decoder/nfc",
947 ui
->decoderNFEffectsCheckBox
->isChecked() ? QString(/*"true"*/) : QString("false")
949 double refdelay
= ui
->decoderNFRefDelaySpinBox
->value();
950 settings
.setValue("decoder/nfc-ref-delay",
951 (refdelay
> 0.0) ? QString::number(refdelay
) : QString()
954 settings
.setValue("decoder/quad", ui
->decoderQuadLineEdit
->text());
955 settings
.setValue("decoder/surround51", ui
->decoder51LineEdit
->text());
956 settings
.setValue("decoder/surround61", ui
->decoder61LineEdit
->text());
957 settings
.setValue("decoder/surround71", ui
->decoder71LineEdit
->text());
960 if(!ui
->enableSSECheckBox
->isChecked())
961 strlist
.append("sse");
962 if(!ui
->enableSSE2CheckBox
->isChecked())
963 strlist
.append("sse2");
964 if(!ui
->enableSSE3CheckBox
->isChecked())
965 strlist
.append("sse3");
966 if(!ui
->enableSSE41CheckBox
->isChecked())
967 strlist
.append("sse4.1");
968 if(!ui
->enableNeonCheckBox
->isChecked())
969 strlist
.append("neon");
970 settings
.setValue("disable-cpu-exts", strlist
.join(QChar(',')));
972 if(ui
->hrtfStateComboBox
->currentIndex() == 1)
973 settings
.setValue("hrtf", "true");
974 else if(ui
->hrtfStateComboBox
->currentIndex() == 2)
975 settings
.setValue("hrtf", "false");
977 settings
.setValue("hrtf", QString());
979 if(ui
->preferredHrtfComboBox
->currentIndex() == 0)
980 settings
.setValue("default-hrtf", QString());
983 QString str
= ui
->preferredHrtfComboBox
->currentText();
984 settings
.setValue("default-hrtf", str
);
988 for(int i
= 0;i
< ui
->hrtfFileList
->count();i
++)
989 strlist
.append(ui
->hrtfFileList
->item(i
)->text());
990 if(!strlist
.empty() && ui
->defaultHrtfPathsCheckBox
->isChecked())
991 strlist
.append(QString());
992 settings
.setValue("hrtf-paths", strlist
.join(QChar(',')));
995 for(int i
= 0;i
< ui
->enabledBackendList
->count();i
++)
997 QString label
= ui
->enabledBackendList
->item(i
)->text();
998 for(int j
= 0;backendList
[j
].backend_name
[0];j
++)
1000 if(label
== backendList
[j
].full_string
)
1002 strlist
.append(backendList
[j
].backend_name
);
1007 for(int i
= 0;i
< ui
->disabledBackendList
->count();i
++)
1009 QString label
= ui
->disabledBackendList
->item(i
)->text();
1010 for(int j
= 0;backendList
[j
].backend_name
[0];j
++)
1012 if(label
== backendList
[j
].full_string
)
1014 strlist
.append(QChar('-')+QString(backendList
[j
].backend_name
));
1019 if(strlist
.size() == 0 && !ui
->backendCheckBox
->isChecked())
1020 strlist
.append("-all");
1021 else if(ui
->backendCheckBox
->isChecked())
1022 strlist
.append(QString());
1023 settings
.setValue("drivers", strlist
.join(QChar(',')));
1025 // TODO: Remove check when we can properly match global values.
1026 if(ui
->defaultReverbComboBox
->currentIndex() == 0)
1027 settings
.setValue("default-reverb", QString());
1030 QString str
= ui
->defaultReverbComboBox
->currentText().toLower();
1031 settings
.setValue("default-reverb", str
);
1034 if(ui
->emulateEaxCheckBox
->isChecked())
1035 settings
.setValue("reverb/emulate-eax", "true");
1037 settings
.remove("reverb/emulate-eax"/*, "false"*/);
1040 if(!ui
->enableEaxReverbCheck
->isChecked())
1041 strlist
.append("eaxreverb");
1042 if(!ui
->enableStdReverbCheck
->isChecked())
1043 strlist
.append("reverb");
1044 if(!ui
->enableChorusCheck
->isChecked())
1045 strlist
.append("chorus");
1046 if(!ui
->enableDistortionCheck
->isChecked())
1047 strlist
.append("distortion");
1048 if(!ui
->enableCompressorCheck
->isChecked())
1049 strlist
.append("compressor");
1050 if(!ui
->enableEchoCheck
->isChecked())
1051 strlist
.append("echo");
1052 if(!ui
->enableEqualizerCheck
->isChecked())
1053 strlist
.append("equalizer");
1054 if(!ui
->enableFlangerCheck
->isChecked())
1055 strlist
.append("flanger");
1056 if(!ui
->enableModulatorCheck
->isChecked())
1057 strlist
.append("modulator");
1058 if(!ui
->enableDedicatedCheck
->isChecked())
1059 strlist
.append("dedicated");
1060 settings
.setValue("excludefx", strlist
.join(QChar(',')));
1062 settings
.setValue("pulse/spawn-server",
1063 ui
->pulseAutospawnCheckBox
->isChecked() ? QString(/*"true"*/) : QString("false")
1065 settings
.setValue("pulse/allow-moves",
1066 ui
->pulseAllowMovesCheckBox
->isChecked() ? QString("true") : QString(/*"false"*/)
1068 settings
.setValue("pulse/fix-rate",
1069 ui
->pulseFixRateCheckBox
->isChecked() ? QString("true") : QString(/*"false"*/)
1072 settings
.setValue("jack/spawn-server",
1073 ui
->jackAutospawnCheckBox
->isChecked() ? QString("true") : QString(/*"false"*/)
1075 settings
.setValue("jack/buffer-size", ui
->jackBufferSizeLine
->text());
1077 settings
.setValue("alsa/device", ui
->alsaDefaultDeviceLine
->text());
1078 settings
.setValue("alsa/capture", ui
->alsaDefaultCaptureLine
->text());
1079 settings
.setValue("alsa/allow-resampler",
1080 ui
->alsaResamplerCheckBox
->isChecked() ? QString("true") : QString(/*"false"*/)
1082 settings
.setValue("alsa/mmap",
1083 ui
->alsaMmapCheckBox
->isChecked() ? QString(/*"true"*/) : QString("false")
1086 settings
.setValue("oss/device", ui
->ossDefaultDeviceLine
->text());
1087 settings
.setValue("oss/capture", ui
->ossDefaultCaptureLine
->text());
1089 settings
.setValue("solaris/device", ui
->solarisDefaultDeviceLine
->text());
1091 settings
.setValue("wave/file", ui
->waveOutputLine
->text());
1092 settings
.setValue("wave/bformat",
1093 ui
->waveBFormatCheckBox
->isChecked() ? QString("true") : QString(/*"false"*/)
1096 /* Remove empty keys
1097 * FIXME: Should only remove keys whose value matches the globally-specified value.
1099 allkeys
= settings
.allKeys();
1100 foreach(const QString
&key
, allkeys
)
1102 QString str
= settings
.value(key
).toString();
1103 if(str
== QString())
1104 settings
.remove(key
);
1109 void MainWindow::enableApplyButton()
1112 ui
->applyButton
->setEnabled(true);
1114 ui
->closeCancelButton
->setText(tr("Cancel"));
1118 void MainWindow::updateResamplerLabel(int num
)
1120 ui
->resamplerLabel
->setText(resamplerList
[num
].name
);
1121 enableApplyButton();
1125 void MainWindow::updatePeriodSizeEdit(int size
)
1127 ui
->periodSizeEdit
->clear();
1130 size
= (size
+32)&~0x3f;
1131 ui
->periodSizeEdit
->insert(QString::number(size
));
1133 enableApplyButton();
1136 void MainWindow::updatePeriodSizeSlider()
1138 int pos
= ui
->periodSizeEdit
->text().toInt();
1143 ui
->periodSizeSlider
->setSliderPosition(pos
);
1145 enableApplyButton();
1148 void MainWindow::updatePeriodCountEdit(int count
)
1150 ui
->periodCountEdit
->clear();
1152 ui
->periodCountEdit
->insert(QString::number(count
));
1153 enableApplyButton();
1156 void MainWindow::updatePeriodCountSlider()
1158 int pos
= ui
->periodCountEdit
->text().toInt();
1163 ui
->periodCountSlider
->setSliderPosition(pos
);
1164 enableApplyButton();
1168 void MainWindow::selectQuadDecoderFile()
1169 { selectDecoderFile(ui
->decoderQuadLineEdit
, "Select Quadrophonic Decoder");}
1170 void MainWindow::select51DecoderFile()
1171 { selectDecoderFile(ui
->decoder51LineEdit
, "Select 5.1 Surround Decoder");}
1172 void MainWindow::select61DecoderFile()
1173 { selectDecoderFile(ui
->decoder61LineEdit
, "Select 6.1 Surround Decoder");}
1174 void MainWindow::select71DecoderFile()
1175 { selectDecoderFile(ui
->decoder71LineEdit
, "Select 7.1 Surround Decoder");}
1176 void MainWindow::selectDecoderFile(QLineEdit
*line
, const char *caption
)
1178 QString dir
= line
->text();
1179 if(dir
.isEmpty() || QDir::isRelativePath(dir
))
1181 QStringList paths
= getAllDataPaths("/openal/presets");
1182 while(!paths
.isEmpty())
1184 if(QDir(paths
.last()).exists())
1192 QString fname
= QFileDialog::getOpenFileName(this, tr(caption
),
1193 dir
, tr("AmbDec Files (*.ambdec);;All Files (*.*)")
1195 if(!fname
.isEmpty())
1197 line
->setText(fname
);
1198 enableApplyButton();
1203 void MainWindow::updateJackBufferSizeEdit(int size
)
1205 ui
->jackBufferSizeLine
->clear();
1207 ui
->jackBufferSizeLine
->insert(QString::number(1<<size
));
1208 enableApplyButton();
1211 void MainWindow::updateJackBufferSizeSlider()
1213 int value
= ui
->jackBufferSizeLine
->text().toInt();
1214 int pos
= (int)floor(log2(value
) + 0.5);
1215 ui
->jackBufferSizeSlider
->setSliderPosition(pos
);
1216 enableApplyButton();
1220 void MainWindow::addHrtfFile()
1222 QString path
= QFileDialog::getExistingDirectory(this, tr("Select HRTF Path"));
1223 if(path
.isEmpty() == false && !getAllDataPaths("/openal/hrtf").contains(path
))
1225 ui
->hrtfFileList
->addItem(path
);
1226 enableApplyButton();
1230 void MainWindow::removeHrtfFile()
1232 QList
<QListWidgetItem
*> selected
= ui
->hrtfFileList
->selectedItems();
1233 if(!selected
.isEmpty())
1235 foreach(QListWidgetItem
*item
, selected
)
1237 enableApplyButton();
1241 void MainWindow::updateHrtfRemoveButton()
1243 ui
->hrtfRemoveButton
->setEnabled(ui
->hrtfFileList
->selectedItems().size() != 0);
1246 void MainWindow::showEnabledBackendMenu(QPoint pt
)
1248 QMap
<QAction
*,QString
> actionMap
;
1250 pt
= ui
->enabledBackendList
->mapToGlobal(pt
);
1253 QAction
*removeAction
= ctxmenu
.addAction(QIcon::fromTheme("list-remove"), "Remove");
1254 if(ui
->enabledBackendList
->selectedItems().size() == 0)
1255 removeAction
->setEnabled(false);
1256 ctxmenu
.addSeparator();
1257 for(size_t i
= 0;backendList
[i
].backend_name
[0];i
++)
1259 QString backend
= backendList
[i
].full_string
;
1260 QAction
*action
= ctxmenu
.addAction(QString("Add ")+backend
);
1261 actionMap
[action
] = backend
;
1262 if(ui
->enabledBackendList
->findItems(backend
, Qt::MatchFixedString
).size() != 0 ||
1263 ui
->disabledBackendList
->findItems(backend
, Qt::MatchFixedString
).size() != 0)
1264 action
->setEnabled(false);
1267 QAction
*gotAction
= ctxmenu
.exec(pt
);
1268 if(gotAction
== removeAction
)
1270 QList
<QListWidgetItem
*> selected
= ui
->enabledBackendList
->selectedItems();
1271 foreach(QListWidgetItem
*item
, selected
)
1273 enableApplyButton();
1275 else if(gotAction
!= NULL
)
1277 QMap
<QAction
*,QString
>::const_iterator iter
= actionMap
.find(gotAction
);
1278 if(iter
!= actionMap
.end())
1279 ui
->enabledBackendList
->addItem(iter
.value());
1280 enableApplyButton();
1284 void MainWindow::showDisabledBackendMenu(QPoint pt
)
1286 QMap
<QAction
*,QString
> actionMap
;
1288 pt
= ui
->disabledBackendList
->mapToGlobal(pt
);
1291 QAction
*removeAction
= ctxmenu
.addAction(QIcon::fromTheme("list-remove"), "Remove");
1292 if(ui
->disabledBackendList
->selectedItems().size() == 0)
1293 removeAction
->setEnabled(false);
1294 ctxmenu
.addSeparator();
1295 for(size_t i
= 0;backendList
[i
].backend_name
[0];i
++)
1297 QString backend
= backendList
[i
].full_string
;
1298 QAction
*action
= ctxmenu
.addAction(QString("Add ")+backend
);
1299 actionMap
[action
] = backend
;
1300 if(ui
->disabledBackendList
->findItems(backend
, Qt::MatchFixedString
).size() != 0 ||
1301 ui
->enabledBackendList
->findItems(backend
, Qt::MatchFixedString
).size() != 0)
1302 action
->setEnabled(false);
1305 QAction
*gotAction
= ctxmenu
.exec(pt
);
1306 if(gotAction
== removeAction
)
1308 QList
<QListWidgetItem
*> selected
= ui
->disabledBackendList
->selectedItems();
1309 foreach(QListWidgetItem
*item
, selected
)
1311 enableApplyButton();
1313 else if(gotAction
!= NULL
)
1315 QMap
<QAction
*,QString
>::const_iterator iter
= actionMap
.find(gotAction
);
1316 if(iter
!= actionMap
.end())
1317 ui
->disabledBackendList
->addItem(iter
.value());
1318 enableApplyButton();
1322 void MainWindow::selectOSSPlayback()
1324 QString current
= ui
->ossDefaultDeviceLine
->text();
1325 if(current
.isEmpty()) current
= ui
->ossDefaultDeviceLine
->placeholderText();
1326 QString fname
= QFileDialog::getOpenFileName(this, tr("Select Playback Device"), current
);
1327 if(!fname
.isEmpty())
1329 ui
->ossDefaultDeviceLine
->setText(fname
);
1330 enableApplyButton();
1334 void MainWindow::selectOSSCapture()
1336 QString current
= ui
->ossDefaultCaptureLine
->text();
1337 if(current
.isEmpty()) current
= ui
->ossDefaultCaptureLine
->placeholderText();
1338 QString fname
= QFileDialog::getOpenFileName(this, tr("Select Capture Device"), current
);
1339 if(!fname
.isEmpty())
1341 ui
->ossDefaultCaptureLine
->setText(fname
);
1342 enableApplyButton();
1346 void MainWindow::selectSolarisPlayback()
1348 QString current
= ui
->solarisDefaultDeviceLine
->text();
1349 if(current
.isEmpty()) current
= ui
->solarisDefaultDeviceLine
->placeholderText();
1350 QString fname
= QFileDialog::getOpenFileName(this, tr("Select Playback Device"), current
);
1351 if(!fname
.isEmpty())
1353 ui
->solarisDefaultDeviceLine
->setText(fname
);
1354 enableApplyButton();
1358 void MainWindow::selectWaveOutput()
1360 QString fname
= QFileDialog::getSaveFileName(this, tr("Select Wave File Output"),
1361 ui
->waveOutputLine
->text(), tr("Wave Files (*.wav *.amb);;All Files (*.*)")
1363 if(!fname
.isEmpty())
1365 ui
->waveOutputLine
->setText(fname
);
1366 enableApplyButton();