changeset 18630:a811d45b7ca7 gui-release

fix checking duplicates for a new shortcut * shortcut-manager.cc (init): add the widget name to the shortcut hash (shortcut_dialog_finished): add the widget name to the shortcut hash (enter_shortcut::keyPressEvent): allow entering shortcuts with function keys
author Torsten <ttl@justmail.de>
date Sun, 06 Apr 2014 10:38:52 +0200
parents a827fc5fe59d
children c7df983b003a
files libgui/src/shortcut-manager.cc
diffstat 1 files changed, 12 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/shortcut-manager.cc	Fri Apr 04 22:59:08 2014 +0200
+++ b/libgui/src/shortcut-manager.cc	Sun Apr 06 10:38:52 2014 +0200
@@ -135,6 +135,7 @@
 
   QKeySequence actual = QKeySequence (settings->value ("shortcuts/"+key, def_sc).toString ());
 
+  // append the new shortcut to the list
   shortcut_t shortcut_info;
   shortcut_info.description = description;
   shortcut_info.settings_key = key;
@@ -142,8 +143,10 @@
   shortcut_info.default_sc = def_sc;
   _sc << shortcut_info;
 
+  // insert shortcut prepended by widget in order check for duplicates later
+  QString widget = key.section ('_',0,0);  // get widget that uses the shortcut
   if (! actual.isEmpty ())
-    _shortcut_hash[actual] = _sc.count ();  // offset of 1 to avoid 0
+    _shortcut_hash[widget + ":" + actual.toString ()] = _sc.count ();  // offset of 1 to avoid 0
   _action_hash[key] = _sc.count ();  // offset of 1 to avoid 0
 }
 
@@ -333,7 +336,12 @@
   if (result == QDialog::Rejected)
     return;
 
-  int double_index = _shortcut_hash[_edit_actual->text()] - 1;
+  // check for duplicate
+
+  // get the widget for which this shortcut is defined
+  QString widget = _sc.at (_handled_index).settings_key.section ('_',0,0);
+  // and look
+  int double_index = _shortcut_hash[widget + ":" + _edit_actual->text()] - 1;
 
   if (double_index >= 0 && double_index != _handled_index)
     {
@@ -366,7 +374,7 @@
   _index_item_hash[_handled_index]->setText (2, shortcut.actual_sc);
 
   if (! shortcut.actual_sc.isEmpty ())
-    _shortcut_hash[shortcut.actual_sc] = _handled_index + 1; // index+1 to avoid 0
+    _shortcut_hash[widget + ":" + shortcut.actual_sc.toString ()] = _handled_index + 1;
 }
 
 void
@@ -408,7 +416,7 @@
     {
       int key = e->key ();
 
-      if (key == Qt::Key_unknown || key == 0 || key >= 16777248)
+      if (key == Qt::Key_unknown || key == 0)
         return;
 
       Qt::KeyboardModifiers modifiers = e->modifiers ();