]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/components/extended_panels.cpp
Qt extended panels: do not spam about options about modules that don't exist in 1.2
[vlc] / modules / gui / qt4 / components / extended_panels.cpp
index 47dadbd3cd4dceb48b5a4bd5f0097c0e2d4dac5d..51952fd121327e108c9997d2a3448c0f51f8e2fb 100644 (file)
@@ -396,6 +396,7 @@ void ExtVideo::initComboBoxItems( QObject *widget )
 {
     QComboBox *combobox = qobject_cast<QComboBox*>( widget );
     if( !combobox ) return;
+
     QString option = OptionFromWidgetName( widget );
     module_config_t *p_item = config_FindConfig( VLC_OBJECT( p_intf ),
                                                  qtu( option ) );
@@ -505,11 +506,12 @@ void ExtVideo::setWidgetValue( QObject *widget )
         free( val.psz_string );
     }
     else
-        msg_Err( p_intf,
-                 "Module %s's %s variable is of an unsupported type ( %d )",
-                 qtu( module ),
-                 qtu( option ),
-                 i_type );
+        if( p_obj )
+            msg_Err( p_intf,
+                     "Module %s's %s variable is of an unsupported type ( %d )",
+                     qtu( module ),
+                     qtu( option ),
+                     i_type );
 }
 
 void ExtVideo::updateFilterOptions()
@@ -887,14 +889,6 @@ Equalizer::Equalizer( intf_thread_t *_p_intf, QWidget *_parent ) :
     updateUIFromCore();
 }
 
