diff options
Diffstat (limited to 'utils/alsoft-config/mainwindow.cpp')
-rw-r--r-- | utils/alsoft-config/mainwindow.cpp | 165 |
1 files changed, 96 insertions, 69 deletions
diff --git a/utils/alsoft-config/mainwindow.cpp b/utils/alsoft-config/mainwindow.cpp index fed9de59..bee7022f 100644 --- a/utils/alsoft-config/mainwindow.cpp +++ b/utils/alsoft-config/mainwindow.cpp @@ -21,13 +21,16 @@ namespace { -static const struct { +const struct { char backend_name[16]; char full_string[32]; } backendList[] = { #ifdef HAVE_JACK { "jack", "JACK" }, #endif +#ifdef HAVE_PIPEWIRE + { "pipewire", "PipeWire" }, +#endif #ifdef HAVE_PULSEAUDIO { "pulse", "PulseAudio" }, #endif @@ -72,7 +75,7 @@ static const struct { { "", "" } }; -static const struct NameValuePair { +const struct NameValuePair { const char name[64]; const char value[16]; } speakerModeList[] = { @@ -80,10 +83,10 @@ static const struct NameValuePair { { "Mono", "mono" }, { "Stereo", "stereo" }, { "Quadraphonic", "quad" }, - { "5.1 Surround (Side)", "surround51" }, - { "5.1 Surround (Rear)", "surround51rear" }, + { "5.1 Surround", "surround51" }, { "6.1 Surround", "surround61" }, { "7.1 Surround", "surround71" }, + { "3D7.1 Surround", "surround3d71" }, { "Ambisonic, 1st Order", "ambi1" }, { "Ambisonic, 2nd Order", "ambi2" }, @@ -104,8 +107,8 @@ static const struct NameValuePair { }, resamplerList[] = { { "Point", "point" }, { "Linear", "linear" }, - { "Default (Linear)", "" }, { "Cubic Spline", "cubic" }, + { "Default (Cubic Spline)", "" }, { "11th order Sinc (fast)", "fast_bsinc12" }, { "11th order Sinc", "bsinc12" }, { "23rd order Sinc (fast)", "fast_bsinc24" }, @@ -120,27 +123,30 @@ static const struct NameValuePair { { "", "" } }, stereoEncList[] = { { "Default", "" }, - { "Pan Pot", "panpot" }, + { "Basic", "panpot" }, { "UHJ", "uhj" }, + { "Binaural", "hrtf" }, { "", "" } }, ambiFormatList[] = { { "Default", "" }, { "AmbiX (ACN, SN3D)", "ambix" }, - { "ACN, N3D", "acn+n3d" }, { "Furse-Malham", "fuma" }, + { "ACN, N3D", "acn+n3d" }, + { "ACN, FuMa", "acn+fuma" }, { "", "" } }, hrtfModeList[] = { { "1st Order Ambisonic", "ambi1" }, { "2nd Order Ambisonic", "ambi2" }, + { "3rd Order Ambisonic", "ambi3" }, { "Default (Full)", "" }, { "Full", "full" }, { "", "" } }; -static QString getDefaultConfigName() +QString getDefaultConfigName() { #ifdef Q_OS_WIN32 static const char fname[] = "alsoft.ini"; @@ -167,7 +173,7 @@ static QString getDefaultConfigName() return fname; } -static QString getBaseDataPath() +QString getBaseDataPath() { #ifdef Q_OS_WIN32 auto get_appdata_path = []() noexcept -> QString @@ -190,7 +196,7 @@ static QString getBaseDataPath() return base; } -static QStringList getAllDataPaths(const QString &append) +QStringList getAllDataPaths(const QString &append) { QStringList list; list.append(getBaseDataPath()); @@ -200,8 +206,12 @@ static QStringList getAllDataPaths(const QString &append) QString paths = qgetenv("XDG_DATA_DIRS"); if(paths.isEmpty()) paths = "/usr/local/share/:/usr/share/"; +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) + list += paths.split(QChar(':'), Qt::SkipEmptyParts); +#else list += paths.split(QChar(':'), QString::SkipEmptyParts); #endif +#endif QStringList::iterator iter = list.begin(); while(iter != list.end()) { @@ -217,7 +227,7 @@ static QStringList getAllDataPaths(const QString &append) } template<size_t N> -static QString getValueFromName(const NameValuePair (&list)[N], const QString &str) +QString getValueFromName(const NameValuePair (&list)[N], const QString &str) { for(size_t i = 0;i < N-1;i++) { @@ -228,7 +238,7 @@ static QString getValueFromName(const NameValuePair (&list)[N], const QString &s } template<size_t N> -static QString getNameFromValue(const NameValuePair (&list)[N], const QString &str) +QString getNameFromValue(const NameValuePair (&list)[N], const QString &str) { for(size_t i = 0;i < N-1;i++) { @@ -298,7 +308,6 @@ MainWindow::MainWindow(QWidget *parent) : for(count = 0;hrtfModeList[count].name[0];count++) { } ui->hrtfmodeSlider->setRange(0, count-1); - ui->hrtfStateComboBox->adjustSize(); #if !defined(HAVE_NEON) && !defined(HAVE_SSE) ui->cpuExtDisabledLabel->move(ui->cpuExtDisabledLabel->x(), ui->cpuExtDisabledLabel->y() - 60); @@ -340,6 +349,12 @@ MainWindow::MainWindow(QWidget *parent) : #endif +#ifndef ALSOFT_EAX + ui->enableEaxCheck->setChecked(Qt::Unchecked); + ui->enableEaxCheck->setEnabled(false); + ui->enableEaxCheck->setVisible(false); +#endif + mPeriodSizeValidator = new QIntValidator{64, 8192, this}; ui->periodSizeEdit->setValidator(mPeriodSizeValidator); mPeriodCountValidator = new QIntValidator{2, 16, this}; @@ -365,11 +380,11 @@ MainWindow::MainWindow(QWidget *parent) : connect(ui->closeCancelButton, &QPushButton::clicked, this, &MainWindow::cancelCloseAction); connect(ui->applyButton, &QPushButton::clicked, this, &MainWindow::saveCurrentConfig); - auto qcb_cicstr = static_cast<void(QComboBox::*)(const QString&)>(&QComboBox::currentIndexChanged); - connect(ui->channelConfigCombo, qcb_cicstr, this, &MainWindow::enableApplyButton); - connect(ui->sampleFormatCombo, qcb_cicstr, this, &MainWindow::enableApplyButton); - connect(ui->stereoModeCombo, qcb_cicstr, this, &MainWindow::enableApplyButton); - connect(ui->sampleRateCombo, qcb_cicstr, this, &MainWindow::enableApplyButton); + auto qcb_cicint = static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged); + connect(ui->channelConfigCombo, qcb_cicint, this, &MainWindow::enableApplyButton); + connect(ui->sampleFormatCombo, qcb_cicint, this, &MainWindow::enableApplyButton); + connect(ui->stereoModeCombo, qcb_cicint, this, &MainWindow::enableApplyButton); + connect(ui->sampleRateCombo, qcb_cicint, this, &MainWindow::enableApplyButton); connect(ui->sampleRateCombo, &QComboBox::editTextChanged, this, &MainWindow::enableApplyButton); connect(ui->resamplerSlider, &QSlider::valueChanged, this, &MainWindow::updateResamplerLabel); @@ -379,8 +394,8 @@ MainWindow::MainWindow(QWidget *parent) : connect(ui->periodCountSlider, &QSlider::valueChanged, this, &MainWindow::updatePeriodCountEdit); connect(ui->periodCountEdit, &QLineEdit::editingFinished, this, &MainWindow::updatePeriodCountSlider); - connect(ui->stereoEncodingComboBox, qcb_cicstr, this, &MainWindow::enableApplyButton); - connect(ui->ambiFormatComboBox, qcb_cicstr, this, &MainWindow::enableApplyButton); + connect(ui->stereoEncodingComboBox, qcb_cicint, this, &MainWindow::enableApplyButton); + connect(ui->ambiFormatComboBox, qcb_cicint, this, &MainWindow::enableApplyButton); connect(ui->outputLimiterCheckBox, &QCheckBox::stateChanged, this, &MainWindow::enableApplyButton); connect(ui->outputDitherCheckBox, &QCheckBox::stateChanged, this, &MainWindow::enableApplyButton); @@ -388,7 +403,7 @@ MainWindow::MainWindow(QWidget *parent) : connect(ui->decoderDistCompCheckBox, &QCheckBox::stateChanged, this, &MainWindow::enableApplyButton); connect(ui->decoderNFEffectsCheckBox, &QCheckBox::stateChanged, this, &MainWindow::enableApplyButton); auto qdsb_vcd = static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged); - connect(ui->decoderNFRefDelaySpinBox, qdsb_vcd, this, &MainWindow::enableApplyButton); + connect(ui->decoderSpeakerDistSpinBox, qdsb_vcd, this, &MainWindow::enableApplyButton); connect(ui->decoderQuadLineEdit, &QLineEdit::textChanged, this, &MainWindow::enableApplyButton); connect(ui->decoderQuadButton, &QPushButton::clicked, this, &MainWindow::selectQuadDecoderFile); connect(ui->decoder51LineEdit, &QLineEdit::textChanged, this, &MainWindow::enableApplyButton); @@ -397,9 +412,10 @@ MainWindow::MainWindow(QWidget *parent) : connect(ui->decoder61Button, &QPushButton::clicked, this, &MainWindow::select61DecoderFile); connect(ui->decoder71LineEdit, &QLineEdit::textChanged, this, &MainWindow::enableApplyButton); connect(ui->decoder71Button, &QPushButton::clicked, this, &MainWindow::select71DecoderFile); + connect(ui->decoder3D71LineEdit, &QLineEdit::textChanged, this, &MainWindow::enableApplyButton); + connect(ui->decoder3D71Button, &QPushButton::clicked, this, &MainWindow::select3D71DecoderFile); - connect(ui->preferredHrtfComboBox, qcb_cicstr, this, &MainWindow::enableApplyButton); - connect(ui->hrtfStateComboBox, qcb_cicstr, this, &MainWindow::enableApplyButton); + connect(ui->preferredHrtfComboBox, qcb_cicint, this, &MainWindow::enableApplyButton); connect(ui->hrtfmodeSlider, &QSlider::valueChanged, this, &MainWindow::updateHrtfModeLabel); connect(ui->hrtfAddButton, &QPushButton::clicked, this, &MainWindow::addHrtfFile); @@ -424,7 +440,7 @@ MainWindow::MainWindow(QWidget *parent) : connect(ui->disabledBackendList, &QListWidget::customContextMenuRequested, this, &MainWindow::showDisabledBackendMenu); connect(ui->backendCheckBox, &QCheckBox::stateChanged, this, &MainWindow::enableApplyButton); - connect(ui->defaultReverbComboBox, qcb_cicstr, this, &MainWindow::enableApplyButton); + connect(ui->defaultReverbComboBox, qcb_cicint, this, &MainWindow::enableApplyButton); connect(ui->enableEaxReverbCheck, &QCheckBox::stateChanged, this, &MainWindow::enableApplyButton); connect(ui->enableStdReverbCheck, &QCheckBox::stateChanged, this, &MainWindow::enableApplyButton); connect(ui->enableAutowahCheck, &QCheckBox::stateChanged, this, &MainWindow::enableApplyButton); @@ -439,13 +455,21 @@ MainWindow::MainWindow(QWidget *parent) : connect(ui->enableDedicatedCheck, &QCheckBox::stateChanged, this, &MainWindow::enableApplyButton); connect(ui->enablePitchShifterCheck, &QCheckBox::stateChanged, this, &MainWindow::enableApplyButton); connect(ui->enableVocalMorpherCheck, &QCheckBox::stateChanged, this, &MainWindow::enableApplyButton); + connect(ui->enableEaxCheck, &QCheckBox::stateChanged, this, &MainWindow::enableApplyButton); connect(ui->pulseAutospawnCheckBox, &QCheckBox::stateChanged, this, &MainWindow::enableApplyButton); connect(ui->pulseAllowMovesCheckBox, &QCheckBox::stateChanged, this, &MainWindow::enableApplyButton); connect(ui->pulseFixRateCheckBox, &QCheckBox::stateChanged, this, &MainWindow::enableApplyButton); connect(ui->pulseAdjLatencyCheckBox, &QCheckBox::stateChanged, this, &MainWindow::enableApplyButton); + connect(ui->pwireAssumeAudioCheckBox, &QCheckBox::stateChanged, this, &MainWindow::enableApplyButton); + connect(ui->pwireRtMixCheckBox, &QCheckBox::stateChanged, this, &MainWindow::enableApplyButton); + + connect(ui->wasapiResamplerCheckBox, &QCheckBox::stateChanged, this, &MainWindow::enableApplyButton); + connect(ui->jackAutospawnCheckBox, &QCheckBox::stateChanged, this, &MainWindow::enableApplyButton); + connect(ui->jackConnectPortsCheckBox, &QCheckBox::stateChanged, this, &MainWindow::enableApplyButton); + connect(ui->jackRtMixCheckBox, &QCheckBox::stateChanged, this, &MainWindow::enableApplyButton); connect(ui->jackBufferSizeSlider, &QSlider::valueChanged, this, &MainWindow::updateJackBufferSizeEdit); connect(ui->jackBufferSizeLine, &QLineEdit::editingFinished, this, &MainWindow::updateJackBufferSizeSlider); @@ -474,10 +498,9 @@ MainWindow::MainWindow(QWidget *parent) : for(int i = 0;backendList[i].backend_name[0];i++) { QList<QListWidgetItem*> items = ui->backendListWidget->findItems( - backendList[i].full_string, Qt::MatchFixedString - ); - foreach(const QListWidgetItem *item, items) - ui->backendListWidget->setItemHidden(item, false); + backendList[i].full_string, Qt::MatchFixedString); + foreach(QListWidgetItem *item, items) + item->setHidden(false); } loadConfig(getDefaultConfigName()); @@ -601,8 +624,7 @@ QStringList MainWindow::collectHrtfs() } #ifdef ALSOFT_EMBED_HRTF_DATA - ret.push_back("Built-In 44100hz"); - ret.push_back("Built-In 48000hz"); + ret.push_back("Built-In HRTF"); #endif } return ret; @@ -636,6 +658,8 @@ void MainWindow::loadConfig(const QString &fname) ui->channelConfigCombo->setCurrentIndex(0); if(channelconfig.isEmpty() == false) { + if(channelconfig == "surround51rear") + channelconfig = "surround51"; QString str{getNameFromValue(speakerModeList, channelconfig)}; if(!str.isEmpty()) { @@ -736,17 +760,17 @@ void MainWindow::loadConfig(const QString &fname) } } - bool hqmode{settings.value("decoder/hq-mode", true).toBool()}; - ui->decoderHQModeCheckBox->setChecked(hqmode); + ui->decoderHQModeCheckBox->setChecked(getCheckState(settings.value("decoder/hq-mode"))); 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); + double speakerdist{settings.value("decoder/speaker-dist", 1.0).toDouble()}; + ui->decoderSpeakerDistSpinBox->setValue(speakerdist); ui->decoderQuadLineEdit->setText(settings.value("decoder/quad").toString()); ui->decoder51LineEdit->setText(settings.value("decoder/surround51").toString()); ui->decoder61LineEdit->setText(settings.value("decoder/surround61").toString()); ui->decoder71LineEdit->setText(settings.value("decoder/surround71").toString()); + ui->decoder3D71LineEdit->setText(settings.value("decoder/surround3d71").toString()); QStringList disabledCpuExts{settings.value("disable-cpu-exts").toStringList()}; if(disabledCpuExts.size() == 1) @@ -761,11 +785,9 @@ void MainWindow::loadConfig(const QString &fname) QString hrtfmode{settings.value("hrtf-mode").toString().trimmed()}; ui->hrtfmodeSlider->setValue(2); - ui->hrtfmodeLabel->setText(hrtfModeList[2].name); - /* The "basic" mode name is no longer supported, and "ambi3" is temporarily - * disabled. Use "ambi2" instead. - */ - if(hrtfmode == "basic" || hrtfmode == "ambi3") + ui->hrtfmodeLabel->setText(hrtfModeList[3].name); + /* The "basic" mode name is no longer supported. Use "ambi2" instead. */ + if(hrtfmode == "basic") hrtfmode = "ambi2"; for(int i = 0;hrtfModeList[i].name[0];i++) { @@ -794,14 +816,6 @@ void MainWindow::loadConfig(const QString &fname) ui->hrtfFileList->addItems(hrtf_paths); 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()) @@ -830,7 +844,7 @@ void MainWindow::loadConfig(const QString &fname) ui->enabledBackendList->clear(); ui->disabledBackendList->clear(); QStringList drivers{settings.value("drivers").toStringList()}; - if(drivers.size() == 0) + if(drivers.empty()) ui->backendCheckBox->setChecked(true); else { @@ -912,13 +926,22 @@ void MainWindow::loadConfig(const QString &fname) ui->enableDedicatedCheck->setChecked(!excludefx.contains("dedicated", Qt::CaseInsensitive)); ui->enablePitchShifterCheck->setChecked(!excludefx.contains("pshifter", Qt::CaseInsensitive)); ui->enableVocalMorpherCheck->setChecked(!excludefx.contains("vmorpher", Qt::CaseInsensitive)); + if(ui->enableEaxCheck->isEnabled()) + ui->enableEaxCheck->setChecked(getCheckState(settings.value("eax/enable")) != Qt::Unchecked); 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->pwireAssumeAudioCheckBox->setCheckState(getCheckState(settings.value("pipewire/assume-audio"))); + ui->pwireRtMixCheckBox->setCheckState(getCheckState(settings.value("pipewire/rt-mix"))); + + ui->wasapiResamplerCheckBox->setCheckState(getCheckState(settings.value("wasapi/allow-resampler"))); + ui->jackAutospawnCheckBox->setCheckState(getCheckState(settings.value("jack/spawn-server"))); + ui->jackConnectPortsCheckBox->setCheckState(getCheckState(settings.value("jack/connect-ports"))); + ui->jackRtMixCheckBox->setCheckState(getCheckState(settings.value("jack/rt-mix"))); ui->jackBufferSizeLine->setText(settings.value("jack/buffer-size", QString()).toString()); updateJackBufferSizeSlider(); @@ -998,20 +1021,19 @@ void MainWindow::saveConfig(const QString &fname) const 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/hq-mode", getCheckValue(ui->decoderHQModeCheckBox)); 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{} + double speakerdist{ui->decoderSpeakerDistSpinBox->value()}; + settings.setValue("decoder/speaker-dist", + (speakerdist != 1.0) ? QString::number(speakerdist) : QString{} ); settings.setValue("decoder/quad", ui->decoderQuadLineEdit->text()); settings.setValue("decoder/surround51", ui->decoder51LineEdit->text()); settings.setValue("decoder/surround61", ui->decoder61LineEdit->text()); settings.setValue("decoder/surround71", ui->decoder71LineEdit->text()); + settings.setValue("decoder/surround3d71", ui->decoder3D71LineEdit->text()); QStringList strlist; if(!ui->enableSSECheckBox->isChecked()) @@ -1028,13 +1050,6 @@ void MainWindow::saveConfig(const QString &fname) const settings.setValue("hrtf-mode", hrtfModeList[ui->hrtfmodeSlider->value()].value); - if(ui->hrtfStateComboBox->currentIndex() == 1) - settings.setValue("hrtf", "true"); - else if(ui->hrtfStateComboBox->currentIndex() == 2) - settings.setValue("hrtf", "false"); - else - settings.setValue("hrtf", QString{}); - if(ui->preferredHrtfComboBox->currentIndex() == 0) settings.setValue("default-hrtf", QString{}); else @@ -1076,7 +1091,7 @@ void MainWindow::saveConfig(const QString &fname) const } } } - if(strlist.size() == 0 && !ui->backendCheckBox->isChecked()) + if(strlist.empty() && !ui->backendCheckBox->isChecked()) strlist.append("-all"); else if(ui->backendCheckBox->isChecked()) strlist.append(QString{}); @@ -1121,6 +1136,14 @@ void MainWindow::saveConfig(const QString &fname) const if(!ui->enableVocalMorpherCheck->isChecked()) strlist.append("vmorpher"); settings.setValue("excludefx", strlist.join(QChar{','})); + settings.setValue("eax/enable", + (!ui->enableEaxCheck->isEnabled() || ui->enableEaxCheck->isChecked()) + ? QString{/*"true"*/} : QString{"false"}); + + settings.setValue("pipewire/assume-audio", getCheckValue(ui->pwireAssumeAudioCheckBox)); + settings.setValue("pipewire/rt-mix", getCheckValue(ui->pwireRtMixCheckBox)); + + settings.setValue("wasapi/allow-resampler", getCheckValue(ui->wasapiResamplerCheckBox)); settings.setValue("pulse/spawn-server", getCheckValue(ui->pulseAutospawnCheckBox)); settings.setValue("pulse/allow-moves", getCheckValue(ui->pulseAllowMovesCheckBox)); @@ -1128,6 +1151,8 @@ void MainWindow::saveConfig(const QString &fname) const settings.setValue("pulse/adjust-latency", getCheckValue(ui->pulseAdjLatencyCheckBox)); settings.setValue("jack/spawn-server", getCheckValue(ui->jackAutospawnCheckBox)); + settings.setValue("jack/connect-ports", getCheckValue(ui->jackConnectPortsCheckBox)); + settings.setValue("jack/rt-mix", getCheckValue(ui->jackRtMixCheckBox)); settings.setValue("jack/buffer-size", ui->jackBufferSizeLine->text()); settings.setValue("alsa/device", ui->alsaDefaultDeviceLine->text()); @@ -1222,6 +1247,8 @@ void MainWindow::select61DecoderFile() { selectDecoderFile(ui->decoder61LineEdit, "Select 6.1 Surround Decoder");} void MainWindow::select71DecoderFile() { selectDecoderFile(ui->decoder71LineEdit, "Select 7.1 Surround Decoder");} +void MainWindow::select3D71DecoderFile() +{ selectDecoderFile(ui->decoder3D71LineEdit, "Select 3D7.1 Surround Decoder");} void MainWindow::selectDecoderFile(QLineEdit *line, const char *caption) { QString dir{line->text()}; @@ -1295,7 +1322,7 @@ void MainWindow::removeHrtfFile() void MainWindow::updateHrtfRemoveButton() { - ui->hrtfRemoveButton->setEnabled(ui->hrtfFileList->selectedItems().size() != 0); + ui->hrtfRemoveButton->setEnabled(!ui->hrtfFileList->selectedItems().empty()); } void MainWindow::showEnabledBackendMenu(QPoint pt) @@ -1306,7 +1333,7 @@ void MainWindow::showEnabledBackendMenu(QPoint pt) QMenu ctxmenu; QAction *removeAction{ctxmenu.addAction(QIcon::fromTheme("list-remove"), "Remove")}; - if(ui->enabledBackendList->selectedItems().size() == 0) + if(ui->enabledBackendList->selectedItems().empty()) removeAction->setEnabled(false); ctxmenu.addSeparator(); for(size_t i = 0;backendList[i].backend_name[0];i++) @@ -1314,8 +1341,8 @@ void MainWindow::showEnabledBackendMenu(QPoint pt) QString backend{backendList[i].full_string}; QAction *action{ctxmenu.addAction(QString("Add ")+backend)}; actionMap[action] = backend; - if(ui->enabledBackendList->findItems(backend, Qt::MatchFixedString).size() != 0 || - ui->disabledBackendList->findItems(backend, Qt::MatchFixedString).size() != 0) + if(!ui->enabledBackendList->findItems(backend, Qt::MatchFixedString).empty() || + !ui->disabledBackendList->findItems(backend, Qt::MatchFixedString).empty()) action->setEnabled(false); } @@ -1344,7 +1371,7 @@ void MainWindow::showDisabledBackendMenu(QPoint pt) QMenu ctxmenu; QAction *removeAction{ctxmenu.addAction(QIcon::fromTheme("list-remove"), "Remove")}; - if(ui->disabledBackendList->selectedItems().size() == 0) + if(ui->disabledBackendList->selectedItems().empty()) removeAction->setEnabled(false); ctxmenu.addSeparator(); for(size_t i = 0;backendList[i].backend_name[0];i++) @@ -1352,8 +1379,8 @@ void MainWindow::showDisabledBackendMenu(QPoint pt) QString backend{backendList[i].full_string}; QAction *action{ctxmenu.addAction(QString("Add ")+backend)}; actionMap[action] = backend; - if(ui->disabledBackendList->findItems(backend, Qt::MatchFixedString).size() != 0 || - ui->enabledBackendList->findItems(backend, Qt::MatchFixedString).size() != 0) + if(!ui->disabledBackendList->findItems(backend, Qt::MatchFixedString).empty() || + !ui->enabledBackendList->findItems(backend, Qt::MatchFixedString).empty()) action->setEnabled(false); } |