changeset 33415:370a2de931a0 stable

fix checking for duplicate shortcuts * shortcuts-tree-widget.cc (shortcut_edit_dialog::finished): use all_shortcut_preferences for list of all shortcuts, use sc_value for the used shortcuts including default values, check within top level sections
author Torsten Lilge <ttl-octave@mailbox.org>
date Tue, 16 Apr 2024 06:56:56 +0200
parents ec8b3c32effa
children 3cf213d5b479 3d37f529ee65
files libgui/src/shortcuts-tree-widget.cc
diffstat 1 files changed, 12 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/shortcuts-tree-widget.cc	Sun Apr 14 15:14:17 2024 +0200
+++ b/libgui/src/shortcuts-tree-widget.cc	Tue Apr 16 06:56:56 2024 +0200
@@ -290,6 +290,9 @@
  // Note that m_settings_key doesn't begin with the sc_group prefix.
 
   QString my_section = get_shortcut_section (m_settings_key);
+  if (my_section.contains ('_'))    // get top level section
+    my_section = my_section.section ('_', 0, 0, QString::SectionSkipEmpty);
+
   QString actual_text = m_edit_actual->text ();
 
   bool conflict = false;
@@ -298,7 +301,7 @@
   gui_settings settings;
 
   settings.beginGroup (sc_group);
-  const QStringList shortcut_settings_keys = settings.allKeys ();
+  const QStringList shortcut_settings_keys = all_shortcut_preferences::keys ();
   settings.endGroup ();
 
   for (const auto& settings_key : shortcut_settings_keys)
@@ -307,11 +310,16 @@
         continue;
 
       QString section = get_shortcut_section (settings_key);
+      if (section.contains ('_'))   // get top level section
+        section = section.section ('_', 0, 0, QString::SectionSkipEmpty);
 
-      if (section == my_section || section.startsWith ("main_"))
+      if (section == my_section || section == "main")
         {
-          QString shortcut_text
-            = settings.value (sc_group + "/" + settings_key).toString ();
+          const sc_pref scpref = all_shortcut_preferences::value (settings_key);
+          QString shortcut_text = settings.sc_value (scpref);
+
+          if (shortcut_text.isEmpty ())
+            continue;
 
           if (shortcut_text == actual_text)
             {