diff --git a/src/preferences/dialog/dlgprefkey.cpp b/src/preferences/dialog/dlgprefkey.cpp index 02bd789e665..f61c9b0c70c 100644 --- a/src/preferences/dialog/dlgprefkey.cpp +++ b/src/preferences/dialog/dlgprefkey.cpp @@ -96,12 +96,12 @@ void DlgPrefKey::loadSettings() { QMap 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) { @@ -128,8 +128,11 @@ void DlgPrefKey::loadSettings() { } } - setNotation(notation_type); + // Store notation map for later recall... KeyUtils::setNotation(notation); + // ... BEFORE invoking setNotation() which populates the QLineEdits from + // the map retrieved from KeyUtils. + setNotation(notation_type); m_pKeyNotation->set(static_cast(notation_type)); slotUpdate(); @@ -265,25 +268,20 @@ void DlgPrefKey::slotUpdate() { } } -void DlgPrefKey::setNotationCustom(bool active) { - if (!active) { - return; - } - +void DlgPrefKey::setNotation(KeyUtils::KeyNotation notation) { 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) {