]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/components/preferences_widgets.cpp
Qt: don't fire the Conflict dialog for "Unset" Keys
[vlc] / modules / gui / qt4 / components / preferences_widgets.cpp
index 1adcb1c81f6b002b52f685d80e1272467bf146bd..99963390d9998fbef92a975f8b90b9d7d68301b4 100644 (file)
@@ -1143,9 +1143,11 @@ KeySelectorControl::KeySelectorControl( vlc_object_t *_p_this,
     QLineEdit *actionSearch = new QLineEdit;*/
 
     table = new QTreeWidget;
-    table->setColumnCount(2);
+    table->setColumnCount(3);
     table->headerItem()->setText( 0, qtr( "Action" ) );
-    table->headerItem()->setText( 1, qtr( "Shortcut" ) );
+    table->headerItem()->setText( 1, qtr( "Hotkey" ) );
+    table->headerItem()->setText( 2, qtr( "Global" ) );
+    table->setAlternatingRowColors( true );
 
     shortcutValue = new KeyShortcutEdit;
     shortcutValue->setReadOnly(true);
@@ -1164,7 +1166,7 @@ KeySelectorControl::KeySelectorControl( vlc_object_t *_p_this,
     gLayout->addWidget( shortcutValue, 3, 1, 1, 2 );
     gLayout->addWidget( setButton, 3, 3, 1, 1 );
 
-    l->addWidget( keyContainer, line, 0, 1, 2 );
+    l->addWidget( keyContainer, line, 0, 1, -1 );
 
     CONNECT( clearButton, clicked(), shortcutValue, clear() );
     CONNECT( clearButton, clicked(), this, setTheKey() );
@@ -1177,8 +1179,6 @@ void KeySelectorControl::finish()
         label->setToolTip( formatTooltip( qtr( p_item->psz_longtext ) ) );
 
     /* Fill the table */
-    table->setColumnCount( 2 );
-    table->setAlternatingRowColors( true );
 
     /* Get the main Module */
     module_t *p_main = module_get_main();
@@ -1197,6 +1197,7 @@ void KeySelectorControl::finish()
         /* If we are a key option not empty */
         if( p_item->i_type & CONFIG_ITEM && p_item->psz_name
             && strstr( p_item->psz_name , "key-" )
+            && !strstr( p_item->psz_name , "global-key" )
             && !EMPTY_STR( p_item->psz_text ) )
         {
             /*
@@ -1213,6 +1214,21 @@ void KeySelectorControl::finish()
             treeItem->setText( 1, VLCKeyToString( p_item->value.i ) );
             treeItem->setData( 1, Qt::UserRole, QVariant( p_item->value.i ) );
             table->addTopLevelItem( treeItem );
+            continue;
+        }
+
+        if( p_item->i_type & CONFIG_ITEM && p_item->psz_name
+                && strstr( p_item->psz_name , "global-key" )
+                && !EMPTY_STR( p_item->psz_text ) )
+        {
+            QList<QTreeWidgetItem *> list =
+                table->findItems( qtr( p_item->psz_text ), Qt::MatchExactly );
+            if( list.count() > 1 )
+            {
+                list[0]->setText( 2, VLCKeyToString( p_item->value.i ) );
+                list[0]->setData( 2, Qt::UserRole,
+                                  QVariant( p_item->value.i ) );
+            }
         }
     }
     module_config_free (p_config);
@@ -1277,6 +1293,7 @@ void KeySelectorControl::selectKey( QTreeWidgetItem *keyItem )
 
 void KeySelectorControl::setTheKey()
 {
+    if( !table->currentItem() ) return;
     table->currentItem()->setText( 1, shortcutValue->text() );
     table->currentItem()->setData( 1, Qt::UserRole, shortcutValue->getValue() );
 }
@@ -1295,7 +1312,7 @@ void KeySelectorControl::doApply()
 }
 
 KeyInputDialog::KeyInputDialog( QTreeWidget *_table,
-                                QString keyToChange,
+                                const QString& keyToChange,
                                 QWidget *_parent ) :
                                 QDialog( _parent ), keyValue(0)
 {
@@ -1328,7 +1345,9 @@ void KeyInputDialog::checkForConflicts( int i_vlckey )
      QList<QTreeWidgetItem *> conflictList =
          table->findItems( VLCKeyToString( i_vlckey ), Qt::MatchExactly, 1 );
 
-    if( conflictList.size() )
+    if( conflictList.size() &&
+        conflictList[0]->data( 1, Qt::UserRole ).toInt() > 1 )
+        /* Avoid 0 or -1 that are the "Unset" states*/
     {
         QLabel *warning = new QLabel(
           qtr("Warning: the key is already assigned to \"") +