Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preferences > Key: restore custom notation #4136

Merged
merged 2 commits into from
Jul 27, 2021
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
26 changes: 12 additions & 14 deletions src/preferences/dialog/dlgprefkey.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ void DlgPrefKey::loadSettings() {
QMap<mixxx::track::io::key::ChromaticKey, QString> notation;
if (notation_name == KEY_NOTATION_CUSTOM) {
radioNotationCustom->setChecked(true);
// Read the custom notation from the config and store it in a temp QMap
for (auto it = m_keyLineEdits.constBegin();
it != m_keyLineEdits.constEnd(); ++it) {
it.value()->setText(m_keySettings.getCustomKeyNotation(it.key()));
notation[it.key()] = it.value()->text();
}
setNotationCustom(true);
notation_type = KeyUtils::KeyNotation::Custom;
} else {
if (notation_name == KEY_NOTATION_LANCELOT) {
Expand All @@ -128,8 +128,11 @@ void DlgPrefKey::loadSettings() {
}
}

setNotation(notation_type);
// Store notation map for later recall...
KeyUtils::setNotation(notation);
uklotzde marked this conversation as resolved.
Show resolved Hide resolved
// ... BEFORE invoking setNotation() which populates the QLineEdits from
// the map retrieved from KeyUtils.
setNotation(notation_type);
m_pKeyNotation->set(static_cast<double>(notation_type));

slotUpdate();
Expand Down Expand Up @@ -265,25 +268,20 @@ void DlgPrefKey::slotUpdate() {
}
}

void DlgPrefKey::setNotationCustom(bool active) {
if (!active) {
return;
}

void DlgPrefKey::setNotation(KeyUtils::KeyNotation notation) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The whole class and especially these methods are not so great. But at least the handling is consistent now.

for (auto it = m_keyLineEdits.constBegin();
it != m_keyLineEdits.constEnd(); ++it) {
it.value()->setEnabled(true);
it.value()->setText(KeyUtils::keyToString(it.key(), notation));
// QLineEdits are only enabled for Custom notation.
it.value()->setEnabled(notation == KeyUtils::KeyNotation::Custom);
}
slotUpdate();
}

void DlgPrefKey::setNotation(KeyUtils::KeyNotation notation) {
for (auto it = m_keyLineEdits.constBegin();
it != m_keyLineEdits.constEnd(); ++it) {
it.value()->setText(KeyUtils::keyToString(it.key(), notation));
it.value()->setEnabled(false);
void DlgPrefKey::setNotationCustom(bool active) {
if (active) {
setNotation(KeyUtils::KeyNotation::Custom);
}
slotUpdate();
}

void DlgPrefKey::setNotationTraditional(bool active) {
Expand Down