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()));
332 connect(ui
->decoderHQModeCheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
333 connect(ui
->decoderDistCompCheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
334 connect(ui
->decoderNFEffectsCheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
335 connect(ui
->decoderNFRefDelaySpinBox
, SIGNAL(valueChanged(double)), this, SLOT(enableApplyButton()));
336 connect(ui
->decoderQuadLineEdit
, SIGNAL(textChanged(QString
)), this, SLOT(enableApplyButton()));
337 connect(ui
->decoderQuadButton
, SIGNAL(clicked()), this, SLOT(selectQuadDecoderFile()));
338 connect(ui
->decoder51LineEdit
, SIGNAL(textChanged(QString
)), this, SLOT(enableApplyButton()));
339 connect(ui
->decoder51Button
, SIGNAL(clicked()), this, SLOT(select51DecoderFile()));
340 connect(ui
->decoder61LineEdit
, SIGNAL(textChanged(QString
)), this, SLOT(enableApplyButton()));
341 connect(ui
->decoder61Button
, SIGNAL(clicked()), this, SLOT(select61DecoderFile()));
342 connect(ui
->decoder71LineEdit
, SIGNAL(textChanged(QString
)), this, SLOT(enableApplyButton()));
343 connect(ui
->decoder71Button
, SIGNAL(clicked()), this, SLOT(select71DecoderFile()));
345 connect(ui
->preferredHrtfComboBox
, SIGNAL(currentIndexChanged(const QString
&)), this, SLOT(enableApplyButton()));
346 connect(ui
->hrtfStateComboBox
, SIGNAL(currentIndexChanged(const QString
&)), this, SLOT(enableApplyButton()));
347 connect(ui
->hrtfAddButton
, SIGNAL(clicked()), this, SLOT(addHrtfFile()));
348 connect(ui
->hrtfRemoveButton
, SIGNAL(clicked()), this, SLOT(removeHrtfFile()));
349 connect(ui
->hrtfFileList
, SIGNAL(itemSelectionChanged()), this, SLOT(updateHrtfRemoveButton()));
350 connect(ui
->defaultHrtfPathsCheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
352 connect(ui
->srcCountLineEdit
, SIGNAL(editingFinished()), this, SLOT(enableApplyButton()));
353 connect(ui
->srcSendLineEdit
, SIGNAL(editingFinished()), this, SLOT(enableApplyButton()));
354 connect(ui
->effectSlotLineEdit
, SIGNAL(editingFinished()), this, SLOT(enableApplyButton()));
356 connect(ui
->enableSSECheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
357 connect(ui
->enableSSE2CheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
358 connect(ui
->enableSSE3CheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
359 connect(ui
->enableSSE41CheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
360 connect(ui
->enableNeonCheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
362 ui
->enabledBackendList
->setContextMenuPolicy(Qt::CustomContextMenu
);
363 connect(ui
->enabledBackendList
, SIGNAL(customContextMenuRequested(QPoint
)), this, SLOT(showEnabledBackendMenu(QPoint
)));
365 ui
->disabledBackendList
->setContextMenuPolicy(Qt::CustomContextMenu
);
366 connect(ui
->disabledBackendList
, SIGNAL(customContextMenuRequested(QPoint
)), this, SLOT(showDisabledBackendMenu(QPoint
)));
367 connect(ui
->backendCheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
369 connect(ui
->defaultReverbComboBox
, SIGNAL(currentIndexChanged(const QString
&)), this, SLOT(enableApplyButton()));
370 connect(ui
->emulateEaxCheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
371 connect(ui
->enableEaxReverbCheck
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
372 connect(ui
->enableStdReverbCheck
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
373 connect(ui
->enableChorusCheck
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
374 connect(ui
->enableCompressorCheck
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
375 connect(ui
->enableDistortionCheck
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
376 connect(ui
->enableEchoCheck
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
377 connect(ui
->enableEqualizerCheck
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
378 connect(ui
->enableFlangerCheck
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
379 connect(ui
->enableModulatorCheck
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
380 connect(ui
->enableDedicatedCheck
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
382 connect(ui
->pulseAutospawnCheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
383 connect(ui
->pulseAllowMovesCheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
384 connect(ui
->pulseFixRateCheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
386 connect(ui
->jackAutospawnCheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
387 connect(ui
->jackBufferSizeSlider
, SIGNAL(valueChanged(int)), this, SLOT(updateJackBufferSizeEdit(int)));
388 connect(ui
->jackBufferSizeLine
, SIGNAL(editingFinished()), this, SLOT(updateJackBufferSizeSlider()));
390 connect(ui
->alsaDefaultDeviceLine
, SIGNAL(textChanged(QString
)), this, SLOT(enableApplyButton()));
391 connect(ui
->alsaDefaultCaptureLine
, SIGNAL(textChanged(QString
)), this, SLOT(enableApplyButton()));
392 connect(ui
->alsaResamplerCheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
393 connect(ui
->alsaMmapCheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
395 connect(ui
->ossDefaultDeviceLine
, SIGNAL(textChanged(QString
)), this, SLOT(enableApplyButton()));
396 connect(ui
->ossPlaybackPushButton
, SIGNAL(clicked(bool)), this, SLOT(selectOSSPlayback()));
397 connect(ui
->ossDefaultCaptureLine
, SIGNAL(textChanged(QString
)), this, SLOT(enableApplyButton()));
398 connect(ui
->ossCapturePushButton
, SIGNAL(clicked(bool)), this, SLOT(selectOSSCapture()));
400 connect(ui
->solarisDefaultDeviceLine
, SIGNAL(textChanged(QString
)), this, SLOT(enableApplyButton()));
401 connect(ui
->solarisPlaybackPushButton
, SIGNAL(clicked(bool)), this, SLOT(selectSolarisPlayback()));
403 connect(ui
->waveOutputLine
, SIGNAL(textChanged(QString
)), this, SLOT(enableApplyButton()));
404 connect(ui
->waveOutputButton
, SIGNAL(clicked(bool)), this, SLOT(selectWaveOutput()));
405 connect(ui
->waveBFormatCheckBox
, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
407 ui
->backendListWidget
->setCurrentRow(0);
408 ui
->tabWidget
->setCurrentIndex(0);
410 for(int i
= 1;i
< ui
->backendListWidget
->count();i
++)
411 ui
->backendListWidget
->setRowHidden(i
, true);
412 for(int i
= 0;backendList
[i
].backend_name
[0];i
++)
414 QList
<QListWidgetItem
*> items
= ui
->backendListWidget
->findItems(
415 backendList
[i
].full_string
, Qt::MatchFixedString
417 foreach(const QListWidgetItem
*item
, items
)
418 ui
->backendListWidget
->setItemHidden(item
, false);
421 loadConfig(getDefaultConfigName());
424 MainWindow::~MainWindow()
427 delete mPeriodSizeValidator
;
428 delete mPeriodCountValidator
;
429 delete mSourceCountValidator
;
430 delete mEffectSlotValidator
;
431 delete mSourceSendValidator
;
432 delete mSampleRateValidator
;
433 delete mJackBufferValidator
;
436 void MainWindow::closeEvent(QCloseEvent
*event
)
442 QMessageBox::StandardButton btn
= QMessageBox::warning(this,
443 tr("Apply changes?"), tr("Save changes before quitting?"),
444 QMessageBox::Save
| QMessageBox::No
| QMessageBox::Cancel
446 if(btn
== QMessageBox::Save
)
448 if(btn
== QMessageBox::Cancel
)
455 void MainWindow::cancelCloseAction()
462 void MainWindow::showAboutPage()
464 QMessageBox::information(this, tr("About"),
465 tr("OpenAL Soft Configuration Utility.\nBuilt for OpenAL Soft library version ")+
466 (ALSOFT_VERSION
"-" ALSOFT_GIT_COMMIT_HASH
" (" ALSOFT_GIT_BRANCH
" branch).")
471 QStringList
MainWindow::collectHrtfs()
474 QStringList processed
;
476 for(int i
= 0;i
< ui
->hrtfFileList
->count();i
++)
478 QDir
dir(ui
->hrtfFileList
->item(i
)->text());
479 QStringList fnames
= dir
.entryList(QDir::Files
| QDir::Readable
, QDir::Name
);
480 foreach(const QString
&fname
, fnames
)
482 if(!fname
.endsWith(".mhr", Qt::CaseInsensitive
))
484 QString fullname
= dir
.absoluteFilePath(fname
);
485 if(processed
.contains(fullname
))
487 processed
.push_back(fullname
);
489 QString name
= fname
.left(fname
.length()-4);
490 if(!ret
.contains(name
))
496 QString s
= name
+" #"+QString::number(i
);
508 if(ui
->defaultHrtfPathsCheckBox
->isChecked())
510 QStringList paths
= getAllDataPaths("/openal/hrtf");
511 foreach(const QString
&name
, paths
)
514 QStringList fnames
= dir
.entryList(QDir::Files
| QDir::Readable
, QDir::Name
);
515 foreach(const QString
&fname
, fnames
)
517 if(!fname
.endsWith(".mhr", Qt::CaseInsensitive
))
519 QString fullname
= dir
.absoluteFilePath(fname
);
520 if(processed
.contains(fullname
))
522 processed
.push_back(fullname
);
524 QString name
= fname
.left(fname
.length()-4);
525 if(!ret
.contains(name
))
531 QString s
= name
+" #"+QString::number(i
);
547 void MainWindow::loadConfigFromFile()
549 QString fname
= QFileDialog::getOpenFileName(this, tr("Select Files"));
550 if(fname
.isEmpty() == false)
554 void MainWindow::loadConfig(const QString
&fname
)
556 QSettings
settings(fname
, QSettings::IniFormat
);
558 QString sampletype
= settings
.value("sample-type").toString();
559 ui
->sampleFormatCombo
->setCurrentIndex(0);
560 if(sampletype
.isEmpty() == false)
562 QString str
= getNameFromValue(sampleTypeList
, sampletype
);
565 int j
= ui
->sampleFormatCombo
->findText(str
);
566 if(j
> 0) ui
->sampleFormatCombo
->setCurrentIndex(j
);
570 QString channelconfig
= settings
.value("channels").toString();
571 ui
->channelConfigCombo
->setCurrentIndex(0);
572 if(channelconfig
.isEmpty() == false)
574 QString str
= getNameFromValue(speakerModeList
, channelconfig
);
577 int j
= ui
->channelConfigCombo
->findText(str
);
578 if(j
> 0) ui
->channelConfigCombo
->setCurrentIndex(j
);
582 QString srate
= settings
.value("frequency").toString();
584 ui
->sampleRateCombo
->setCurrentIndex(0);
587 ui
->sampleRateCombo
->lineEdit()->clear();
588 ui
->sampleRateCombo
->lineEdit()->insert(srate
);
591 ui
->srcCountLineEdit
->clear();
592 ui
->srcCountLineEdit
->insert(settings
.value("sources").toString());
593 ui
->effectSlotLineEdit
->clear();
594 ui
->effectSlotLineEdit
->insert(settings
.value("slots").toString());
595 ui
->srcSendLineEdit
->clear();
596 ui
->srcSendLineEdit
->insert(settings
.value("sends").toString());
598 QString resampler
= settings
.value("resampler").toString().trimmed();
599 ui
->resamplerSlider
->setValue(0);
600 /* The "cubic" and "sinc8" resamplers are no longer supported. Use "sinc4"
603 if(resampler
== "cubic" || resampler
== "sinc8")
605 for(int i
= 0;resamplerList
[i
].name
[0];i
++)
607 if(resampler
== resamplerList
[i
].value
)
609 ui
->resamplerSlider
->setValue(i
);
614 QString stereomode
= settings
.value("stereo-mode").toString().trimmed();
615 ui
->stereoModeCombo
->setCurrentIndex(0);
616 if(stereomode
.isEmpty() == false)
618 QString str
= getNameFromValue(stereoModeList
, stereomode
);
621 int j
= ui
->stereoModeCombo
->findText(str
);
622 if(j
> 0) ui
->stereoModeCombo
->setCurrentIndex(j
);
626 int periodsize
= settings
.value("period_size").toInt();
627 ui
->periodSizeEdit
->clear();
630 ui
->periodSizeEdit
->insert(QString::number(periodsize
));
631 updatePeriodSizeSlider();
634 int periodcount
= settings
.value("periods").toInt();
635 ui
->periodCountEdit
->clear();
638 ui
->periodCountEdit
->insert(QString::number(periodcount
));
639 updatePeriodCountSlider();
642 QString stereopan
= settings
.value("stereo-encoding").toString();
643 ui
->stereoEncodingComboBox
->setCurrentIndex(0);
644 if(stereopan
.isEmpty() == false)
646 QString str
= getNameFromValue(stereoEncList
, stereopan
);
649 int j
= ui
->stereoEncodingComboBox
->findText(str
);
650 if(j
> 0) ui
->stereoEncodingComboBox
->setCurrentIndex(j
);
654 QString ambiformat
= settings
.value("ambi-format").toString();
655 ui
->ambiFormatComboBox
->setCurrentIndex(0);
656 if(ambiformat
.isEmpty() == false)
658 QString str
= getNameFromValue(ambiFormatList
, ambiformat
);
661 int j
= ui
->ambiFormatComboBox
->findText(str
);
662 if(j
> 0) ui
->ambiFormatComboBox
->setCurrentIndex(j
);
666 bool hqmode
= settings
.value("decoder/hq-mode", false).toBool();
667 ui
->decoderHQModeCheckBox
->setChecked(hqmode
);
668 bool distcomp
= settings
.value("decoder/distance-comp", true).toBool();
669 ui
->decoderDistCompCheckBox
->setChecked(distcomp
);
670 bool nfeffects
= settings
.value("decoder/nfc", true).toBool();
671 ui
->decoderNFEffectsCheckBox
->setChecked(nfeffects
);
672 double refdelay
= settings
.value("decoder/nfc-ref-delay", 0.0).toDouble();
673 ui
->decoderNFRefDelaySpinBox
->setValue(refdelay
);
675 ui
->decoderQuadLineEdit
->setText(settings
.value("decoder/quad").toString());
676 ui
->decoder51LineEdit
->setText(settings
.value("decoder/surround51").toString());
677 ui
->decoder61LineEdit
->setText(settings
.value("decoder/surround61").toString());
678 ui
->decoder71LineEdit
->setText(settings
.value("decoder/surround71").toString());
680 QStringList disabledCpuExts
= settings
.value("disable-cpu-exts").toStringList();
681 if(disabledCpuExts
.size() == 1)
682 disabledCpuExts
= disabledCpuExts
[0].split(QChar(','));
683 for(QStringList::iterator iter
= disabledCpuExts
.begin();iter
!= disabledCpuExts
.end();iter
++)
684 *iter
= iter
->trimmed();
685 ui
->enableSSECheckBox
->setChecked(!disabledCpuExts
.contains("sse", Qt::CaseInsensitive
));
686 ui
->enableSSE2CheckBox
->setChecked(!disabledCpuExts
.contains("sse2", Qt::CaseInsensitive
));
687 ui
->enableSSE3CheckBox
->setChecked(!disabledCpuExts
.contains("sse3", Qt::CaseInsensitive
));
688 ui
->enableSSE41CheckBox
->setChecked(!disabledCpuExts
.contains("sse4.1", Qt::CaseInsensitive
));
689 ui
->enableNeonCheckBox
->setChecked(!disabledCpuExts
.contains("neon", Qt::CaseInsensitive
));
691 QStringList hrtf_paths
= settings
.value("hrtf-paths").toStringList();
692 if(hrtf_paths
.size() == 1)
693 hrtf_paths
= hrtf_paths
[0].split(QChar(','));
694 for(QStringList::iterator iter
= hrtf_paths
.begin();iter
!= hrtf_paths
.end();iter
++)
695 *iter
= iter
->trimmed();
696 if(!hrtf_paths
.empty() && !hrtf_paths
.back().isEmpty())
697 ui
->defaultHrtfPathsCheckBox
->setCheckState(Qt::Unchecked
);
700 hrtf_paths
.removeAll(QString());
701 ui
->defaultHrtfPathsCheckBox
->setCheckState(Qt::Checked
);
703 hrtf_paths
.removeDuplicates();
704 ui
->hrtfFileList
->clear();
705 ui
->hrtfFileList
->addItems(hrtf_paths
);
706 updateHrtfRemoveButton();
708 QString hrtfstate
= settings
.value("hrtf").toString().toLower();
709 if(hrtfstate
== "true")
710 ui
->hrtfStateComboBox
->setCurrentIndex(1);
711 else if(hrtfstate
== "false")
712 ui
->hrtfStateComboBox
->setCurrentIndex(2);
714 ui
->hrtfStateComboBox
->setCurrentIndex(0);
716 ui
->preferredHrtfComboBox
->clear();
717 ui
->preferredHrtfComboBox
->addItem("- Any -");
718 if(ui
->defaultHrtfPathsCheckBox
->isChecked())
720 QStringList hrtfs
= collectHrtfs();
721 foreach(const QString
&name
, hrtfs
)
722 ui
->preferredHrtfComboBox
->addItem(name
);
725 QString defaulthrtf
= settings
.value("default-hrtf").toString();
726 ui
->preferredHrtfComboBox
->setCurrentIndex(0);
727 if(defaulthrtf
.isEmpty() == false)
729 int i
= ui
->preferredHrtfComboBox
->findText(defaulthrtf
);
731 ui
->preferredHrtfComboBox
->setCurrentIndex(i
);
734 i
= ui
->preferredHrtfComboBox
->count();
735 ui
->preferredHrtfComboBox
->addItem(defaulthrtf
);
736 ui
->preferredHrtfComboBox
->setCurrentIndex(i
);
739 ui
->preferredHrtfComboBox
->adjustSize();
741 ui
->enabledBackendList
->clear();
742 ui
->disabledBackendList
->clear();
743 QStringList drivers
= settings
.value("drivers").toStringList();
744 if(drivers
.size() == 0)
745 ui
->backendCheckBox
->setChecked(true);
748 if(drivers
.size() == 1)
749 drivers
= drivers
[0].split(QChar(','));
750 for(QStringList::iterator iter
= drivers
.begin();iter
!= drivers
.end();iter
++)
751 *iter
= iter
->trimmed();
753 bool lastWasEmpty
= false;
754 foreach(const QString
&backend
, drivers
)
756 lastWasEmpty
= backend
.isEmpty();
757 if(lastWasEmpty
) continue;
759 if(!backend
.startsWith(QChar('-')))
760 for(int j
= 0;backendList
[j
].backend_name
[0];j
++)
762 if(backend
== backendList
[j
].backend_name
)
764 ui
->enabledBackendList
->addItem(backendList
[j
].full_string
);
768 else if(backend
.size() > 1)
770 QStringRef backendref
= backend
.rightRef(backend
.size()-1);
771 for(int j
= 0;backendList
[j
].backend_name
[0];j
++)
773 if(backendref
== backendList
[j
].backend_name
)
775 ui
->disabledBackendList
->addItem(backendList
[j
].full_string
);
781 ui
->backendCheckBox
->setChecked(lastWasEmpty
);
784 QString defaultreverb
= settings
.value("default-reverb").toString().toLower();
785 ui
->defaultReverbComboBox
->setCurrentIndex(0);
786 if(defaultreverb
.isEmpty() == false)
788 for(int i
= 0;i
< ui
->defaultReverbComboBox
->count();i
++)
790 if(defaultreverb
.compare(ui
->defaultReverbComboBox
->itemText(i
).toLower()) == 0)
792 ui
->defaultReverbComboBox
->setCurrentIndex(i
);
798 ui
->emulateEaxCheckBox
->setChecked(settings
.value("reverb/emulate-eax", false).toBool());
800 QStringList excludefx
= settings
.value("excludefx").toStringList();
801 if(excludefx
.size() == 1)
802 excludefx
= excludefx
[0].split(QChar(','));
803 for(QStringList::iterator iter
= excludefx
.begin();iter
!= excludefx
.end();iter
++)
804 *iter
= iter
->trimmed();
805 ui
->enableEaxReverbCheck
->setChecked(!excludefx
.contains("eaxreverb", Qt::CaseInsensitive
));
806 ui
->enableStdReverbCheck
->setChecked(!excludefx
.contains("reverb", Qt::CaseInsensitive
));
807 ui
->enableChorusCheck
->setChecked(!excludefx
.contains("chorus", Qt::CaseInsensitive
));
808 ui
->enableCompressorCheck
->setChecked(!excludefx
.contains("compressor", Qt::CaseInsensitive
));
809 ui
->enableDistortionCheck
->setChecked(!excludefx
.contains("distortion", Qt::CaseInsensitive
));
810 ui
->enableEchoCheck
->setChecked(!excludefx
.contains("echo", Qt::CaseInsensitive
));
811 ui
->enableEqualizerCheck
->setChecked(!excludefx
.contains("equalizer", Qt::CaseInsensitive
));
812 ui
->enableFlangerCheck
->setChecked(!excludefx
.contains("flanger", Qt::CaseInsensitive
));
813 ui
->enableModulatorCheck
->setChecked(!excludefx
.contains("modulator", Qt::CaseInsensitive
));
814 ui
->enableDedicatedCheck
->setChecked(!excludefx
.contains("dedicated", Qt::CaseInsensitive
));
816 ui
->pulseAutospawnCheckBox
->setChecked(settings
.value("pulse/spawn-server", true).toBool());
817 ui
->pulseAllowMovesCheckBox
->setChecked(settings
.value("pulse/allow-moves", false).toBool());
818 ui
->pulseFixRateCheckBox
->setChecked(settings
.value("pulse/fix-rate", false).toBool());
820 ui
->jackAutospawnCheckBox
->setChecked(settings
.value("jack/spawn-server", false).toBool());
821 ui
->jackBufferSizeLine
->setText(settings
.value("jack/buffer-size", QString()).toString());
822 updateJackBufferSizeSlider();
824 ui
->alsaDefaultDeviceLine
->setText(settings
.value("alsa/device", QString()).toString());
825 ui
->alsaDefaultCaptureLine
->setText(settings
.value("alsa/capture", QString()).toString());
826 ui
->alsaResamplerCheckBox
->setChecked(settings
.value("alsa/allow-resampler", false).toBool());
827 ui
->alsaMmapCheckBox
->setChecked(settings
.value("alsa/mmap", true).toBool());
829 ui
->ossDefaultDeviceLine
->setText(settings
.value("oss/device", QString()).toString());
830 ui
->ossDefaultCaptureLine
->setText(settings
.value("oss/capture", QString()).toString());
832 ui
->solarisDefaultDeviceLine
->setText(settings
.value("solaris/device", QString()).toString());
834 ui
->waveOutputLine
->setText(settings
.value("wave/file", QString()).toString());
835 ui
->waveBFormatCheckBox
->setChecked(settings
.value("wave/bformat", false).toBool());
837 ui
->applyButton
->setEnabled(false);
838 ui
->closeCancelButton
->setText(tr("Close"));
842 void MainWindow::saveCurrentConfig()
844 saveConfig(getDefaultConfigName());
845 ui
->applyButton
->setEnabled(false);
846 ui
->closeCancelButton
->setText(tr("Close"));
848 QMessageBox::information(this, tr("Information"),
849 tr("Applications using OpenAL need to be restarted for changes to take effect."));
852 void MainWindow::saveConfigAsFile()
854 QString fname
= QFileDialog::getOpenFileName(this, tr("Select Files"));
855 if(fname
.isEmpty() == false)
858 ui
->applyButton
->setEnabled(false);
863 void MainWindow::saveConfig(const QString
&fname
) const
865 QSettings
settings(fname
, QSettings::IniFormat
);
867 /* HACK: Compound any stringlist values into a comma-separated string. */
868 QStringList allkeys
= settings
.allKeys();
869 foreach(const QString
&key
, allkeys
)
871 QStringList vals
= settings
.value(key
).toStringList();
873 settings
.setValue(key
, vals
.join(QChar(',')));
876 settings
.setValue("sample-type", getValueFromName(sampleTypeList
, ui
->sampleFormatCombo
->currentText()));
877 settings
.setValue("channels", getValueFromName(speakerModeList
, ui
->channelConfigCombo
->currentText()));
879 uint rate
= ui
->sampleRateCombo
->currentText().toUInt();
881 settings
.setValue("frequency", QString());
883 settings
.setValue("frequency", rate
);
885 settings
.setValue("period_size", ui
->periodSizeEdit
->text());
886 settings
.setValue("periods", ui
->periodCountEdit
->text());
888 settings
.setValue("sources", ui
->srcCountLineEdit
->text());
889 settings
.setValue("slots", ui
->effectSlotLineEdit
->text());
891 settings
.setValue("resampler", resamplerList
[ui
->resamplerSlider
->value()].value
);
893 settings
.setValue("stereo-mode", getValueFromName(stereoModeList
, ui
->stereoModeCombo
->currentText()));
894 settings
.setValue("stereo-encoding", getValueFromName(stereoEncList
, ui
->stereoEncodingComboBox
->currentText()));
895 settings
.setValue("ambi-format", getValueFromName(ambiFormatList
, ui
->ambiFormatComboBox
->currentText()));
897 settings
.setValue("decoder/hq-mode",
898 ui
->decoderHQModeCheckBox
->isChecked() ? QString("true") : QString(/*"false"*/)
900 settings
.setValue("decoder/distance-comp",
901 ui
->decoderDistCompCheckBox
->isChecked() ? QString(/*"true"*/) : QString("false")
903 settings
.setValue("decoder/nfc",
904 ui
->decoderNFEffectsCheckBox
->isChecked() ? QString(/*"true"*/) : QString("false")
906 double refdelay
= ui
->decoderNFRefDelaySpinBox
->value();
907 settings
.setValue("decoder/nfc-ref-delay",
908 (refdelay
> 0.0) ? QString::number(refdelay
) : QString()
911 settings
.setValue("decoder/quad", ui
->decoderQuadLineEdit
->text());
912 settings
.setValue("decoder/surround51", ui
->decoder51LineEdit
->text());
913 settings
.setValue("decoder/surround61", ui
->decoder61LineEdit
->text());
914 settings
.setValue("decoder/surround71", ui
->decoder71LineEdit
->text());
917 if(!ui
->enableSSECheckBox
->isChecked())
918 strlist
.append("sse");
919 if(!ui
->enableSSE2CheckBox
->isChecked())
920 strlist
.append("sse2");
921 if(!ui
->enableSSE3CheckBox
->isChecked())
922 strlist
.append("sse3");
923 if(!ui
->enableSSE41CheckBox
->isChecked())
924 strlist
.append("sse4.1");
925 if(!ui
->enableNeonCheckBox
->isChecked())
926 strlist
.append("neon");
927 settings
.setValue("disable-cpu-exts", strlist
.join(QChar(',')));
929 if(ui
->hrtfStateComboBox
->currentIndex() == 1)
930 settings
.setValue("hrtf", "true");
931 else if(ui
->hrtfStateComboBox
->currentIndex() == 2)
932 settings
.setValue("hrtf", "false");
934 settings
.setValue("hrtf", QString());
936 if(ui
->preferredHrtfComboBox
->currentIndex() == 0)
937 settings
.setValue("default-hrtf", QString());
940 QString str
= ui
->preferredHrtfComboBox
->currentText();
941 settings
.setValue("default-hrtf", str
);
945 for(int i
= 0;i
< ui
->hrtfFileList
->count();i
++)
946 strlist
.append(ui
->hrtfFileList
->item(i
)->text());
947 if(!strlist
.empty() && ui
->defaultHrtfPathsCheckBox
->isChecked())
948 strlist
.append(QString());
949 settings
.setValue("hrtf-paths", strlist
.join(QChar(',')));
952 for(int i
= 0;i
< ui
->enabledBackendList
->count();i
++)
954 QString label
= ui
->enabledBackendList
->item(i
)->text();
955 for(int j
= 0;backendList
[j
].backend_name
[0];j
++)
957 if(label
== backendList
[j
].full_string
)
959 strlist
.append(backendList
[j
].backend_name
);
964 for(int i
= 0;i
< ui
->disabledBackendList
->count();i
++)
966 QString label
= ui
->disabledBackendList
->item(i
)->text();
967 for(int j
= 0;backendList
[j
].backend_name
[0];j
++)
969 if(label
== backendList
[j
].full_string
)
971 strlist
.append(QChar('-')+QString(backendList
[j
].backend_name
));
976 if(strlist
.size() == 0 && !ui
->backendCheckBox
->isChecked())
977 strlist
.append("-all");
978 else if(ui
->backendCheckBox
->isChecked())
979 strlist
.append(QString());
980 settings
.setValue("drivers", strlist
.join(QChar(',')));
982 // TODO: Remove check when we can properly match global values.
983 if(ui
->defaultReverbComboBox
->currentIndex() == 0)
984 settings
.setValue("default-reverb", QString());
987 QString str
= ui
->defaultReverbComboBox
->currentText().toLower();
988 settings
.setValue("default-reverb", str
);
991 if(ui
->emulateEaxCheckBox
->isChecked())
992 settings
.setValue("reverb/emulate-eax", "true");
994 settings
.remove("reverb/emulate-eax"/*, "false"*/);
997 if(!ui
->enableEaxReverbCheck
->isChecked())
998 strlist
.append("eaxreverb");
999 if(!ui
->enableStdReverbCheck
->isChecked())
1000 strlist
.append("reverb");
1001 if(!ui
->enableChorusCheck
->isChecked())
1002 strlist
.append("chorus");
1003 if(!ui
->enableDistortionCheck
->isChecked())
1004 strlist
.append("distortion");
1005 if(!ui
->enableCompressorCheck
->isChecked())
1006 strlist
.append("compressor");
1007 if(!ui
->enableEchoCheck
->isChecked())
1008 strlist
.append("echo");
1009 if(!ui
->enableEqualizerCheck
->isChecked())
1010 strlist
.append("equalizer");
1011 if(!ui
->enableFlangerCheck
->isChecked())
1012 strlist
.append("flanger");
1013 if(!ui
->enableModulatorCheck
->isChecked())
1014 strlist
.append("modulator");
1015 if(!ui
->enableDedicatedCheck
->isChecked())
1016 strlist
.append("dedicated");
1017 settings
.setValue("excludefx", strlist
.join(QChar(',')));
1019 settings
.setValue("pulse/spawn-server",
1020 ui
->pulseAutospawnCheckBox
->isChecked() ? QString(/*"true"*/) : QString("false")
1022 settings
.setValue("pulse/allow-moves",
1023 ui
->pulseAllowMovesCheckBox
->isChecked() ? QString("true") : QString(/*"false"*/)
1025 settings
.setValue("pulse/fix-rate",
1026 ui
->pulseFixRateCheckBox
->isChecked() ? QString("true") : QString(/*"false"*/)
1029 settings
.setValue("jack/spawn-server",
1030 ui
->jackAutospawnCheckBox
->isChecked() ? QString("true") : QString(/*"false"*/)
1032 settings
.setValue("jack/buffer-size", ui
->jackBufferSizeLine
->text());
1034 settings
.setValue("alsa/device", ui
->alsaDefaultDeviceLine
->text());
1035 settings
.setValue("alsa/capture", ui
->alsaDefaultCaptureLine
->text());
1036 settings
.setValue("alsa/allow-resampler",
1037 ui
->alsaResamplerCheckBox
->isChecked() ? QString("true") : QString(/*"false"*/)
1039 settings
.setValue("alsa/mmap",
1040 ui
->alsaMmapCheckBox
->isChecked() ? QString(/*"true"*/) : QString("false")
1043 settings
.setValue("oss/device", ui
->ossDefaultDeviceLine
->text());
1044 settings
.setValue("oss/capture", ui
->ossDefaultCaptureLine
->text());
1046 settings
.setValue("solaris/device", ui
->solarisDefaultDeviceLine
->text());
1048 settings
.setValue("wave/file", ui
->waveOutputLine
->text());
1049 settings
.setValue("wave/bformat",
1050 ui
->waveBFormatCheckBox
->isChecked() ? QString("true") : QString(/*"false"*/)
1053 /* Remove empty keys
1054 * FIXME: Should only remove keys whose value matches the globally-specified value.
1056 allkeys
= settings
.allKeys();
1057 foreach(const QString
&key
, allkeys
)
1059 QString str
= settings
.value(key
).toString();
1060 if(str
== QString())
1061 settings
.remove(key
);
1066 void MainWindow::enableApplyButton()
1069 ui
->applyButton
->setEnabled(true);
1071 ui
->closeCancelButton
->setText(tr("Cancel"));
1075 void MainWindow::updateResamplerLabel(int num
)
1077 ui
->resamplerLabel
->setText(resamplerList
[num
].name
);
1078 enableApplyButton();
1082 void MainWindow::updatePeriodSizeEdit(int size
)
1084 ui
->periodSizeEdit
->clear();
1087 size
= (size
+32)&~0x3f;
1088 ui
->periodSizeEdit
->insert(QString::number(size
));
1090 enableApplyButton();
1093 void MainWindow::updatePeriodSizeSlider()
1095 int pos
= ui
->periodSizeEdit
->text().toInt();
1100 ui
->periodSizeSlider
->setSliderPosition(pos
);
1102 enableApplyButton();
1105 void MainWindow::updatePeriodCountEdit(int count
)
1107 ui
->periodCountEdit
->clear();
1109 ui
->periodCountEdit
->insert(QString::number(count
));
1110 enableApplyButton();
1113 void MainWindow::updatePeriodCountSlider()
1115 int pos
= ui
->periodCountEdit
->text().toInt();
1120 ui
->periodCountSlider
->setSliderPosition(pos
);
1121 enableApplyButton();
1125 void MainWindow::selectQuadDecoderFile()
1126 { selectDecoderFile(ui
->decoderQuadLineEdit
, "Select Quadrophonic Decoder");}
1127 void MainWindow::select51DecoderFile()
1128 { selectDecoderFile(ui
->decoder51LineEdit
, "Select 5.1 Surround Decoder");}
1129 void MainWindow::select61DecoderFile()
1130 { selectDecoderFile(ui
->decoder61LineEdit
, "Select 6.1 Surround Decoder");}
1131 void MainWindow::select71DecoderFile()
1132 { selectDecoderFile(ui
->decoder71LineEdit
, "Select 7.1 Surround Decoder");}
1133 void MainWindow::selectDecoderFile(QLineEdit
*line
, const char *caption
)
1135 QString dir
= line
->text();
1136 if(dir
.isEmpty() || QDir::isRelativePath(dir
))
1138 QStringList paths
= getAllDataPaths("/openal/presets");
1139 while(!paths
.isEmpty())
1141 if(QDir(paths
.last()).exists())
1149 QString fname
= QFileDialog::getOpenFileName(this, tr(caption
),
1150 dir
, tr("AmbDec Files (*.ambdec);;All Files (*.*)")
1152 if(!fname
.isEmpty())
1154 line
->setText(fname
);
1155 enableApplyButton();
1160 void MainWindow::updateJackBufferSizeEdit(int size
)
1162 ui
->jackBufferSizeLine
->clear();
1164 ui
->jackBufferSizeLine
->insert(QString::number(1<<size
));
1165 enableApplyButton();
1168 void MainWindow::updateJackBufferSizeSlider()
1170 int value
= ui
->jackBufferSizeLine
->text().toInt();
1171 int pos
= (int)floor(log2(value
) + 0.5);
1172 ui
->jackBufferSizeSlider
->setSliderPosition(pos
);
1173 enableApplyButton();
1177 void MainWindow::addHrtfFile()
1179 QString path
= QFileDialog::getExistingDirectory(this, tr("Select HRTF Path"));
1180 if(path
.isEmpty() == false && !getAllDataPaths("/openal/hrtf").contains(path
))
1182 ui
->hrtfFileList
->addItem(path
);
1183 enableApplyButton();
1187 void MainWindow::removeHrtfFile()
1189 QList
<QListWidgetItem
*> selected
= ui
->hrtfFileList
->selectedItems();
1190 if(!selected
.isEmpty())
1192 foreach(QListWidgetItem
*item
, selected
)
1194 enableApplyButton();
1198 void MainWindow::updateHrtfRemoveButton()
1200 ui
->hrtfRemoveButton
->setEnabled(ui
->hrtfFileList
->selectedItems().size() != 0);
1203 void MainWindow::showEnabledBackendMenu(QPoint pt
)
1205 QMap
<QAction
*,QString
> actionMap
;
1207 pt
= ui
->enabledBackendList
->mapToGlobal(pt
);
1210 QAction
*removeAction
= ctxmenu
.addAction(QIcon::fromTheme("list-remove"), "Remove");
1211 if(ui
->enabledBackendList
->selectedItems().size() == 0)
1212 removeAction
->setEnabled(false);
1213 ctxmenu
.addSeparator();
1214 for(size_t i
= 0;backendList
[i
].backend_name
[0];i
++)
1216 QString backend
= backendList
[i
].full_string
;
1217 QAction
*action
= ctxmenu
.addAction(QString("Add ")+backend
);
1218 actionMap
[action
] = backend
;
1219 if(ui
->enabledBackendList
->findItems(backend
, Qt::MatchFixedString
).size() != 0 ||
1220 ui
->disabledBackendList
->findItems(backend
, Qt::MatchFixedString
).size() != 0)
1221 action
->setEnabled(false);
1224 QAction
*gotAction
= ctxmenu
.exec(pt
);
1225 if(gotAction
== removeAction
)
1227 QList
<QListWidgetItem
*> selected
= ui
->enabledBackendList
->selectedItems();
1228 foreach(QListWidgetItem
*item
, selected
)
1230 enableApplyButton();
1232 else if(gotAction
!= NULL
)
1234 QMap
<QAction
*,QString
>::const_iterator iter
= actionMap
.find(gotAction
);
1235 if(iter
!= actionMap
.end())
1236 ui
->enabledBackendList
->addItem(iter
.value());
1237 enableApplyButton();
1241 void MainWindow::showDisabledBackendMenu(QPoint pt
)
1243 QMap
<QAction
*,QString
> actionMap
;
1245 pt
= ui
->disabledBackendList
->mapToGlobal(pt
);
1248 QAction
*removeAction
= ctxmenu
.addAction(QIcon::fromTheme("list-remove"), "Remove");
1249 if(ui
->disabledBackendList
->selectedItems().size() == 0)
1250 removeAction
->setEnabled(false);
1251 ctxmenu
.addSeparator();
1252 for(size_t i
= 0;backendList
[i
].backend_name
[0];i
++)
1254 QString backend
= backendList
[i
].full_string
;
1255 QAction
*action
= ctxmenu
.addAction(QString("Add ")+backend
);
1256 actionMap
[action
] = backend
;
1257 if(ui
->disabledBackendList
->findItems(backend
, Qt::MatchFixedString
).size() != 0 ||
1258 ui
->enabledBackendList
->findItems(backend
, Qt::MatchFixedString
).size() != 0)
1259 action
->setEnabled(false);
1262 QAction
*gotAction
= ctxmenu
.exec(pt
);
1263 if(gotAction
== removeAction
)
1265 QList
<QListWidgetItem
*> selected
= ui
->disabledBackendList
->selectedItems();
1266 foreach(QListWidgetItem
*item
, selected
)
1268 enableApplyButton();
1270 else if(gotAction
!= NULL
)
1272 QMap
<QAction
*,QString
>::const_iterator iter
= actionMap
.find(gotAction
);
1273 if(iter
!= actionMap
.end())
1274 ui
->disabledBackendList
->addItem(iter
.value());
1275 enableApplyButton();
1279 void MainWindow::selectOSSPlayback()
1281 QString current
= ui
->ossDefaultDeviceLine
->text();
1282 if(current
.isEmpty()) current
= ui
->ossDefaultDeviceLine
->placeholderText();
1283 QString fname
= QFileDialog::getOpenFileName(this, tr("Select Playback Device"), current
);
1284 if(!fname
.isEmpty())
1286 ui
->ossDefaultDeviceLine
->setText(fname
);
1287 enableApplyButton();
1291 void MainWindow::selectOSSCapture()
1293 QString current
= ui
->ossDefaultCaptureLine
->text();
1294 if(current
.isEmpty()) current
= ui
->ossDefaultCaptureLine
->placeholderText();
1295 QString fname
= QFileDialog::getOpenFileName(this, tr("Select Capture Device"), current
);
1296 if(!fname
.isEmpty())
1298 ui
->ossDefaultCaptureLine
->setText(fname
);
1299 enableApplyButton();
1303 void MainWindow::selectSolarisPlayback()
1305 QString current
= ui
->solarisDefaultDeviceLine
->text();
1306 if(current
.isEmpty()) current
= ui
->solarisDefaultDeviceLine
->placeholderText();
1307 QString fname
= QFileDialog::getOpenFileName(this, tr("Select Playback Device"), current
);
1308 if(!fname
.isEmpty())
1310 ui
->solarisDefaultDeviceLine
->setText(fname
);
1311 enableApplyButton();
1315 void MainWindow::selectWaveOutput()
1317 QString fname
= QFileDialog::getSaveFileName(this, tr("Select Wave File Output"),
1318 ui
->waveOutputLine
->text(), tr("Wave Files (*.wav *.amb);;All Files (*.*)")
1320 if(!fname
.isEmpty())
1322 ui
->waveOutputLine
->setText(fname
);
1323 enableApplyButton();