comparison libgui/src/shortcuts-tree-widget.cc @ 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
comparison
equal deleted inserted replaced
33414:ec8b3c32effa 33415:370a2de931a0
288 // the settings key to separate the section from the shortcut name. 288 // the settings key to separate the section from the shortcut name.
289 289
290 // Note that m_settings_key doesn't begin with the sc_group prefix. 290 // Note that m_settings_key doesn't begin with the sc_group prefix.
291 291
292 QString my_section = get_shortcut_section (m_settings_key); 292 QString my_section = get_shortcut_section (m_settings_key);
293 if (my_section.contains ('_')) // get top level section
294 my_section = my_section.section ('_', 0, 0, QString::SectionSkipEmpty);
295
293 QString actual_text = m_edit_actual->text (); 296 QString actual_text = m_edit_actual->text ();
294 297
295 bool conflict = false; 298 bool conflict = false;
296 QString other_settings_key; 299 QString other_settings_key;
297 300
298 gui_settings settings; 301 gui_settings settings;
299 302
300 settings.beginGroup (sc_group); 303 settings.beginGroup (sc_group);
301 const QStringList shortcut_settings_keys = settings.allKeys (); 304 const QStringList shortcut_settings_keys = all_shortcut_preferences::keys ();
302 settings.endGroup (); 305 settings.endGroup ();
303 306
304 for (const auto& settings_key : shortcut_settings_keys) 307 for (const auto& settings_key : shortcut_settings_keys)
305 { 308 {
306 if (settings_key == m_settings_key) 309 if (settings_key == m_settings_key)
307 continue; 310 continue;
308 311
309 QString section = get_shortcut_section (settings_key); 312 QString section = get_shortcut_section (settings_key);
310 313 if (section.contains ('_')) // get top level section
311 if (section == my_section || section.startsWith ("main_")) 314 section = section.section ('_', 0, 0, QString::SectionSkipEmpty);
315
316 if (section == my_section || section == "main")
312 { 317 {
313 QString shortcut_text 318 const sc_pref scpref = all_shortcut_preferences::value (settings_key);
314 = settings.value (sc_group + "/" + settings_key).toString (); 319 QString shortcut_text = settings.sc_value (scpref);
320
321 if (shortcut_text.isEmpty ())
322 continue;
315 323
316 if (shortcut_text == actual_text) 324 if (shortcut_text == actual_text)
317 { 325 {
318 other_settings_key = settings_key; 326 other_settings_key = settings_key;
319 conflict = true; 327 conflict = true;