Commit 1961ae18 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt: helpers for setting video filter values

This is mostly splitting Qt and core code

Ref #11613

(cherry picked from commit c803336b8b6c859bf529dbc944668e63b30e2828)
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 5a462784
...@@ -583,106 +583,121 @@ void ExtVideo::setWidgetValue( QObject *widget ) ...@@ -583,106 +583,121 @@ void ExtVideo::setWidgetValue( QObject *widget )
i_type ); i_type );
} }
void ExtVideo::updateFilterOptions() void ExtVideo::setFilterOption( struct intf_thread_t *p_intf, const char *psz_module, const char *psz_option,
int i_int, double f_float, QString val )
{ {
QString module = ModuleFromWidgetName( sender()->parent() ); vlc_object_t *p_obj = ( vlc_object_t * )vlc_object_find_name( p_intf->p_libvlc, psz_module );
//msg_Dbg( p_intf, "Module name: %s", qtu( module ) );
QString option = OptionFromWidgetName( sender() );
//msg_Dbg( p_intf, "Option name: %s", qtu( option ) );
vlc_object_t *p_obj = ( vlc_object_t * )
vlc_object_find_name( p_intf->p_libvlc, qtu( module ) );
int i_type; int i_type;
bool b_is_command; bool b_is_command;
if( !p_obj ) if( !p_obj )
{ {
msg_Warn( p_intf, "Module %s not found. You'll need to restart the filter to take the change into account.", qtu( module ) ); msg_Warn( p_intf, "Module %s not found. You'll need to restart the filter to take the change into account.", psz_module );
i_type = config_GetType( p_intf, qtu( option ) ); i_type = config_GetType( p_intf, psz_option );
b_is_command = false; b_is_command = false;
} }
else else
{ {
i_type = var_Type( p_obj, qtu( option ) ); i_type = var_Type( p_obj, psz_option );
if( i_type == 0 ) if( i_type == 0 )
i_type = config_GetType( p_intf, qtu( option ) ); i_type = config_GetType( p_intf, psz_option );
b_is_command = ( i_type & VLC_VAR_ISCOMMAND ); b_is_command = ( i_type & VLC_VAR_ISCOMMAND );
} }
/* Try to cast to all the widgets we're likely to encounter. Only
* one of the casts is expected to work. */
QSlider *slider = qobject_cast<QSlider*> ( sender() );
QCheckBox *checkbox = qobject_cast<QCheckBox*> ( sender() );
QSpinBox *spinbox = qobject_cast<QSpinBox*> ( sender() );
QDoubleSpinBox *doublespinbox = qobject_cast<QDoubleSpinBox*>( sender() );
VLCQDial *dial = qobject_cast<VLCQDial*> ( sender() );
QLineEdit *lineedit = qobject_cast<QLineEdit*> ( sender() );
QComboBox *combobox = qobject_cast<QComboBox*> ( sender() );
i_type &= VLC_VAR_CLASS; i_type &= VLC_VAR_CLASS;
if( i_type == VLC_VAR_INTEGER || i_type == VLC_VAR_BOOL ) if( i_type == VLC_VAR_INTEGER || i_type == VLC_VAR_BOOL )
{ {
int i_int = 0; if( i_int == -1 )
if( slider ) i_int = slider->value(); msg_Warn( p_intf, "Could not find the correct Integer widget" );
else if( checkbox ) i_int = checkbox->checkState() == Qt::Checked; config_PutInt( p_intf, psz_option, i_int );
else if( spinbox ) i_int = spinbox->value();
else if( dial ) i_int = ( 540-dial->value() )%360;
else if( lineedit ) i_int = lineedit->text().toInt( NULL,16 );
else if( combobox ) i_int = combobox->itemData( combobox->currentIndex() ).toInt();
else msg_Warn( p_intf, "Could not find the correct Integer widget" );
config_PutInt( p_intf, qtu( option ), i_int );
if( b_is_command ) if( b_is_command )
{ {
if( i_type == VLC_VAR_INTEGER ) if( i_type == VLC_VAR_INTEGER )
var_SetInteger( p_obj, qtu( option ), i_int ); var_SetInteger( p_obj, psz_option, i_int );
else else
var_SetBool( p_obj, qtu( option ), i_int ); var_SetBool( p_obj, psz_option, i_int );
} }
} }
else if( i_type == VLC_VAR_FLOAT ) else if( i_type == VLC_VAR_FLOAT )
{ {
double f_float = 0; if( f_float == -1 )
if( slider ) f_float = ( double )slider->value() msg_Warn( p_intf, "Could not find the correct Float widget" );
/ ( double )slider->tickInterval(); /* hack alert! */ config_PutFloat( p_intf, psz_option, f_float );
else if( doublespinbox ) f_float = doublespinbox->value();
else if( dial ) f_float = (540 - dial->value()) % 360;
else if( lineedit ) f_float = lineedit->text().toDouble();
else msg_Warn( p_intf, "Could not find the correct Float widget" );
config_PutFloat( p_intf, qtu( option ), f_float );
if( b_is_command ) if( b_is_command )
var_SetFloat( p_obj, qtu( option ), f_float ); var_SetFloat( p_obj, psz_option, f_float );
} }
else if( i_type == VLC_VAR_STRING ) else if( i_type == VLC_VAR_STRING )
{ {
QString val; if( val.isNull() )
if( lineedit )
val = lineedit->text();
else if( combobox )
val = combobox->itemData( combobox->currentIndex() ).toString();
else
msg_Warn( p_intf, "Could not find the correct String widget" ); msg_Warn( p_intf, "Could not find the correct String widget" );
config_PutPsz( p_intf, qtu( option ), qtu( val ) ); config_PutPsz( p_intf, psz_option, qtu( val ) );
if( b_is_command ) if( b_is_command )
var_SetString( p_obj, qtu( option ), qtu( val ) ); var_SetString( p_obj, psz_option, qtu( val ) );
} }
else else
msg_Err( p_intf, msg_Err( p_intf,
"Module %s's %s variable is of an unsupported type ( %d )", "Module %s's %s variable is of an unsupported type ( %d )",
qtu( module ), psz_module,
qtu( option ), psz_option,
i_type ); i_type );
if( !b_is_command ) if( !b_is_command )
{ {
msg_Warn( p_intf, "Module %s's %s variable isn't a command. Brute-restarting the filter.", msg_Warn( p_intf, "Module %s's %s variable isn't a command. Brute-restarting the filter.",
qtu( module ), psz_module,
qtu( option ) ); psz_option );
ChangeVFiltersString( p_intf, qtu( module ), false ); ChangeVFiltersString( p_intf, psz_module, false );
ChangeVFiltersString( p_intf, qtu( module ), true ); ChangeVFiltersString( p_intf, psz_module, true );
} }
if( p_obj ) vlc_object_release( p_obj ); if( p_obj ) vlc_object_release( p_obj );
} }
void ExtVideo::updateFilterOptions()
{
QString module = ModuleFromWidgetName( sender()->parent() );
//msg_Dbg( p_intf, "Module name: %s", qtu( module ) );
QString option = OptionFromWidgetName( sender() );
//msg_Dbg( p_intf, "Option name: %s", qtu( option ) );
/* Try to cast to all the widgets we're likely to encounter. Only
* one of the casts is expected to work. */
QSlider *slider = qobject_cast<QSlider*> ( sender() );
QCheckBox *checkbox = qobject_cast<QCheckBox*> ( sender() );
QSpinBox *spinbox = qobject_cast<QSpinBox*> ( sender() );
QDoubleSpinBox *doublespinbox = qobject_cast<QDoubleSpinBox*>( sender() );
VLCQDial *dial = qobject_cast<VLCQDial*> ( sender() );
QLineEdit *lineedit = qobject_cast<QLineEdit*> ( sender() );
QComboBox *combobox = qobject_cast<QComboBox*> ( sender() );
int i_int = -1;
double f_float = -1.;
QString val;
if( slider ) {
i_int = slider->value();
f_float = ( double )slider->value() / ( double )slider->tickInterval(); /* hack alert! */
}
else if( checkbox ) i_int = checkbox->checkState() == Qt::Checked;
else if( spinbox ) i_int = spinbox->value();
else if( doublespinbox ) f_float = doublespinbox->value();
else if( dial ) {
i_int = (540 - dial->value()) % 360;
f_float = (540 - dial->value()) / 360.;
}
else if( lineedit ) {
i_int = lineedit->text().toInt( NULL,16 );
f_float = lineedit->text().toDouble();
val = lineedit->text();
}
else if( combobox ) {
i_int = combobox->itemData( combobox->currentIndex() ).toInt();
val = combobox->itemData( combobox->currentIndex() ).toString();
}
setFilterOption( p_intf, qtu( module ), qtu( option ), i_int, f_float, val);
}
/********************************************************************** /**********************************************************************
* v4l2 controls * v4l2 controls
**********************************************************************/ **********************************************************************/
......
...@@ -53,6 +53,8 @@ private: ...@@ -53,6 +53,8 @@ private:
void initComboBoxItems( QObject* ); void initComboBoxItems( QObject* );
void setWidgetValue( QObject* ); void setWidgetValue( QObject* );
void clean(); void clean();
static void setFilterOption( struct intf_thread_t *, const char *psz_module, const char *psz_option, int, double, QString );
private slots: private slots:
void updateFilters(); void updateFilters();
void updateFilterOptions(); void updateFilterOptions();
......
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