]> git.sesse.net Git - vlc/commitdiff
Qt4 - Hotkeys Preferences: * Create the QLabel warning only if needed,
authorJean-Baptiste Kempf <jb@videolan.org>
Tue, 6 Nov 2007 02:25:30 +0000 (02:25 +0000)
committerJean-Baptiste Kempf <jb@videolan.org>
Tue, 6 Nov 2007 02:25:30 +0000 (02:25 +0000)
                           * Fix the "empty value, empty text" key bug.

modules/gui/qt4/components/preferences_widgets.cpp
modules/gui/qt4/components/preferences_widgets.hpp

index be376ee19ec9d83e25610f0cecb3ec00c1f74c76..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,11 +1124,9 @@ 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 );
 
     buttonBox = new QDialogButtonBox;
     QPushButton *ok = new QPushButton( qtr("OK") );
@@ -1136,7 +1134,7 @@ KeyInputDialog::KeyInputDialog( QList<module_config_t*>& _values,
     buttonBox->addButton( ok, QDialogButtonBox::AcceptRole );
     buttonBox->addButton( cancel, QDialogButtonBox::RejectRole );
 
-    l->addWidget( buttonBox );
+    vLayout->addWidget( buttonBox );
     buttonBox->hide();
 
     CONNECT( buttonBox, accepted(), this, accept() );
@@ -1160,10 +1158,12 @@ void KeyInputDialog::checkForConflicts( int i_vlckey )
 
     if( conflicts )
     {
-        warning->setText(
+        QLabel *warning = new QLabel(
           qtr("Warning: the  key is already assigned to \"") +
           qfu( p_current->psz_text ) + "\"" );
-        buttonBox->hide();
+        warning->setWordWrap( true );
+        vLayout->insertWidget( 1, warning );
+        buttonBox->show();
     }
     else accept();
 }
index 1b9ff8173e7ed8e97f677c275598cc63b3c28c50..486909bb8cd536306fe40a5939a06d8dbb2ba65c 100644 (file)
@@ -51,6 +51,7 @@ class QTreeWidgetItem;
 class QGroupBox;
 class QGridLayout;
 class QDialogButtonBox;
+class QVBoxLayout;
 
 class ConfigControl : public QObject
 {
@@ -421,8 +422,8 @@ private:
     void keyPressEvent( QKeyEvent *);
     void wheelEvent( QWheelEvent *);
     QLabel *selected;
-    QLabel *warning;
-    const char * keyToChange;
+    QVBoxLayout *vLayout;
+    const char *keyToChange;
     QList<module_config_t*> values;
     QDialogButtonBox *buttonBox;
 };