]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/components/preferences_widgets.cpp
Qt4 - Hotkeys Preferences: * Create the QLabel warning only if needed,
[vlc] / modules / gui / qt4 / components / preferences_widgets.cpp
index 466597d87bed08a7a7bf46e563a976f7e45cf918..59bac28d521dd2747abd28977545464830ee6ac8 100644 (file)
@@ -1039,7 +1039,7 @@ void KeySelectorControl::finish()
         module_config_t *p_item = p_main->p_config + i;
 
         if( p_item->i_type & CONFIG_ITEM && p_item->psz_name &&
-            strstr( p_item->psz_name , "key-" ) )
+            strstr( p_item->psz_name , "key-" ) && !EMPTY_STR( p_item->psz_text ) )
         {
             QTreeWidgetItem *treeItem = new QTreeWidgetItem();
             treeItem->setText( 0, qtr( p_item->psz_text ) );
@@ -1124,19 +1124,18 @@ KeyInputDialog::KeyInputDialog( QList<module_config_t*>& _values,
 
     setWindowTitle( qtr( "Hotkey for " ) + qfu( keyToChange)  );
 
-    QVBoxLayout *l = new QVBoxLayout( this );
-    selected = new QLabel( qtr("Press the new keys for ")  + qfu(keyToChange) );
-    warning = new QLabel();
-    l->addWidget( selected , Qt::AlignCenter );
-    l->addWidget( warning, Qt::AlignCenter );
+    vLayout = new QVBoxLayout( this );
+    selected = new QLabel( qtr("Press the new keys for ") + qfu( keyToChange ) );
+    vLayout->addWidget( selected , Qt::AlignCenter );
 
-    QDialogButtonBox *buttonBox = new QDialogButtonBox;
+    buttonBox = new QDialogButtonBox;
     QPushButton *ok = new QPushButton( qtr("OK") );
     QPushButton *cancel = new QPushButton( qtr("Cancel") );
     buttonBox->addButton( ok, QDialogButtonBox::AcceptRole );
     buttonBox->addButton( cancel, QDialogButtonBox::RejectRole );
 
-    l->addWidget( buttonBox );
+    vLayout->addWidget( buttonBox );
+    buttonBox->hide();
 
     CONNECT( buttonBox, accepted(), this, accept() );
     CONNECT( buttonBox, rejected(), this, reject() );
@@ -1146,6 +1145,7 @@ void KeyInputDialog::checkForConflicts( int i_vlckey )
 {
     conflicts = false;
     module_config_t *p_current = NULL;
+    /* Search for conflicts */
     foreach( p_current, values )
     {
         if( p_current->value.i == i_vlckey && strcmp( p_current->psz_text,
@@ -1155,13 +1155,17 @@ void KeyInputDialog::checkForConflicts( int i_vlckey )
             break;
         }
     }
+
     if( conflicts )
     {
-        warning->setText(
+        QLabel *warning = new QLabel(
           qtr("Warning: the  key is already assigned to \"") +
-          QString( p_current->psz_text ) + "\"" );
+          qfu( p_current->psz_text ) + "\"" );
+        warning->setWordWrap( true );
+        vLayout->insertWidget( 1, warning );
+        buttonBox->show();
     }
-    else warning->setText( "" );
+    else accept();
 }
 
 void KeyInputDialog::keyPressEvent( QKeyEvent *e )