[vlc-devel] [PATCHv2 16/18] qt: refactor ChangeVFiltersString

Thomas Guillem thomas at gllm.fr
Tue May 30 18:41:06 CEST 2017


Ref #6873
---
 modules/gui/qt/components/extended_panels.cpp | 53 ++++++++++++++++++---------
 modules/gui/qt/components/extended_panels.hpp |  2 +
 2 files changed, 37 insertions(+), 18 deletions(-)

diff --git a/modules/gui/qt/components/extended_panels.cpp b/modules/gui/qt/components/extended_panels.cpp
index 24dd7e5e1b..a1dcb9797f 100644
--- a/modules/gui/qt/components/extended_panels.cpp
+++ b/modules/gui/qt/components/extended_panels.cpp
@@ -301,19 +301,10 @@ static QString ChangeFiltersString( struct intf_thread_t *p_intf, const char *ps
     return list.join( ":" );
 }
 
-static void ChangeVFiltersString( struct intf_thread_t *p_intf, const char *psz_name, bool b_add )
+static void UpdateVFiltersString( struct intf_thread_t *p_intf,
+                                  const char *psz_filter_type, const char *value )
 {
-    const char *psz_filter_type = GetVFilterType( p_intf, psz_name );
-
-    if( psz_filter_type == NULL )
-        return;
-
-    QString result = ChangeFiltersString( p_intf, psz_filter_type, psz_name, b_add );
-
-    /* Vout is not kept, so put that in the config */
-    config_PutPsz( p_intf, psz_filter_type, qtu( result ) );
-
-    var_SetString( THEPL, psz_filter_type, qtu( result ) );
+    var_SetString( THEPL, psz_filter_type, value );
 
     /* Try to set non splitter filters on the fly */
     if( strcmp( psz_filter_type, "video-splitter" ) )
@@ -321,12 +312,25 @@ static void ChangeVFiltersString( struct intf_thread_t *p_intf, const char *psz_
         QVector<vout_thread_t*> p_vouts = THEMIM->getVouts();
         foreach( vout_thread_t *p_vout, p_vouts )
         {
-            var_SetString( p_vout, psz_filter_type, qtu( result ) );
+            var_SetString( p_vout, psz_filter_type, value );
             vlc_object_release( p_vout );
         }
     }
 }
 
+void ExtVideo::changeVFiltersString( const char *psz_name, bool b_add )
+{
+    const char *psz_filter_type = GetVFilterType( p_intf, psz_name );
+    if( psz_filter_type == NULL )
+        return;
+
+    QString result = ChangeFiltersString( p_intf, psz_filter_type, psz_name, b_add );
+
+    config_PutPsz( p_intf, psz_filter_type, qtu( result ) );
+
+    UpdateVFiltersString( p_intf, psz_filter_type, qtu( result ) );
+}
+
 void ExtVideo::updateFilters()
 {
     QString module = ModuleFromWidgetName( sender() );
@@ -334,7 +338,7 @@ void ExtVideo::updateFilters()
     QCheckBox *checkbox = qobject_cast<QCheckBox*>( sender() );
     QGroupBox *groupbox = qobject_cast<QGroupBox*>( sender() );
 
-    ChangeVFiltersString( p_intf, qtu( module ),
+    changeVFiltersString( qtu( module ),
                           checkbox ? checkbox->isChecked()
                                    : groupbox->isChecked() );
 }
@@ -559,8 +563,8 @@ void ExtVideo::setFilterOption( const char *psz_module, const char *psz_option,
         msg_Warn( p_intf, "Module %s's %s variable isn't a command. Brute-restarting the filter.",
                  psz_module,
                  psz_option );
-        ChangeVFiltersString( p_intf, psz_module, false );
-        ChangeVFiltersString( p_intf, psz_module, true );
+        changeVFiltersString( psz_module, false );
+        changeVFiltersString( psz_module, true );
     }
 
     foreach( vout_thread_t *p_vout, p_vouts )
@@ -1525,7 +1529,7 @@ void SyncControls::adjustSubsDuration( double f_factor )
     if( THEMIM->getInput() && b_userAction )
     {
         subsdelaySetFactor( f_factor );
-        ChangeVFiltersString( p_intf, "subsdelay", f_factor > 0 );
+        changeVFiltersString( "subsdelay", f_factor > 0 );
     }
 }
 
@@ -1558,7 +1562,7 @@ void SyncControls::initSubsDuration()
 void SyncControls::subsdelayClean()
 {
     /* Remove subsdelay filter */
-    ChangeVFiltersString( p_intf, "subsdelay", false );
+    changeVFiltersString( "subsdelay", false );
 }
 
 void SyncControls::subsdelaySetFactor( double f_factor )
@@ -1575,6 +1579,19 @@ void SyncControls::subsdelaySetFactor( double f_factor )
     }
 }
 
+void SyncControls::changeVFiltersString( const char *psz_name, bool b_add )
+{
+    const char *psz_filter_type = GetVFilterType( p_intf, psz_name );
+    if( psz_filter_type == NULL )
+        return;
+
+    QString result = ChangeFiltersString( p_intf, psz_filter_type, psz_name, b_add );
+
+    config_PutPsz( p_intf, psz_filter_type, qtu( result ) );
+
+    UpdateVFiltersString( p_intf, psz_filter_type, qtu( result ) );
+}
+
 
 /**********************************************************************
  * Video filters / Adjust
diff --git a/modules/gui/qt/components/extended_panels.hpp b/modules/gui/qt/components/extended_panels.hpp
index 1f6a1869d3..872b872f1d 100644
--- a/modules/gui/qt/components/extended_panels.hpp
+++ b/modules/gui/qt/components/extended_panels.hpp
@@ -56,6 +56,7 @@ private:
     void clean();
     void setFilterOption( const char *psz_module, const char *psz_option, int,
                           double, const char * );
+    void changeVFiltersString( const char *psz_name, bool b_add );
 
 private slots:
     void updateFilters();
@@ -246,6 +247,7 @@ private:
     void initSubsDuration();
     void subsdelayClean();
     void subsdelaySetFactor( double );
+    void changeVFiltersString( const char *psz_name, bool b_add );
 public slots:
     void update();
 private slots:
-- 
2.11.0



More information about the vlc-devel mailing list