Commit 02032094 authored by Antoine Cellerier's avatar Antoine Cellerier

Fixes to the v4l2 extended panel (works fine for multiple refreshes).

parent 9538c177
...@@ -568,23 +568,25 @@ ExtV4l2::ExtV4l2( intf_thread_t *_p_intf, QWidget *_parent ) ...@@ -568,23 +568,25 @@ ExtV4l2::ExtV4l2( intf_thread_t *_p_intf, QWidget *_parent )
BUTTONACT( ui.refresh, Refresh() ); BUTTONACT( ui.refresh, Refresh() );
layout = new QVBoxLayout; box = NULL;
ui.vboxLayout->addLayout( layout );
help = new QLabel( qtr( "No v4l2 instance found. Press the refresh button to try again." ) );
layout->addWidget( help );
} }
ExtV4l2::~ExtV4l2() ExtV4l2::~ExtV4l2()
{ {
delete help; if( box )
delete layout; delete box;
} }
void ExtV4l2::Refresh( void ) void ExtV4l2::Refresh( void )
{ {
vlc_object_t *p_obj = (vlc_object_t*)vlc_object_find_name( p_intf, "v4l2", FIND_ANYWHERE ); 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 ) if( p_obj )
{ {
msg_Dbg( p_intf, "Found v4l2 instance" ); msg_Dbg( p_intf, "Found v4l2 instance" );
...@@ -593,10 +595,17 @@ void ExtV4l2::Refresh( void ) ...@@ -593,10 +595,17 @@ void ExtV4l2::Refresh( void )
&val, &text ); &val, &text );
if( i_ret < 0 ) 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 ); vlc_object_release( p_obj );
return; 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++ ) for( int i = 0; i < val.p_list->i_count; i++ )
{ {
const char *psz_var = text.p_list->p_values[i].psz_string; const char *psz_var = text.p_list->p_values[i].psz_string;
...@@ -610,13 +619,13 @@ void ExtV4l2::Refresh( void ) ...@@ -610,13 +619,13 @@ void ExtV4l2::Refresh( void )
{ {
case VLC_VAR_INTEGER: case VLC_VAR_INTEGER:
{ {
QLabel *label = new QLabel( psz_label ); QLabel *label = new QLabel( psz_label, box );
QHBoxLayout *hlayout = new QHBoxLayout; QHBoxLayout *hlayout = new QHBoxLayout( box );
hlayout->addWidget( label ); hlayout->addWidget( label );
int i_val = var_GetInteger( p_obj, psz_var ); int i_val = var_GetInteger( p_obj, psz_var );
if( i_type & VLC_VAR_HASCHOICE ) if( i_type & VLC_VAR_HASCHOICE )
{ {
QComboBox *combobox = new QComboBox; QComboBox *combobox = new QComboBox( box );
combobox->setObjectName( psz_var ); combobox->setObjectName( psz_var );
vlc_value_t val2, text2; vlc_value_t val2, text2;
...@@ -639,7 +648,7 @@ void ExtV4l2::Refresh( void ) ...@@ -639,7 +648,7 @@ void ExtV4l2::Refresh( void )
} }
else else
{ {
QSlider *slider = new QSlider; QSlider *slider = new QSlider( box );
slider->setObjectName( psz_var ); slider->setObjectName( psz_var );
slider->setOrientation( Qt::Horizontal ); slider->setOrientation( Qt::Horizontal );
vlc_value_t val2; vlc_value_t val2;
...@@ -663,7 +672,7 @@ void ExtV4l2::Refresh( void ) ...@@ -663,7 +672,7 @@ void ExtV4l2::Refresh( void )
} }
case VLC_VAR_BOOL: case VLC_VAR_BOOL:
{ {
QRadioButton *button = new QRadioButton( psz_label ); QCheckBox *button = new QCheckBox( psz_label, box );
button->setObjectName( psz_var ); button->setObjectName( psz_var );
button->setChecked( var_GetBool( p_obj, psz_var ) ); button->setChecked( var_GetBool( p_obj, psz_var ) );
...@@ -674,7 +683,7 @@ void ExtV4l2::Refresh( void ) ...@@ -674,7 +683,7 @@ void ExtV4l2::Refresh( void )
} }
case VLC_VAR_VOID: case VLC_VAR_VOID:
{ {
QPushButton *button = new QPushButton( psz_label ); QPushButton *button = new QPushButton( psz_label, box );
button->setObjectName( psz_var ); button->setObjectName( psz_var );
CONNECT( button, clicked( bool ), this, CONNECT( button, clicked( bool ), this,
...@@ -694,7 +703,7 @@ void ExtV4l2::Refresh( void ) ...@@ -694,7 +703,7 @@ void ExtV4l2::Refresh( void )
else else
{ {
msg_Dbg( p_intf, "Couldn't find v4l2 instance" ); msg_Dbg( p_intf, "Couldn't find v4l2 instance" );
help->show(); ui.help->show();
} }
} }
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
* $Id: preferences.hpp 16643 2006-09-13 12:45:46Z zorglub $ * $Id: preferences.hpp 16643 2006-09-13 12:45:46Z zorglub $
* *
* Authors: Clément Stenac <zorglub@videolan.org> * 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 * 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 * it under the terms of the GNU General Public License as published by
...@@ -65,8 +66,7 @@ public: ...@@ -65,8 +66,7 @@ public:
private: private:
intf_thread_t *p_intf; intf_thread_t *p_intf;
Ui::ExtV4l2Widget ui; Ui::ExtV4l2Widget ui;
QVBoxLayout *layout; QGroupBox *box;
QLabel *help;
private slots: private slots:
void Refresh( void ); void Refresh( void );
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>400</width> <width>405</width>
<height>300</height> <height>300</height>
</rect> </rect>
</property> </property>
...@@ -20,6 +20,13 @@ ...@@ -20,6 +20,13 @@
</property> </property>
</widget> </widget>
</item> </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> </layout>
</widget> </widget>
<resources/> <resources/>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment