diff options
-rw-r--r-- | Alc/hrtf.c | 2 | ||||
-rw-r--r-- | alsoftrc.sample | 4 | ||||
-rw-r--r-- | utils/alsoft-config/mainwindow.cpp | 103 | ||||
-rw-r--r-- | utils/alsoft-config/mainwindow.h | 2 |
4 files changed, 71 insertions, 40 deletions
@@ -641,7 +641,7 @@ vector_HrtfEntry EnumerateHrtf(const_al_string devname) } } - if(VECTOR_SIZE(list) > 1 && ConfigValueStr(al_string_get_cstr(devname), NULL, "default_hrtf", &defaulthrtf)) + if(VECTOR_SIZE(list) > 1 && ConfigValueStr(al_string_get_cstr(devname), NULL, "default-hrtf", &defaulthrtf)) { const HrtfEntry *iter; /* Find the preferred HRTF and move it to the front of the list. */ diff --git a/alsoftrc.sample b/alsoftrc.sample index c29fae49..9eb9740e 100644 --- a/alsoftrc.sample +++ b/alsoftrc.sample @@ -96,11 +96,11 @@ # respectively. #hrtf = auto -## default_hrtf: +## default-hrtf: # Specifies the default HRTF to use. When multiple HRTFs are available, this # determines the preferred one to use if none are specifically requested. Note # that this is the enumerated HRTF name, not necessarily the filename. -#default_hrtf = +#default-hrtf = ## hrtf_tables: # Specifies a comma-separated list of files containing HRTF data sets. The diff --git a/utils/alsoft-config/mainwindow.cpp b/utils/alsoft-config/mainwindow.cpp index 3b123ccf..315ef491 100644 --- a/utils/alsoft-config/mainwindow.cpp +++ b/utils/alsoft-config/mainwindow.cpp @@ -269,6 +269,7 @@ MainWindow::MainWindow(QWidget *parent) : connect(ui->periodCountSlider, SIGNAL(valueChanged(int)), this, SLOT(updatePeriodCountEdit(int))); connect(ui->periodCountEdit, SIGNAL(editingFinished()), this, SLOT(updatePeriodCountSlider())); + connect(ui->preferredHrtfComboBox, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(enableApplyButton())); connect(ui->hrtfStateComboBox, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(enableApplyButton())); connect(ui->hrtfAddButton, SIGNAL(clicked()), this, SLOT(addHrtfFile())); connect(ui->hrtfRemoveButton, SIGNAL(clicked()), this, SLOT(removeHrtfFile())); @@ -345,6 +346,24 @@ void MainWindow::cancelCloseAction() } +QStringList MainWindow::collectDefaultHrtfs() +{ + QStringList ret; + QStringList paths = getAllDataPaths("/openal/hrtf"); + foreach(const QString &name, paths) + { + QDir dir(name); + QStringList fnames = dir.entryList(QDir::Files | QDir::Readable); + foreach(const QString &fname, fnames) + { + if(fname.endsWith(".mhr", Qt::CaseInsensitive)) + ret.push_back(fname); + } + } + return ret; +} + + void MainWindow::loadConfigFromFile() { QString fname = QFileDialog::getOpenFileName(this, tr("Select Files")); @@ -364,15 +383,8 @@ void MainWindow::loadConfig(const QString &fname) { if(sampletype == sampleTypeList[i].value) { - for(int j = 1;j < ui->sampleFormatCombo->count();j++) - { - QString item = ui->sampleFormatCombo->itemText(j); - if(item == sampleTypeList[i].name) - { - ui->sampleFormatCombo->setCurrentIndex(j); - break; - } - } + int j = ui->sampleFormatCombo->findText(sampleTypeList[i].name); + if(j > 0) ui->sampleFormatCombo->setCurrentIndex(j); break; } } @@ -386,15 +398,8 @@ void MainWindow::loadConfig(const QString &fname) { if(channelconfig == speakerModeList[i].value) { - for(int j = 1;j < ui->channelConfigCombo->count();j++) - { - QString item = ui->channelConfigCombo->itemText(j); - if(item == speakerModeList[i].name) - { - ui->channelConfigCombo->setCurrentIndex(j); - break; - } - } + int j = ui->channelConfigCombo->findText(speakerModeList[i].name); + if(j > 0) ui->channelConfigCombo->setCurrentIndex(j); break; } } @@ -439,15 +444,8 @@ void MainWindow::loadConfig(const QString &fname) { if(stereomode == stereoModeList[i].value) { - for(int j = 1;j < ui->stereoModeCombo->count();j++) - { - QString item = ui->stereoModeCombo->itemText(j); - if(item == stereoModeList[i].name) - { - ui->stereoModeCombo->setCurrentIndex(j); - break; - } - } + int j = ui->stereoModeCombo->findText(stereoModeList[i].name); + if(j > 0) ui->stereoModeCombo->setCurrentIndex(j); break; } } @@ -480,16 +478,6 @@ void MainWindow::loadConfig(const QString &fname) ui->enableSSE41CheckBox->setChecked(!disabledCpuExts.contains("sse4.1", Qt::CaseInsensitive)); ui->enableNeonCheckBox->setChecked(!disabledCpuExts.contains("neon", Qt::CaseInsensitive)); - if(settings.value("hrtf").toString() == QString()) - ui->hrtfStateComboBox->setCurrentIndex(0); - else - { - if(settings.value("hrtf", true).toBool()) - ui->hrtfStateComboBox->setCurrentIndex(1); - else - ui->hrtfStateComboBox->setCurrentIndex(2); - } - QStringList hrtf_tables = settings.value("hrtf_tables").toStringList(); if(hrtf_tables.size() == 1) hrtf_tables = hrtf_tables[0].split(QChar(',')); @@ -507,6 +495,39 @@ void MainWindow::loadConfig(const QString &fname) ui->hrtfFileList->addItems(hrtf_tables); updateHrtfRemoveButton(); + QString hrtfstate = settings.value("hrtf").toString().toLower(); + if(hrtfstate == "true") + ui->hrtfStateComboBox->setCurrentIndex(1); + else if(hrtfstate == "false") + ui->hrtfStateComboBox->setCurrentIndex(2); + else + ui->hrtfStateComboBox->setCurrentIndex(0); + + ui->preferredHrtfComboBox->clear(); + ui->preferredHrtfComboBox->addItem("- Any -"); + if(ui->defaultHrtfPathsCheckBox->isChecked()) + { + QStringList hrtfs = collectDefaultHrtfs(); + foreach(const QString &name, hrtfs) + ui->preferredHrtfComboBox->addItem(name); + } + + QString defaulthrtf = settings.value("default-hrtf").toString(); + ui->preferredHrtfComboBox->setCurrentIndex(0); + if(defaulthrtf.isEmpty() == false) + { + int i = ui->preferredHrtfComboBox->findText(defaulthrtf); + if(i > 0) + ui->preferredHrtfComboBox->setCurrentIndex(i); + else + { + i = ui->preferredHrtfComboBox->count(); + ui->preferredHrtfComboBox->addItem(defaulthrtf); + ui->preferredHrtfComboBox->setCurrentIndex(i); + } + } + ui->preferredHrtfComboBox->adjustSize(); + ui->enabledBackendList->clear(); ui->disabledBackendList->clear(); QStringList drivers = settings.value("drivers").toStringList(); @@ -666,6 +687,14 @@ void MainWindow::saveConfig(const QString &fname) const else settings.setValue("hrtf", QString()); + if(ui->preferredHrtfComboBox->currentIndex() == 0) + settings.setValue("default-hrtf", QString()); + else + { + str = ui->preferredHrtfComboBox->currentText(); + settings.setValue("default-hrtf", str); + } + strlist.clear(); QList<QListWidgetItem*> items = ui->hrtfFileList->findItems("*", Qt::MatchWildcard); foreach(const QListWidgetItem *item, items) diff --git a/utils/alsoft-config/mainwindow.h b/utils/alsoft-config/mainwindow.h index dfa69ca2..66b4c650 100644 --- a/utils/alsoft-config/mainwindow.h +++ b/utils/alsoft-config/mainwindow.h @@ -55,6 +55,8 @@ private: void closeEvent(QCloseEvent *event); + QStringList collectDefaultHrtfs(); + void loadConfig(const QString &fname); void saveConfig(const QString &fname) const; }; |