]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/components/preferences_widgets.cpp
Qt: ConfigControl: unify and fix visibility changes.
[vlc] / modules / gui / qt4 / components / preferences_widgets.cpp
index 4b00351487b02064dc009ef3c65f4f59af1e5db7..32e6bdd5d5de8d4f44f198db491de8569714a3b3 100644 (file)
@@ -39,6 +39,7 @@
 #include <vlc_keys.h>
 #include <vlc_intf_strings.h>
 #include <vlc_modules.h>
+#include <vlc_plugin.h>
 
 #include <QString>
 #include <QVariant>
@@ -219,6 +220,7 @@ StringConfigControl::StringConfigControl( vlc_object_t *_p_this,
 
     if( !l )
     {
+        widget = new QWidget( _parent );
         QHBoxLayout *layout = new QHBoxLayout();
         layout->addWidget( label, 0 ); layout->insertSpacing( 1, 10 );
         layout->addWidget( text, LAST_COLUMN );
@@ -243,6 +245,8 @@ StringConfigControl::StringConfigControl( vlc_object_t *_p_this,
     finish( );
 }
 
+int VStringConfigControl::getType() const { return CONFIG_ITEM_STRING; }
+
 void StringConfigControl::finish()
 {
     text->setText( qfu(p_item->value.psz) );
@@ -278,6 +282,7 @@ FileConfigControl::FileConfigControl( vlc_object_t *_p_this,
 
     if( !l )
     {
+        widget = new QWidget( _parent );
         QHBoxLayout *layout = new QHBoxLayout();
         layout->addWidget( label, 0 );
         layout->insertSpacing( 1, 10 );
@@ -373,6 +378,7 @@ FontConfigControl::FontConfigControl( vlc_object_t *_p_this,
     font->setCurrentFont( QFont( qfu( p_item->value.psz) ) );
     if( !_p_layout )
     {
+        widget = new QWidget( _parent );
         QHBoxLayout *layout = new QHBoxLayout();
         layout->addWidget( label, 0 );
         layout->addWidget( font, 1 );
@@ -421,6 +427,7 @@ StringListConfigControl::StringListConfigControl( vlc_object_t *_p_this,
     finish( p_module_config );
     if( !l )
     {
+        widget = new QWidget( _parent );
         l = new QGridLayout();
         l->addWidget( label, 0, 0 ); l->addWidget( combo, 0, LAST_COLUMN );
         widget->setLayout( l );
@@ -595,6 +602,7 @@ ModuleConfigControl::ModuleConfigControl( vlc_object_t *_p_this,
     finish( bycat );
     if( !l )
     {
+        widget = new QWidget( _parent );
         QHBoxLayout *layout = new QHBoxLayout();
         layout->addWidget( label ); layout->addWidget( combo, LAST_COLUMN );
         widget->setLayout( layout );
@@ -703,6 +711,7 @@ ModuleListConfigControl::ModuleListConfigControl( vlc_object_t *_p_this,
 
     if( !l )
     {
+        widget = new QWidget( _parent );
         QVBoxLayout *layout = new QVBoxLayout();
         layout->addWidget( groupBox, line, 0 );
         widget->setLayout( layout );
@@ -813,21 +822,14 @@ QString ModuleListConfigControl::getValue() const
     return text->text();
 }
 
-void ModuleListConfigControl::hide()
+void ModuleListConfigControl::changeVisibility( bool b )
 {
     foreach ( checkBoxListItem *it, modules )
-        it->checkBox->hide();
-    groupBox->hide();
+        it->checkBox->setVisible( b );
+    groupBox->setVisible( b );
+    ConfigControl::changeVisibility( b );
 }
 
-void ModuleListConfigControl::show()
-{
-    foreach ( checkBoxListItem *it, modules )
-        it->checkBox->show();
-    groupBox->show();
-}
-
-
 void ModuleListConfigControl::onUpdate()
 {
     text->clear();
@@ -875,6 +877,7 @@ IntegerConfigControl::IntegerConfigControl( vlc_object_t *_p_this,
 
     if( !l )
     {
+        widget = new QWidget( _parent );
         QHBoxLayout *layout = new QHBoxLayout();
         layout->addWidget( label, 0 ); layout->addWidget( spin, LAST_COLUMN );
         widget->setLayout( layout );
@@ -917,6 +920,8 @@ int IntegerConfigControl::getValue() const
     return spin->value();
 }
 
+int VIntConfigControl::getType() const { return CONFIG_ITEM_INTEGER; }
+
 /********* Integer range **********/
 IntegerRangeConfigControl::IntegerRangeConfigControl( vlc_object_t *_p_this,
                                             module_config_t *_p_item,
@@ -984,6 +989,7 @@ IntegerListConfigControl::IntegerListConfigControl( vlc_object_t *_p_this,
     finish( p_module_config );
     if( !l )
     {
+        widget = new QWidget( _parent );
         QHBoxLayout *layout = new QHBoxLayout();
         layout->addWidget( label ); layout->addWidget( combo, LAST_COLUMN );
         widget->setLayout( layout );
@@ -1101,6 +1107,7 @@ BoolConfigControl::BoolConfigControl( vlc_object_t *_p_this,
 
     if( !l )
     {
+        widget = new QWidget( _parent );
         QHBoxLayout *layout = new QHBoxLayout();
         layout->addWidget( checkbox, 0 );
         widget->setLayout( layout );
@@ -1122,6 +1129,8 @@ BoolConfigControl::BoolConfigControl( vlc_object_t *_p_this,
     finish();
 }
 
+int BoolConfigControl::getType() const { return CONFIG_ITEM_BOOL; }
+
 void BoolConfigControl::finish()
 {
     checkbox->setChecked( p_item->value.i );
@@ -1147,6 +1156,7 @@ ColorConfigControl::ColorConfigControl( vlc_object_t *_p_this,
 
     if( !l )
     {
+        widget = new QWidget( _parent );
         QHBoxLayout *layout = new QHBoxLayout();
         layout->addWidget( label, 0 ); layout->addWidget( color_but, LAST_COLUMN );
         widget->setLayout( layout );
@@ -1231,6 +1241,7 @@ FloatConfigControl::FloatConfigControl( vlc_object_t *_p_this,
 
     if( !l )
     {
+        widget = new QWidget( _parent );
         QHBoxLayout *layout = new QHBoxLayout();
         layout->addWidget( label, 0 ); layout->addWidget( spin, LAST_COLUMN );
         widget->setLayout( layout );
@@ -1242,6 +1253,8 @@ FloatConfigControl::FloatConfigControl( vlc_object_t *_p_this,
     }
 }
 
+int VFloatConfigControl::getType() const { return CONFIG_ITEM_FLOAT; }
+
 FloatConfigControl::FloatConfigControl( vlc_object_t *_p_this,
                                         module_config_t *_p_item,
                                         QLabel *_label,
@@ -1315,7 +1328,8 @@ KeySelectorControl::KeySelectorControl( vlc_object_t *_p_this,
     QGridLayout *gLayout = new QGridLayout( keyContainer );
 
     label = new QLabel(
-        qtr( "Select or double click an action to change the associated hotkey") );
+        qtr( "Select or double click an action to change the associated "
+             "hotkey. Use delete key to remove hotkeys") );
 
     QLabel *searchLabel = new QLabel( qtr( "Search" ) );
     SearchLineEdit *actionSearch = new SearchLineEdit( keyContainer );
@@ -1345,6 +1359,8 @@ KeySelectorControl::KeySelectorControl( vlc_object_t *_p_this,
              this, filter( const QString& ) );
 }
 
+int KeySelectorControl::getType() const { return CONFIG_ITEM_KEY; }
+
 void KeySelectorControl::finish()
 {
     if( label && p_item->psz_longtext )
@@ -1521,8 +1537,11 @@ bool KeySelectorControl::eventFilter( QObject *obj, QEvent *e )
     }
     else if( keyEv->key() == Qt::Key_Delete )
     {
-        aTable->currentItem()->setText( aTable->currentColumn(), NULL );
-        aTable->currentItem()->setData( aTable->currentColumn(), Qt::UserRole, QVariant() );
+        if( aTable->currentColumn() != 0 )
+        {
+            aTable->currentItem()->setText( aTable->currentColumn(), NULL );
+            aTable->currentItem()->setData( aTable->currentColumn(), Qt::UserRole, QVariant() );
+        }
         return true;
     }
     else
@@ -1613,4 +1632,3 @@ void KeyInputDialog::wheelEvent( QWheelEvent *e )
     checkForConflicts( i_vlck );
     keyValue = i_vlck;
 }
-