From 65ddf05482ec54d9a88c24b93407bea13befb6b8 Mon Sep 17 00:00:00 2001 From: ronso0 Date: Sat, 24 Jul 2021 01:03:03 +0200 Subject: [PATCH 1/2] Pref > Key: fix loading of custom notation --- src/preferences/dialog/dlgprefkey.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/preferences/dialog/dlgprefkey.cpp b/src/preferences/dialog/dlgprefkey.cpp index 02bd789e665..b3491cc1498 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(); @@ -266,22 +269,17 @@ void DlgPrefKey::slotUpdate() { } void DlgPrefKey::setNotationCustom(bool active) { - if (!active) { - return; - } - - for (auto it = m_keyLineEdits.constBegin(); - it != m_keyLineEdits.constEnd(); ++it) { - it.value()->setEnabled(true); + if (active) { + setNotation(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); + // QLineEdits are only enabled for Custom notation. + it.value()->setEnabled(notation == KeyUtils::KeyNotation::Custom); } slotUpdate(); } From 761487c0283b441a6d1cb2cb76d1806a3fd6aaa7 Mon Sep 17 00:00:00 2001 From: ronso0 Date: Sat, 24 Jul 2021 01:05:50 +0200 Subject: [PATCH 2/2] DlgfPrefKey: move setNotationCustom --- src/preferences/dialog/dlgprefkey.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/preferences/dialog/dlgprefkey.cpp b/src/preferences/dialog/dlgprefkey.cpp index b3491cc1498..f61c9b0c70c 100644 --- a/src/preferences/dialog/dlgprefkey.cpp +++ b/src/preferences/dialog/dlgprefkey.cpp @@ -268,12 +268,6 @@ void DlgPrefKey::slotUpdate() { } } -void DlgPrefKey::setNotationCustom(bool active) { - if (active) { - setNotation(KeyUtils::KeyNotation::Custom); - } -} - void DlgPrefKey::setNotation(KeyUtils::KeyNotation notation) { for (auto it = m_keyLineEdits.constBegin(); it != m_keyLineEdits.constEnd(); ++it) { @@ -284,6 +278,12 @@ void DlgPrefKey::setNotation(KeyUtils::KeyNotation notation) { slotUpdate(); } +void DlgPrefKey::setNotationCustom(bool active) { + if (active) { + setNotation(KeyUtils::KeyNotation::Custom); + } +} + void DlgPrefKey::setNotationTraditional(bool active) { if (active) { setNotation(KeyUtils::KeyNotation::Traditional);