aboutsummaryrefslogtreecommitdiffstats
path: root/utils/alsoft-config/mainwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'utils/alsoft-config/mainwindow.cpp')
-rw-r--r--utils/alsoft-config/mainwindow.cpp110
1 files changed, 43 insertions, 67 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());