Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions src/controllers/dlgprefcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
#include "util/string.h"

namespace {

constexpr int kNoMappingIndex = 0; // "No Mapping" is always at the first position;

const QString kMappingExt(".midi.xml");

QString mappingNameToPath(const QString& directory, const QString& mappingName) {
Expand Down Expand Up @@ -459,17 +462,19 @@ void DlgPrefController::enumerateMappings(const QString& selectedMappingPath) {
}

// Preselect configured or matching mapping
int index = -1;
int index = kNoMappingIndex;
if (!selectedMappingPath.isEmpty()) {
index = m_ui.comboBoxMapping->findData(selectedMappingPath);
} else if (match.isValid()) {
index = m_ui.comboBoxMapping->findText(match.getName());
}
QString newMappingFilePath = mappingFilePathFromIndex(index);
if (index == -1) {
QString newMappingFilePath;
if (index <= kNoMappingIndex) { // findData() returns -1 for not found
index = kNoMappingIndex;
m_ui.chkEnabledDevice->setEnabled(false);
m_ui.groupBoxSettings->setVisible(false);
} else {
newMappingFilePath = mappingFilePathFromIndex(index);
m_ui.comboBoxMapping->setCurrentIndex(index);
m_ui.chkEnabledDevice->setEnabled(true);
}
Expand Down Expand Up @@ -506,8 +511,12 @@ MappingInfo DlgPrefController::enumerateMappingsFromEnumerator(
void DlgPrefController::slotUpdate() {
enumerateMappings(m_pControllerManager->getConfiguredMappingFileForDevice(
m_pController->getName()));
// Force updating the controller settings
slotMappingSelected(m_ui.comboBoxMapping->currentIndex());
// Note: this is called by closeDlg() when MIDI learning starts
// "No Mapping" is selected but we have a mapping for learning
if (m_ui.comboBoxMapping->currentIndex() > kNoMappingIndex || !m_pMapping) {
// Force updating the controller settings
slotMappingSelected(m_ui.comboBoxMapping->currentIndex());
}
Comment on lines +514 to +519
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!
I was puzzled what was calling showMapping() and that's it.


// enumerateMappings() calls slotMappingSelected() which will tick the 'Enabled'
// checkbox if there is a valid mapping saved in the mixxx.cfg file.
Expand Down Expand Up @@ -614,8 +623,7 @@ void DlgPrefController::enableWizardAndIOTabs(bool enable) {
}

QString DlgPrefController::mappingFilePathFromIndex(int index) const {
if (index == 0) {
// "No Mapping" item
if (index <= kNoMappingIndex) {
return QString();
}

Expand Down