]> git.sesse.net Git - vlc/commitdiff
Fixes to the v4l2 extended panel (works fine for multiple refreshes).
authorAntoine Cellerier <dionoea@videolan.org>
Sat, 8 Dec 2007 22:19:30 +0000 (22:19 +0000)
committerAntoine Cellerier <dionoea@videolan.org>
Sat, 8 Dec 2007 22:19:30 +0000 (22:19 +0000)
modules/gui/qt4/components/extended_panels.cpp
modules/gui/qt4/components/extended_panels.hpp
modules/gui/qt4/ui/v4l2.ui

index 70ddd3a42a8dce8f07a750b60d2305aa4de9f6ce..f933aa23673f9216fd356afcb964ab13fdbb3359 100644 (file)
@@ -568,23 +568,25 @@ ExtV4l2::ExtV4l2( intf_thread_t *_p_intf, QWidget *_parent )
 
     BUTTONACT( ui.refresh, Refresh() );
 
-    layout = new QVBoxLayout;
-    ui.vboxLayout->addLayout( layout );
-
-    help = new QLabel( qtr( "No v4l2 instance found. Press the refresh button to try again." ) );
-    layout->addWidget( help );
+    box = NULL;
 }
 
 ExtV4l2::~ExtV4l2()
 {
-    delete help;
-    delete layout;
+    if( box )
+        delete box;
 }
 
 void ExtV4l2::Refresh( void )
 {
     vlc_object_t *p_obj = (vlc_object_t*)vlc_object_find_name( p_intf, "v4l2", FIND_ANYWHERE );
-    help->hide();
+    ui.help->hide();
+    if( box )
+    {
+        ui.vboxLayout->removeWidget( box );
+        delete box;
+        box = NULL;
+    }
     if( p_obj )
     {
         msg_Dbg( p_intf, "Found v4l2 instance" );
@@ -593,10 +595,17 @@ void ExtV4l2::Refresh( void )
                                 &val, &text );
         if( i_ret < 0 )
         {
-            msg_Err( p_intf, "Oops" );
+            msg_Err( p_intf, "Oops, v4l2 object doesn't have a 'controls' variable." );
+            ui.help->show();
             vlc_object_release( p_obj );
             return;
         }
+
+        box = new QGroupBox( this );
+        ui.vboxLayout->addWidget( box );
+        QVBoxLayout *layout = new QVBoxLayout( box );
+        box->setLayout( layout );
+
         for( int i = 0; i < val.p_list->i_count; i++ )
         {
             const char *psz_var = text.p_list->p_values[i].psz_string;
@@ -610,13 +619,13 @@ void ExtV4l2::Refresh( void )
             {
                 case VLC_VAR_INTEGER:
                 {
-                    QLabel *label = new QLabel( psz_label );
-                    QHBoxLayout *hlayout = new QHBoxLayout;
+                    QLabel *label = new QLabel( psz_label, box );
+                    QHBoxLayout *hlayout = new QHBoxLayout( box );
                     hlayout->addWidget( label );
                     int i_val = var_GetInteger( p_obj, psz_var );
                     if( i_type & VLC_VAR_HASCHOICE )
                     {
-                        QComboBox *combobox = new QComboBox;
+                        QComboBox *combobox = new QComboBox( box );
                         combobox->setObjectName( psz_var );
 
                         vlc_value_t val2, text2;
@@ -639,7 +648,7 @@ void ExtV4l2::Refresh( void )
                     }
                     else
                     {
-                        QSlider *slider = new QSlider;
+                        QSlider *slider = new QSlider( box );
                         slider->setObjectName( psz_var );
                         slider->setOrientation( Qt::Horizontal );
                         vlc_value_t val2;
@@ -663,7 +672,7 @@ void ExtV4l2::Refresh( void )
                 }
                 case VLC_VAR_BOOL:
                 {
-                    QRadioButton *button = new QRadioButton( psz_label );
+                    QCheckBox *button = new QCheckBox( psz_label, box );
                     button->setObjectName( psz_var );
                     button->setChecked( var_GetBool( p_obj, psz_var ) );
 
@@ -674,7 +683,7 @@ void ExtV4l2::Refresh( void )
                 }
                 case VLC_VAR_VOID:
                 {
-                    QPushButton *button = new QPushButton( psz_label );
+                    QPushButton *button = new QPushButton( psz_label, box );
                     button->setObjectName( psz_var );
 
                     CONNECT( button, clicked( bool ), this,
@@ -694,7 +703,7 @@ void ExtV4l2::Refresh( void )
     else
     {
         msg_Dbg( p_intf, "Couldn't find v4l2 instance" );
-        help->show();
+        ui.help->show();
     }
 
 }
index 596bd2adfda8877ab2438ad96c3bf2ed9b2fe735..fc5892cf4995a6571e6593ee43d864f0787c4666 100644 (file)
@@ -5,6 +5,7 @@
  * $Id: preferences.hpp 16643 2006-09-13 12:45:46Z zorglub $
  *
  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
+ *          Antoine Cellerier <dionoea at videolan dot org>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -65,8 +66,7 @@ public:
 private:
     intf_thread_t *p_intf;
     Ui::ExtV4l2Widget ui;
-    QVBoxLayout *layout;
-    QLabel *help;
+    QGroupBox *box;
 
 private slots:
     void Refresh( void );
index 9077f93ec0563e8f53181803f7594f38800e295e..ec18b20d12a78f232e8c1aea66ade56d995873c0 100644 (file)
@@ -5,7 +5,7 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>400</width>
+    <width>405</width>
     <height>300</height>
    </rect>
   </property>
      </property>
     </widget>
    </item>
+   <item>
+    <widget class="QLabel" name="help" >
+     <property name="text" >
+      <string>No v4l2 instance found. Press the refresh button to try again.</string>
+     </property>
+    </widget>
+   </item>
   </layout>
  </widget>
  <resources/>