diff options
author | Chris Robinson <[email protected]> | 2019-04-29 13:44:16 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2019-04-29 19:47:14 -0700 |
commit | fb52413a6e1ba40643529343e6660ef760f9635d (patch) | |
tree | 19d4f67839c030cae75a65f709e48698c12cdd34 /utils/alsoft-config | |
parent | cef7eebed663e1daf8704eceb09f05ff75609ec5 (diff) |
Make a number of settings tristate
Diffstat (limited to 'utils/alsoft-config')
-rw-r--r-- | utils/alsoft-config/mainwindow.cpp | 110 | ||||
-rw-r--r-- | utils/alsoft-config/mainwindow.ui | 26 |
2 files changed, 63 insertions, 73 deletions
diff --git a/utils/alsoft-config/mainwindow.cpp b/utils/alsoft-config/mainwindow.cpp index 37ea3dd7..4e2b2464 100644 --- a/utils/alsoft-config/mainwindow.cpp +++ b/utils/alsoft-config/mainwindow.cpp @@ -210,6 +210,26 @@ static QString getNameFromValue(const NameValuePair (&list)[N], const QString &s return QString(); } + +Qt::CheckState getCheckState(const QVariant &var) +{ + if(var.isNull()) + return Qt::PartiallyChecked; + if(var.toBool()) + return Qt::Checked; + return Qt::Unchecked; +} + +QString getCheckValue(const QCheckBox *checkbox) +{ + const Qt::CheckState state{checkbox->checkState()}; + if(state == Qt::Checked) + return QString("true"); + if(state == Qt::Unchecked) + return QString("false"); + return QString(); +} + } MainWindow::MainWindow(QWidget *parent) : @@ -655,19 +675,8 @@ void MainWindow::loadConfig(const QString &fname) updatePeriodCountSlider(); } - if(settings.value("output-limiter").isNull()) - ui->outputLimiterCheckBox->setCheckState(Qt::PartiallyChecked); - else - ui->outputLimiterCheckBox->setCheckState( - settings.value("output-limiter").toBool() ? Qt::Checked : Qt::Unchecked - ); - - if(settings.value("dither").isNull()) - ui->outputDitherCheckBox->setCheckState(Qt::PartiallyChecked); - else - ui->outputDitherCheckBox->setCheckState( - settings.value("dither").toBool() ? Qt::Checked : Qt::Unchecked - ); + ui->outputLimiterCheckBox->setCheckState(getCheckState(settings.value("output-limiter"))); + ui->outputDitherCheckBox->setCheckState(getCheckState(settings.value("dither"))); QString stereopan = settings.value("stereo-encoding").toString(); ui->stereoEncodingComboBox->setCurrentIndex(0); @@ -695,10 +704,8 @@ void MainWindow::loadConfig(const QString &fname) bool hqmode = settings.value("decoder/hq-mode", false).toBool(); ui->decoderHQModeCheckBox->setChecked(hqmode); - bool distcomp = settings.value("decoder/distance-comp", true).toBool(); - ui->decoderDistCompCheckBox->setChecked(distcomp); - bool nfeffects = settings.value("decoder/nfc", false).toBool(); - ui->decoderNFEffectsCheckBox->setChecked(nfeffects); + ui->decoderDistCompCheckBox->setCheckState(getCheckState(settings.value("decoder/distance-comp"))); + ui->decoderNFEffectsCheckBox->setCheckState(getCheckState(settings.value("decoder/nfc"))); double refdelay = settings.value("decoder/nfc-ref-delay", 0.0).toDouble(); ui->decoderNFRefDelaySpinBox->setValue(refdelay); @@ -853,19 +860,19 @@ void MainWindow::loadConfig(const QString &fname) ui->enableDedicatedCheck->setChecked(!excludefx.contains("dedicated", Qt::CaseInsensitive)); ui->enablePitchShifterCheck->setChecked(!excludefx.contains("pshifter", Qt::CaseInsensitive)); - ui->pulseAutospawnCheckBox->setChecked(settings.value("pulse/spawn-server", true).toBool()); - ui->pulseAllowMovesCheckBox->setChecked(settings.value("pulse/allow-moves", false).toBool()); - ui->pulseFixRateCheckBox->setChecked(settings.value("pulse/fix-rate", false).toBool()); - ui->pulseAdjLatencyCheckBox->setChecked(settings.value("pulse/adjust-latency", false).toBool()); + ui->pulseAutospawnCheckBox->setCheckState(getCheckState(settings.value("pulse/spawn-server"))); + ui->pulseAllowMovesCheckBox->setCheckState(getCheckState(settings.value("pulse/allow-moves"))); + ui->pulseFixRateCheckBox->setCheckState(getCheckState(settings.value("pulse/fix-rate"))); + ui->pulseAdjLatencyCheckBox->setCheckState(getCheckState(settings.value("pulse/adjust-latency"))); - ui->jackAutospawnCheckBox->setChecked(settings.value("jack/spawn-server", false).toBool()); + ui->jackAutospawnCheckBox->setCheckState(getCheckState(settings.value("jack/spawn-server"))); ui->jackBufferSizeLine->setText(settings.value("jack/buffer-size", QString()).toString()); updateJackBufferSizeSlider(); ui->alsaDefaultDeviceLine->setText(settings.value("alsa/device", QString()).toString()); ui->alsaDefaultCaptureLine->setText(settings.value("alsa/capture", QString()).toString()); - ui->alsaResamplerCheckBox->setChecked(settings.value("alsa/allow-resampler", false).toBool()); - ui->alsaMmapCheckBox->setChecked(settings.value("alsa/mmap", true).toBool()); + ui->alsaResamplerCheckBox->setCheckState(getCheckState(settings.value("alsa/allow-resampler"))); + ui->alsaMmapCheckBox->setCheckState(getCheckState(settings.value("alsa/mmap"))); ui->ossDefaultDeviceLine->setText(settings.value("oss/device", QString()).toString()); ui->ossDefaultCaptureLine->setText(settings.value("oss/capture", QString()).toString()); @@ -887,7 +894,7 @@ void MainWindow::saveCurrentConfig() ui->closeCancelButton->setText(tr("Close")); mNeedsSave = false; QMessageBox::information(this, tr("Information"), - tr("Applications using OpenAL need to be restarted for changes to take effect.")); + tr("Applications using OpenAL need to be restarted for changes to take effect.")); } void MainWindow::saveConfigAsFile() @@ -935,31 +942,14 @@ void MainWindow::saveConfig(const QString &fname) const settings.setValue("stereo-encoding", getValueFromName(stereoEncList, ui->stereoEncodingComboBox->currentText())); settings.setValue("ambi-format", getValueFromName(ambiFormatList, ui->ambiFormatComboBox->currentText())); - Qt::CheckState limiter = ui->outputLimiterCheckBox->checkState(); - if(limiter == Qt::PartiallyChecked) - settings.setValue("output-limiter", QString()); - else if(limiter == Qt::Checked) - settings.setValue("output-limiter", QString("true")); - else if(limiter == Qt::Unchecked) - settings.setValue("output-limiter", QString("false")); - - Qt::CheckState dither = ui->outputDitherCheckBox->checkState(); - if(dither == Qt::PartiallyChecked) - settings.setValue("dither", QString()); - else if(dither == Qt::Checked) - settings.setValue("dither", QString("true")); - else if(dither == Qt::Unchecked) - settings.setValue("dither", QString("false")); + settings.setValue("output-limiter", getCheckValue(ui->outputLimiterCheckBox)); + settings.setValue("dither", getCheckValue(ui->outputDitherCheckBox)); settings.setValue("decoder/hq-mode", ui->decoderHQModeCheckBox->isChecked() ? QString("true") : QString(/*"false"*/) ); - settings.setValue("decoder/distance-comp", - ui->decoderDistCompCheckBox->isChecked() ? QString(/*"true"*/) : QString("false") - ); - settings.setValue("decoder/nfc", - ui->decoderNFEffectsCheckBox->isChecked() ? QString("true") : QString(/*"false"*/) - ); + settings.setValue("decoder/distance-comp", getCheckValue(ui->decoderDistCompCheckBox)); + settings.setValue("decoder/nfc", getCheckValue(ui->decoderNFEffectsCheckBox)); double refdelay = ui->decoderNFRefDelaySpinBox->value(); settings.setValue("decoder/nfc-ref-delay", (refdelay > 0.0) ? QString::number(refdelay) : QString() @@ -1074,32 +1064,18 @@ void MainWindow::saveConfig(const QString &fname) const strlist.append("pshifter"); settings.setValue("excludefx", strlist.join(QChar(','))); - settings.setValue("pulse/spawn-server", - ui->pulseAutospawnCheckBox->isChecked() ? QString(/*"true"*/) : QString("false") - ); - settings.setValue("pulse/allow-moves", - ui->pulseAllowMovesCheckBox->isChecked() ? QString("true") : QString(/*"false"*/) - ); - settings.setValue("pulse/fix-rate", - ui->pulseFixRateCheckBox->isChecked() ? QString("true") : QString(/*"false"*/) - ); - settings.setValue("pulse/adjust-latency", - ui->pulseAdjLatencyCheckBox->isChecked() ? QString("true") : QString(/*"false"*/) - ); + settings.setValue("pulse/spawn-server", getCheckValue(ui->pulseAutospawnCheckBox)); + settings.setValue("pulse/allow-moves", getCheckValue(ui->pulseAllowMovesCheckBox)); + settings.setValue("pulse/fix-rate", getCheckValue(ui->pulseFixRateCheckBox)); + settings.setValue("pulse/adjust-latency", getCheckValue(ui->pulseAdjLatencyCheckBox)); - settings.setValue("jack/spawn-server", - ui->jackAutospawnCheckBox->isChecked() ? QString("true") : QString(/*"false"*/) - ); + settings.setValue("jack/spawn-server", getCheckValue(ui->jackAutospawnCheckBox)); settings.setValue("jack/buffer-size", ui->jackBufferSizeLine->text()); settings.setValue("alsa/device", ui->alsaDefaultDeviceLine->text()); settings.setValue("alsa/capture", ui->alsaDefaultCaptureLine->text()); - settings.setValue("alsa/allow-resampler", - ui->alsaResamplerCheckBox->isChecked() ? QString("true") : QString(/*"false"*/) - ); - settings.setValue("alsa/mmap", - ui->alsaMmapCheckBox->isChecked() ? QString(/*"true"*/) : QString("false") - ); + settings.setValue("alsa/allow-resampler", getCheckValue(ui->alsaResamplerCheckBox)); + settings.setValue("alsa/mmap", getCheckValue(ui->alsaMmapCheckBox)); settings.setValue("oss/device", ui->ossDefaultDeviceLine->text()); settings.setValue("oss/capture", ui->ossDefaultCaptureLine->text()); diff --git a/utils/alsoft-config/mainwindow.ui b/utils/alsoft-config/mainwindow.ui index 158a3316..46d1b7a8 100644 --- a/utils/alsoft-config/mainwindow.ui +++ b/utils/alsoft-config/mainwindow.ui @@ -655,7 +655,7 @@ configuration file.</string> <property name="text"> <string>Distance Compensation:</string> </property> - <property name="checked"> + <property name="tristate"> <bool>true</bool> </property> </widget> @@ -847,8 +847,7 @@ creates a more realistic perception of sound distance. Note that the effect may be stronger or weaker than intended if the application doesn't use or specify an appropriate unit scale, or if incorrect speaker distances -are set in the decoder configuration file. Requires High -Quality Mode to be enabled.</string> +are set in the decoder configuration file.</string> </property> <property name="layoutDirection"> <enum>Qt::RightToLeft</enum> @@ -856,7 +855,7 @@ Quality Mode to be enabled.</string> <property name="text"> <string>Near-Field Effects:</string> </property> - <property name="checked"> + <property name="tristate"> <bool>true</bool> </property> </widget> @@ -1282,7 +1281,7 @@ is not already running.</string> <property name="text"> <string>AutoSpawn Server</string> </property> - <property name="checked"> + <property name="tristate"> <bool>true</bool> </property> </widget> @@ -1304,6 +1303,9 @@ to match the new device.</string> <property name="text"> <string>Allow Moving Streams</string> </property> + <property name="tristate"> + <bool>true</bool> + </property> </widget> <widget class="QCheckBox" name="pulseFixRateCheckBox"> <property name="geometry"> @@ -1321,6 +1323,9 @@ rate to match the PulseAudio device.</string> <property name="text"> <string>Fix Sample Rate</string> </property> + <property name="tristate"> + <bool>true</bool> + </property> </widget> <widget class="QCheckBox" name="pulseAdjLatencyCheckBox"> <property name="geometry"> @@ -1341,6 +1346,9 @@ drop-outs.</string> <property name="text"> <string>Adjust Latency</string> </property> + <property name="tristate"> + <bool>true</bool> + </property> </widget> </widget> <widget class="QWidget" name="page_7"> @@ -1356,6 +1364,9 @@ drop-outs.</string> <property name="text"> <string>AutoSpawn Server</string> </property> + <property name="tristate"> + <bool>true</bool> + </property> </widget> <widget class="QGroupBox" name="groupBox_7"> <property name="geometry"> @@ -1497,6 +1508,9 @@ resample pass on top of OpenAL's resampler.</string> <property name="text"> <string>Allow Resampler</string> </property> + <property name="tristate"> + <bool>true</bool> + </property> </widget> <widget class="QCheckBox" name="alsaMmapCheckBox"> <property name="geometry"> @@ -1515,7 +1529,7 @@ during updates.</string> <property name="text"> <string>MMap Buffer</string> </property> - <property name="checked"> + <property name="tristate"> <bool>true</bool> </property> </widget> |