-Equalizer::~Equalizer()
-{
-}
-
-void Equalizer::clean()
-{
-    enable();
-}
 /* Write down initial values */
 void Equalizer::updateUIFromCore()
 {
@@ -934,7 +928,7 @@ void Equalizer::updateUIFromCore()
 
     if( psz_bands && strlen( psz_bands ) > 1 )
     {
-       char *psz_bands_orig = psz_bands;
+        char *psz_bands_orig = psz_bands;
         for( int i = 0; i < BANDS; i++ )
         {
             const float f = us_strtod(psz_bands, &psz_bands );
@@ -1122,41 +1116,33 @@ void Equalizer::addCallbacks( aout_instance_t *p_aout )
 /**********************************************************************
  * Dynamic range compressor
  **********************************************************************/
-static const char *psz_comp_control_names[] =
-{
-    "compressor-rms-peak", "compressor-attack", "compressor-release",
-    "compressor-threshold", "compressor-ratio", "compressor-knee",
-    "compressor-makeup-gain"
-};
 
-static const char *psz_comp_control_descs[] =
+typedef struct
 {
-    "RMS/peak", "Attack",
-    "Release", "Threshold", "Ratio", "Knee\nradius", "Makeup\ngain"
-};
-
-static const char *psz_comp_control_units[] =
+    const char *psz_name;
+    const char *psz_descs;
+    const char *psz_units;
+    const float f_min;      // min
+    const float f_max;      // max
+    const float f_value;    // value
+    const float f_resolution; // resolution
+} comp_controls_t;
+
+static const comp_controls_t comp_controls[] =
 {
-    "", " ms", " ms", " dB", ":1", " dB", " dB"
+    { "compressor-rms-peak",    _("RMS/peak"),       "",       0.0f,   1.0f,   0.00f, 0.001f },
+    { "compressor-attack",      _("Attack"),       _(" ms"),   1.5f, 400.0f,  25.00f, 0.100f },
+    { "compressor-release",     _("Release"),      _(" ms"),   2.0f, 800.0f, 100.00f, 0.100f },
+    { "compressor-threshold",   _("Threshold"),    _(" dB"), -30.0f,   0.0f, -11.00f, 0.010f },
+    { "compressor-ratio",       _("Ratio"),          ":1",     1.0f,  20.0f,   8.00f, 0.010f },
+    { "compressor-knee",        _("Knee\nradius"), _(" dB"),   1.0f,  10.0f,   2.50f, 0.010f },
+    { "compressor-makeup-gain", _("Makeup\ngain"), _(" dB"),   0.0f,  24.0f,   7.00f, 0.010f },
 };
 
-static const float f_comp_min_max_val_res_data[] =
+Compressor::Compressor( intf_thread_t *_p_intf, QWidget *_parent )
+           : QWidget( _parent ) , p_intf( _p_intf )
 {
-    // min     max   value  resolution
-    //----  ------  ------  ----------
-      0.0f,   1.0f,   0.00f, 0.001f,  // RMS/peak
-      1.5f, 400.0f,  25.00f, 0.100f,  // Attack
-      2.0f, 800.0f, 100.00f, 0.100f,  // Release
-    -30.0f,   0.0f, -11.00f, 0.010f,  // Threshold
-      1.0f,  20.0f,   8.00f, 0.010f,  // Ratio
-      1.0f,  10.0f,   2.50f, 0.010f,  // Knee radius
-      0.0f,  24.0f,   7.00f, 0.010f   // Makeup gain
-};
-
-Compressor::Compressor( intf_thread_t *_p_intf, QWidget *_parent ) :
-    QWidget( _parent ) , p_intf( _p_intf )
-{
-    QFont smallFont = QApplication::font( static_cast<QWidget*>( 0 ) );
+    QFont smallFont = QApplication::font();
     smallFont.setPointSize( smallFont.pointSize() - 3 );
 
     QGridLayout *layout = new QGridLayout( this );
@@ -1167,30 +1153,33 @@ Compressor::Compressor( intf_thread_t *_p_intf, QWidget *_parent ) :
 
     for( int i = 0 ; i < NUM_CP_CTRL ; i++ )
     {
-        compCtrl[i] = new QSlider( Qt::Vertical );
-
-        const int i_min = (int)( f_comp_min_max_val_res_data[4 * i + 0]
-                               / f_comp_min_max_val_res_data[4 * i + 3] );
-        const int i_max = (int)( f_comp_min_max_val_res_data[4 * i + 1]
-                               / f_comp_min_max_val_res_data[4 * i + 3] );
-        const int i_val = (int)( f_comp_min_max_val_res_data[4 * i + 2]
-                               / f_comp_min_max_val_res_data[4 * i + 3] );
+        const int i_min = (int)( comp_controls[i].f_min
+                               / comp_controls[i].f_resolution );
+        const int i_max = (int)( comp_controls[i].f_max
+                               / comp_controls[i].f_resolution );
+        const int i_val = (int)( comp_controls[i].f_value
+                               / comp_controls[i].f_resolution );
 
+        compCtrl[i] = new QSlider( Qt::Vertical );
         compCtrl[i]->setMinimum( i_min );
         compCtrl[i]->setMaximum( i_max );
         compCtrl[i]->setValue(   i_val );
-        oldControlVars[i] = f_comp_min_max_val_res_data[4 * i + 2];
+
+        oldControlVars[i] = comp_controls[i].f_value;
+
         CONNECT( compCtrl[i], valueChanged( int ), this, setInitValues() );
-        ctrl_texts[i] = new QLabel( qtr( psz_comp_control_descs[i] )
-                                  + qtr( "\n" ) );
+
+        ctrl_texts[i] = new QLabel( qtr( comp_controls[i].psz_descs ) + "\n" );
         ctrl_texts[i]->setFont( smallFont );
         ctrl_texts[i]->setAlignment( Qt::AlignHCenter );
-        ctrl_readout[i] = new QLabel( qtr( "" ) );
+
+        ctrl_readout[i] = new QLabel;
         ctrl_readout[i]->setFont( smallFont );
         ctrl_readout[i]->setAlignment( Qt::AlignHCenter );
-        layout->addWidget( compCtrl[i], 1, i, Qt::AlignHCenter );
+
+        layout->addWidget( compCtrl[i],     1, i, Qt::AlignHCenter );
         layout->addWidget( ctrl_readout[i], 2, i, Qt::AlignHCenter );
-        layout->addWidget( ctrl_texts[i], 3, i, Qt::AlignHCenter );
+        layout->addWidget( ctrl_texts[i],   3, i, Qt::AlignHCenter );
     }
 
     BUTTONACT( enableCheck, enable() );
@@ -1205,7 +1194,7 @@ Compressor::Compressor( intf_thread_t *_p_intf, QWidget *_parent ) :
         for( int i = 0; i < NUM_CP_CTRL; i++ )
         {
             controlVars[i] = var_GetFloat( p_aout,
-                                           psz_comp_control_names[i] );
+                                           comp_controls[i].psz_name );
         }
         vlc_object_release( p_aout );
     }
@@ -1215,7 +1204,7 @@ Compressor::Compressor( intf_thread_t *_p_intf, QWidget *_parent ) :
         for( int i = 0; i < NUM_CP_CTRL; i++ )
         {
             controlVars[i] = config_GetFloat( p_intf,
-                                              psz_comp_control_names[i] );
+                                              comp_controls[i].psz_name );
         }
     }
     if( psz_af && strstr( psz_af, "compressor" ) != NULL )
@@ -1251,9 +1240,8 @@ void Compressor::updateSliders( float * controlVars )
     {
         if( oldControlVars[i] != controlVars[i] )
         {
-            const int i_val = (int)( controlVars[i]
-                                   / f_comp_min_max_val_res_data[4 * i + 3] );
-            compCtrl[i]->setValue( i_val );
+            compCtrl[i]->setValue(
+                    (int)( controlVars[i] / comp_controls[i].f_resolution ) );
         }
     }
 }
@@ -1269,17 +1257,16 @@ void Compressor::setValues( float * controlVars )
 
     for( int i = 0 ; i < NUM_CP_CTRL ; i++ )
     {
-        float f = (float)( compCtrl[i]->value() )
-                * ( f_comp_min_max_val_res_data[4 * i + 3] );
+        float f = (float)( compCtrl[i]->value() ) * ( comp_controls[i].f_resolution );
         ctrl_readout[i]->setText( QString::number( f, 'f', 1 )
-                                + qtr( psz_comp_control_units[i] ) );
+                                + qtr( comp_controls[i].psz_units ) );
         if( oldControlVars[i] != f )
         {
             if( p_aout )
             {
-                var_SetFloat( p_aout, psz_comp_control_names[i], f );
+                var_SetFloat( p_aout, comp_controls[i].psz_name, f );
             }
-            config_PutFloat( p_intf, psz_comp_control_names[i], f );
+            config_PutFloat( p_intf, comp_controls[i].psz_name, f );
             oldControlVars[i] = f;
         }
     }
