From d77ec47116cae944c5406bba91dfdc94ff54a3ca Mon Sep 17 00:00:00 2001 From: Antoine Cellerier Date: Sun, 17 Jun 2007 14:14:19 +0000 Subject: [PATCH] Fix a huge bunch of things in the video effects panel. Implement combo box options. --- .../gui/qt4/components/extended_panels.cpp | 65 +++++++++++++++---- .../gui/qt4/components/extended_panels.hpp | 1 + modules/gui/qt4/ui/video_effects.ui | 59 ++++++++++++++++- 3 files changed, 112 insertions(+), 13 deletions(-) diff --git a/modules/gui/qt4/components/extended_panels.cpp b/modules/gui/qt4/components/extended_panels.cpp index 1434909412..b57cc709ea 100644 --- a/modules/gui/qt4/components/extended_panels.cpp +++ b/modules/gui/qt4/components/extended_panels.cpp @@ -114,6 +114,7 @@ ExtVideo::ExtVideo( intf_thread_t *_p_intf, QWidget *_parent ) : } \ CONNECT( ui.widget##Enable, clicked(), this, updateFilters() ); #define SETUP_VFILTER_OPTION( widget, signal ) \ + initComboBoxItems( ui.widget ); \ setWidgetValue( ui.widget ); \ CONNECT( ui.widget, signal, this, updateFilterOptions() ); @@ -140,7 +141,7 @@ ExtVideo::ExtVideo( intf_thread_t *_p_intf, QWidget *_parent ) : SETUP_VFILTER_OPTION( gradientTypeCheck, stateChanged(int) ) SETUP_VFILTER_OPTION( gradientCartoonCheck, stateChanged(int) ) - SETUP_VFILTER( blur ) + SETUP_VFILTER( motionblur ) SETUP_VFILTER_OPTION( blurFactorSlider, valueChanged(int) ) SETUP_VFILTER( motiondetect ) @@ -211,7 +212,7 @@ void ExtVideo::ChangeVFiltersString( char *psz_name, vlc_bool_t b_add ) vlc_object_find_name( p_intf->p_libvlc_global, psz_name, FIND_CHILD ); if( !p_obj ) { - msg_Err( p_intf, "Unable to find filter module." ); + msg_Err( p_intf, "Unable to find filter module \"%s\n.", psz_name ); return; } @@ -319,6 +320,32 @@ void ExtVideo::updateFilters() : groupbox->isChecked() ); } +void ExtVideo::initComboBoxItems( QObject *widget ) +{ + QComboBox *combobox = qobject_cast(widget); + if( !combobox ) return; + QString option = OptionFromWidgetName( widget ); + module_config_t *p_item = config_FindConfig( VLC_OBJECT(p_intf), + option.toStdString().c_str() ); + if( p_item ) + { + int i_type = p_item->i_type & CONFIG_ITEM; + for( int i_index = 0; i_index < p_item->i_list; i_index++ ) + { + if( i_type == CONFIG_ITEM_INTEGER + || i_type == CONFIG_ITEM_BOOL ) + combobox->addItem( qfu( p_item->ppsz_list_text[i_index] ), p_item->pi_list[i_index] ); + else if( i_type == CONFIG_ITEM_STRING ) + combobox->addItem( qfu( p_item->ppsz_list_text[i_index] ), p_item->ppsz_list[i_index] ); + } + } + else + { + msg_Err( p_intf, "Couldn't find option \"%s\".", + option.toStdString().c_str() ); + } +} + void ExtVideo::setWidgetValue( QObject *widget ) { QString module = ModuleFromWidgetName( widget->parent() ); @@ -384,6 +411,8 @@ void ExtVideo::setWidgetValue( QObject *widget ) sprintf( str, "%06X", val.i_int ); lineedit->setText( str ); } + else if( combobox ) combobox->setCurrentIndex( + combobox->findData( val.i_int ) ); else msg_Warn( p_intf, "Oops %s %s %d", __FILE__, __func__, __LINE__ ); } else if( i_type == VLC_VAR_FLOAT ) @@ -397,6 +426,8 @@ void ExtVideo::setWidgetValue( QObject *widget ) { const char *psz_string = NULL; if( lineedit ) lineedit->setText( qfu(val.psz_string) ); + else if( combobox ) combobox->setCurrentIndex( + combobox->findData( qfu( val.psz_string ) ) ); else msg_Warn( p_intf, "Oops %s %s %d", __FILE__, __func__, __LINE__ ); free( val.psz_string ); } @@ -426,13 +457,13 @@ void ExtVideo::updateFilterOptions() } int i_type = var_Type( p_obj, option.toStdString().c_str() ); - if( !( i_type & VLC_VAR_ISCOMMAND ) ) + bool b_is_command = ( i_type & VLC_VAR_ISCOMMAND ); + if( !b_is_command ) { - vlc_object_release( p_obj ); - msg_Err( p_intf, "Module %s's %s variable isn't a command.", + msg_Warn( p_intf, "Module %s's %s variable isn't a command. You'll need to restart the filter to take change into account.", module.toStdString().c_str(), option.toStdString().c_str() ); - return; + /* FIXME: restart automatically somewhere near the end of this function */ } /* Try to cast to all the widgets we're likely to encounter. Only @@ -454,12 +485,16 @@ void ExtVideo::updateFilterOptions() 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, "Oops %s %s %d", __FILE__, __func__, __LINE__ ); config_PutInt( p_intf, option.toStdString().c_str(), i_int ); - if( i_type == VLC_VAR_INTEGER ) - var_SetInteger( p_obj, option.toStdString().c_str(), i_int ); - else - var_SetBool( p_obj, option.toStdString().c_str(), i_int ); + if( b_is_command ) + { + if( i_type == VLC_VAR_INTEGER ) + var_SetInteger( p_obj, option.toStdString().c_str(), i_int ); + else + var_SetBool( p_obj, option.toStdString().c_str(), i_int ); + } } else if( i_type == VLC_VAR_FLOAT ) { @@ -470,15 +505,21 @@ void ExtVideo::updateFilterOptions() else if( lineedit ) f_float = lineedit->text().toDouble(); else msg_Warn( p_intf, "Oops %s %s %d", __FILE__, __func__, __LINE__ ); config_PutFloat( p_intf, option.toStdString().c_str(), f_float ); - var_SetFloat( p_obj, option.toStdString().c_str(), f_float ); + if( b_is_command ) + var_SetFloat( p_obj, option.toStdString().c_str(), f_float ); } else if( i_type == VLC_VAR_STRING ) { char *psz_string = NULL; if( lineedit ) psz_string = qtu(lineedit->text()); + else if( combobox ) psz_string = qtu(combobox->itemData( + combobox->currentIndex()).toString()); else msg_Warn( p_intf, "Oops %s %s %d", __FILE__, __func__, __LINE__ ); + psz_string = strdup( psz_string ); config_PutPsz( p_intf, option.toStdString().c_str(), psz_string ); - var_SetString( p_obj, option.toStdString().c_str(), psz_string ); + if( b_is_command ) + var_SetString( p_obj, option.toStdString().c_str(), psz_string ); + free( psz_string ); } else msg_Err( p_intf, diff --git a/modules/gui/qt4/components/extended_panels.hpp b/modules/gui/qt4/components/extended_panels.hpp index ee0b93a17b..cb651e478f 100644 --- a/modules/gui/qt4/components/extended_panels.hpp +++ b/modules/gui/qt4/components/extended_panels.hpp @@ -45,6 +45,7 @@ private: Ui::ExtVideoWidget ui; QSignalMapper* filterMapper; intf_thread_t *p_intf; + void initComboBoxItems( QObject* ); void setWidgetValue( QObject* ); void ChangeVFiltersString( char *psz_name, vlc_bool_t b_add ); private slots: diff --git a/modules/gui/qt4/ui/video_effects.ui b/modules/gui/qt4/ui/video_effects.ui index d6e216605a..a84e350602 100644 --- a/modules/gui/qt4/ui/video_effects.ui +++ b/modules/gui/qt4/ui/video_effects.ui @@ -86,9 +86,24 @@ + + 200 + + + 1 + + + 10 + Qt::Horizontal + + QSlider::TicksBothSides + + + 100 + @@ -123,6 +138,12 @@ Qt::Horizontal + + QSlider::TicksBothSides + + + 60 + @@ -133,6 +154,9 @@ Qt::Horizontal + + QSlider::TicksBothSides + 50 @@ -146,6 +170,9 @@ Qt::Horizontal + + QSlider::TicksBothSides + 100 @@ -159,6 +186,9 @@ Qt::Horizontal + + QSlider::TicksBothSides + 100 @@ -172,6 +202,9 @@ Qt::Horizontal + + QSlider::TicksBothSides + 100 @@ -521,7 +554,7 @@ - + _("Motion blur") @@ -547,9 +580,24 @@ + + 1 + + + 127 + + + 80 + Qt::Horizontal + + QSlider::TicksBothSides + + + 16 + @@ -852,9 +900,18 @@ + + 255 + Qt::Horizontal + + QSlider::TicksBothSides + + + 32 + -- 2.39.2