[vlc-devel] [PATCH 09/11] qt: refactor ChangeVFiltersString

Thomas Guillem thomas at gllm.fr
Mon May 29 18:53:03 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 20eed19ba0..eb82fc9b2c 100644
--- a/modules/gui/qt/components/extended_panels.cpp
+++ b/modules/gui/qt/components/extended_panels.cpp
@@ -290,19 +290,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" ) )
@@ -310,12 +301,25 @@ static void ChangeVFiltersString( struct intf_thread_t *p_intf, const char *psz_
         vout_thread_t *p_vout = THEMIM->getVout();
         if( p_vout )
         {
-            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() );
@@ -323,7 +327,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() );
 }
@@ -533,8 +537,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 );
     }
 
     if( p_vout ) vlc_object_release( p_vout );
@@ -1498,7 +1502,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 );
     }
 }
 
@@ -1531,7 +1535,7 @@ void SyncControls::initSubsDuration()
 void SyncControls::subsdelayClean()
 {
     /* Remove subsdelay filter */
-    ChangeVFiltersString( p_intf, "subsdelay", false );
+    changeVFiltersString( "subsdelay", false );
 }
 
 void SyncControls::subsdelaySetFactor( double f_factor )
@@ -1548,6 +1552,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 ddd3da5d38..eece04b47a 100644
--- a/modules/gui/qt/components/extended_panels.hpp
+++ b/modules/gui/qt/components/extended_panels.hpp
@@ -55,6 +55,7 @@ private:
     void setWidgetValue( QObject* );
     void clean();
     void setFilterOption( const char *psz_module, const char *psz_option, int, double, QString );
+    void changeVFiltersString( const char *psz_name, bool b_add );
 
 private slots:
     void updateFilters();
@@ -245,6 +246,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