[vlc-commits] Qt: stop abusing MACROS in extended_panels

Jean-Baptiste Kempf git at videolan.org
Sat Aug 16 09:02:05 CEST 2014


vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Sat Aug 16 09:00:24 2014 +0200| [3cd4baea26c6a7736be59976eed2ebfc29378acd] | committer: Jean-Baptiste Kempf

Qt: stop abusing MACROS in extended_panels

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3cd4baea26c6a7736be59976eed2ebfc29378acd
---

 modules/gui/qt4/components/extended_panels.cpp |   45 ++++++++++++------------
 1 file changed, 23 insertions(+), 22 deletions(-)

diff --git a/modules/gui/qt4/components/extended_panels.cpp b/modules/gui/qt4/components/extended_panels.cpp
index 924f890..d05c0b3 100644
--- a/modules/gui/qt4/components/extended_panels.cpp
+++ b/modules/gui/qt4/components/extended_panels.cpp
@@ -80,38 +80,39 @@ QString OptionFromWidgetName( QObject *obj )
     return option;
 }
 
-ExtVideo::ExtVideo( intf_thread_t *_p_intf, QTabWidget *_parent ) :
-            QObject( _parent ), p_intf( _p_intf )
+static inline void setup_vfilter( intf_thread_t *p_intf, const char* psz_name, QWidget *widget )
 {
-    ui.setupUi( _parent );
+    vlc_object_t *p_obj = ( vlc_object_t * )
+        vlc_object_find_name( p_intf->p_libvlc, psz_name );
+    QCheckBox *checkbox = qobject_cast<QCheckBox*>( widget );
+    QGroupBox *groupbox = qobject_cast<QGroupBox*>( widget );
+    if( p_obj )
+    {
+        vlc_object_release( p_obj ); \
+        if( checkbox ) checkbox->setChecked( true ); \
+        else if (groupbox) groupbox->setChecked( true ); \
+    }
+    else
+    {
+        if( checkbox ) checkbox->setChecked( false );
+        else if (groupbox) groupbox->setChecked( false );
+    }
+}
 
 #define SETUP_VFILTER( widget ) \
-    { \
-        vlc_object_t *p_obj = ( vlc_object_t * ) \
-            vlc_object_find_name( p_intf->p_libvlc, \
-                                  #widget ); \
-        QCheckBox *checkbox = qobject_cast<QCheckBox*>( ui.widget##Enable ); \
-        QGroupBox *groupbox = qobject_cast<QGroupBox*>( ui.widget##Enable ); \
-        if( p_obj ) \
-        { \
-            vlc_object_release( p_obj ); \
-            if( checkbox ) checkbox->setChecked( true ); \
-            else if (groupbox) groupbox->setChecked( true ); \
-        } \
-        else \
-        { \
-            if( checkbox ) checkbox->setChecked( false ); \
-            else if (groupbox)  groupbox->setChecked( false ); \
-        } \
-    } \
+    setup_vfilter( p_intf, #widget, ui.widget##Enable ); \
     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() );
 
+ExtVideo::ExtVideo( intf_thread_t *_p_intf, QTabWidget *_parent ) :
+            QObject( _parent ), p_intf( _p_intf )
+{
+    ui.setupUi( _parent );
+
     SETUP_VFILTER( adjust )
     SETUP_VFILTER_OPTION( hueSlider, valueChanged( int ) )
     SETUP_VFILTER_OPTION( contrastSlider, valueChanged( int ) )



More information about the vlc-commits mailing list