@@ -1292,14 +1279,23 @@ void Compressor::setValues( float * controlVars )
 /**********************************************************************
  * Spatializer
  **********************************************************************/
-static const char *psz_control_names[] =
+typedef struct
+{
+    const char *psz_name;
+    const char *psz_desc;
+} spat_controls_t;
+
+static const spat_controls_t spat_controls[] =
 {
-    "spatializer-roomsize", "spatializer-width",
-    "spatializer-wet", "spatializer-dry", "spatializer-damp"
+    { "spatializer-roomsize", _("Size") },
+    { "spatializer-width",    _("Width") },
+    { "spatializer-wet",      _("Wet") },
+    { "spatializer-dry",      _("Dry") },
+    { "spatializer-damp",     _("Damp") },
 };
 
-Spatializer::Spatializer( intf_thread_t *_p_intf, QWidget *_parent ) :
-    QWidget( _parent ) , p_intf( _p_intf )
+Spatializer::Spatializer( intf_thread_t *_p_intf, QWidget *_parent )
+            : QWidget( _parent ) , p_intf( _p_intf )
 {
     QFont smallFont = QApplication::font();
     smallFont.setPointSize( smallFont.pointSize() - 3 );
@@ -1324,15 +1320,20 @@ Spatializer::Spatializer( intf_thread_t *_p_intf, QWidget *_parent ) :
             spatCtrl[i]->setValue( 0 );
             spatCtrl[i]->setMinimum( -10 );
         }
+
         oldControlVars[i] = spatCtrl[i]->value();
+
         CONNECT( spatCtrl[i], valueChanged( int ), this, setInitValues() );
-        ctrl_texts[i] = new QLabel( qfu( psz_control_names[i] ) + "\n" );
+
+        ctrl_texts[i] = new QLabel( qtr( spat_controls[i].psz_desc ) + "\n" );
         ctrl_texts[i]->setFont( smallFont );
-        ctrl_readout[i] = new QLabel( "" );
+
+        ctrl_readout[i] = new QLabel;
         ctrl_readout[i]->setFont( smallFont );
-        layout->addWidget( spatCtrl[i], 1, i );
-        layout->addWidget( ctrl_readout[i], 2, i );
-        layout->addWidget( ctrl_texts[i], 3, i );
+
+        layout->addWidget( spatCtrl[i],     1, i, Qt::AlignHCenter );
+        layout->addWidget( ctrl_readout[i], 2, i, Qt::AlignHCenter );
+        layout->addWidget( ctrl_texts[i],   3, i, Qt::AlignHCenter );
     }
 
     BUTTONACT( enableCheck, enable() );
@@ -1346,7 +1347,7 @@ Spatializer::Spatializer( intf_thread_t *_p_intf, QWidget *_parent ) :
         psz_af = var_GetNonEmptyString( p_aout, "audio-filter" );
         for( int i = 0; i < NUM_SP_CTRL ; i++ )
         {
-            controlVars[i] = var_GetFloat( p_aout, psz_control_names[i] );
+            controlVars[i] = var_GetFloat( p_aout, spat_controls[i].psz_name );
         }
         vlc_object_release( p_aout );
     }
@@ -1355,7 +1356,7 @@ Spatializer::Spatializer( intf_thread_t *_p_intf, QWidget *_parent ) :
         psz_af = config_GetPsz( p_intf, "audio-filter" );
         for( int i = 0; i < NUM_SP_CTRL ; i++ )
         {
-            controlVars[i] = config_GetFloat( p_intf, psz_control_names[i] );
+            controlVars[i] = config_GetFloat( p_intf, spat_controls[i].psz_name );
         }
     }
     if( psz_af && strstr( psz_af, "spatializer" ) != NULL )
@@ -1365,10 +1366,6 @@ Spatializer::Spatializer( intf_thread_t *_p_intf, QWidget *_parent ) :
     setValues( controlVars );
 }
 
-Spatializer::~Spatializer()
-{
-}
-
 void Spatializer::enable()
 {
     bool en = enableCheck->isChecked();
@@ -1405,9 +1402,9 @@ void Spatializer::setValues( float *controlVars )
         {
             if( oldControlVars[i] != spatCtrl[i]->value() )
             {
-                var_SetFloat( p_aout, psz_control_names[i],
+                var_SetFloat( p_aout, spat_controls[i].psz_name,
                         ( float )spatCtrl[i]->value() );
-                config_PutFloat( p_intf, psz_control_names[i],
+                config_PutFloat( p_intf, spat_controls[i].psz_name,
                         ( float ) spatCtrl[i]->value() );
                 oldControlVars[i] = ( float ) spatCtrl[i]->value();
             }