Commit b5d005ce authored by Francois Cartegnie's avatar Francois Cartegnie

Qt: compressor: simplify by grouping

parent 68c78f8b
...@@ -1258,11 +1258,12 @@ Compressor::Compressor( intf_thread_t *_p_intf, QWidget *_parent ) ...@@ -1258,11 +1258,12 @@ Compressor::Compressor( intf_thread_t *_p_intf, QWidget *_parent )
QFont smallFont = QApplication::font(); QFont smallFont = QApplication::font();
smallFont.setPointSize( smallFont.pointSize() - 2 ); smallFont.setPointSize( smallFont.pointSize() - 2 );
QGridLayout *layout = new QGridLayout( this ); QVBoxLayout *layout = new QVBoxLayout( this );
compressorBox = new QGroupBox( qtr( "Enable dynamic range compressor" ) );
enableCheck = new QCheckBox( qtr( "Enable dynamic range compressor" ) ); compressorBox->setCheckable( true );
layout->addWidget( enableCheck, 0, 0, 1, NUM_CP_CTRL ); layout->addWidget( compressorBox );
QGridLayout *ctrlLayout = new QGridLayout( compressorBox );
for( int i = 0 ; i < NUM_CP_CTRL ; i++ ) for( int i = 0 ; i < NUM_CP_CTRL ; i++ )
{ {
const int i_min = (int)( comp_controls[i].f_min const int i_min = (int)( comp_controls[i].f_min
...@@ -1287,16 +1288,14 @@ Compressor::Compressor( intf_thread_t *_p_intf, QWidget *_parent ) ...@@ -1287,16 +1288,14 @@ Compressor::Compressor( intf_thread_t *_p_intf, QWidget *_parent )
ctrl_readout[i]->setFont( smallFont ); ctrl_readout[i]->setFont( smallFont );
ctrl_readout[i]->setAlignment( Qt::AlignHCenter ); ctrl_readout[i]->setAlignment( Qt::AlignHCenter );
layout->addWidget( compCtrl[i], 1, i, Qt::AlignHCenter ); ctrlLayout->addWidget( compCtrl[i], 0, i, Qt::AlignHCenter );
layout->addWidget( ctrl_readout[i], 2, i, Qt::AlignHCenter ); ctrlLayout->addWidget( ctrl_readout[i], 1, i, Qt::AlignHCenter );
layout->addWidget( ctrl_texts[i], 3, i, Qt::AlignHCenter ); ctrlLayout->addWidget( ctrl_texts[i], 2, i, Qt::AlignHCenter );
} }
for( int i = 0; i < NUM_CP_CTRL; i++ ) for( int i = 0; i < NUM_CP_CTRL; i++ )
CONNECT( compCtrl[i], valueChanged( int ), this, setValues() ); CONNECT( compCtrl[i], valueChanged( int ), this, setValues() );
BUTTONACT( enableCheck, enable() );
/* Write down initial values */ /* Write down initial values */
vlc_object_t *p_aout = (vlc_object_t *)THEMIM->getAout(); vlc_object_t *p_aout = (vlc_object_t *)THEMIM->getAout();
char *psz_af; char *psz_af;
...@@ -1320,31 +1319,20 @@ Compressor::Compressor( intf_thread_t *_p_intf, QWidget *_parent ) ...@@ -1320,31 +1319,20 @@ Compressor::Compressor( intf_thread_t *_p_intf, QWidget *_parent )
comp_controls[i].psz_name ); comp_controls[i].psz_name );
} }
} }
if( psz_af && strstr( psz_af, "compressor" ) != NULL ) if( psz_af && strstr( psz_af, "compressor" ) != NULL )
{ compressorBox->setChecked( true );
enableCheck->setChecked( true ); else
} compressorBox->setChecked( false );
free( psz_af ); free( psz_af );
enable( enableCheck->isChecked() );
updateSliders( controlVars ); updateSliders( controlVars );
setValues(); setValues();
} }
void Compressor::enable() void Compressor::enable()
{ {
bool en = enableCheck->isChecked(); playlist_EnableAudioFilter( THEPL, "compressor", compressorBox->isChecked() );
playlist_EnableAudioFilter( THEPL, "compressor", en );
enable( en );
}
void Compressor::enable( bool en )
{
for( int i = 0 ; i < NUM_CP_CTRL ; i++ )
{
compCtrl[i]->setEnabled( en );
ctrl_texts[i]->setEnabled( en );
ctrl_readout[i]->setEnabled( en );
}
} }
void Compressor::updateSliders( float * p_controlVars ) void Compressor::updateSliders( float * p_controlVars )
......
...@@ -127,7 +127,7 @@ private: ...@@ -127,7 +127,7 @@ private:
float controlVars[NUM_CP_CTRL]; float controlVars[NUM_CP_CTRL];
float oldControlVars[NUM_CP_CTRL]; float oldControlVars[NUM_CP_CTRL];
QCheckBox *enableCheck; QGroupBox *compressorBox;
intf_thread_t *p_intf; intf_thread_t *p_intf;
...@@ -137,7 +137,6 @@ private: ...@@ -137,7 +137,6 @@ private:
void updateSliders(float *); void updateSliders(float *);
private slots: private slots:
void enable(bool);
void enable(); void enable();
void setValues(); void setValues();
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment