Commit d68625ea authored by Francois Cartegnie's avatar Francois Cartegnie

Qt: ExtendedDialog: Add sync to config checkbox for audio filters

(fix #7924)
parent 8c2ccecd
...@@ -921,7 +921,9 @@ void ExtV4l2::ValueChange( int value ) ...@@ -921,7 +921,9 @@ void ExtV4l2::ValueChange( int value )
FilterSliderData::FilterSliderData( QObject *parent, QSlider *_slider ) : FilterSliderData::FilterSliderData( QObject *parent, QSlider *_slider ) :
QObject( parent ), slider( _slider ) QObject( parent ), slider( _slider )
{} {
b_save_to_config = false;
}
FilterSliderData::FilterSliderData( QObject *parent, FilterSliderData::FilterSliderData( QObject *parent,
intf_thread_t *_p_intf, intf_thread_t *_p_intf,
...@@ -931,6 +933,7 @@ FilterSliderData::FilterSliderData( QObject *parent, ...@@ -931,6 +933,7 @@ FilterSliderData::FilterSliderData( QObject *parent,
QObject( parent ), slider( _slider ), valueLabel( _label ), QObject( parent ), slider( _slider ), valueLabel( _label ),
nameLabel( _nameLabel ), p_data( _p_data ), p_intf( _p_intf ) nameLabel( _nameLabel ), p_data( _p_data ), p_intf( _p_intf )
{ {
b_save_to_config = false;
slider->setMinimum( p_data->f_min / p_data->f_resolution ); slider->setMinimum( p_data->f_min / p_data->f_resolution );
slider->setMaximum( p_data->f_max / p_data->f_resolution ); slider->setMaximum( p_data->f_max / p_data->f_resolution );
nameLabel->setText( p_data->descs ); nameLabel->setText( p_data->descs );
...@@ -996,10 +999,16 @@ void FilterSliderData::onValueChanged( int i ) const ...@@ -996,10 +999,16 @@ void FilterSliderData::onValueChanged( int i ) const
void FilterSliderData::writeToConfig() const void FilterSliderData::writeToConfig() const
{ {
if ( !b_save_to_config ) return;
float f = ((float) slider->value()) * p_data->f_resolution; float f = ((float) slider->value()) * p_data->f_resolution;
config_PutFloat( p_intf, qtu(p_data->name), f ); config_PutFloat( p_intf, qtu(p_data->name), f );
} }
void FilterSliderData::setSaveToConfig( bool b )
{
b_save_to_config = b;
}
AudioFilterControlWidget::AudioFilterControlWidget AudioFilterControlWidget::AudioFilterControlWidget
( intf_thread_t *_p_intf, QWidget *parent, const char *_name ) : ( intf_thread_t *_p_intf, QWidget *parent, const char *_name ) :
QWidget( parent ), p_intf( _p_intf ), name( _name ), i_smallfont(0) QWidget( parent ), p_intf( _p_intf ), name( _name ), i_smallfont(0)
...@@ -1034,6 +1043,7 @@ void AudioFilterControlWidget::build() ...@@ -1034,6 +1043,7 @@ void AudioFilterControlWidget::build()
ctrlLayout->addWidget( valueLabel, 1, i, Qt::AlignHCenter ); ctrlLayout->addWidget( valueLabel, 1, i, Qt::AlignHCenter );
ctrlLayout->addWidget( nameLabel, 2, i, Qt::AlignHCenter ); ctrlLayout->addWidget( nameLabel, 2, i, Qt::AlignHCenter );
i++; i++;
sliderDatas << filter;
} }
vlc_object_t *p_aout = (vlc_object_t *)THEMIM->getAout(); vlc_object_t *p_aout = (vlc_object_t *)THEMIM->getAout();
...@@ -1065,6 +1075,12 @@ void AudioFilterControlWidget::enable( bool b_enable ) const ...@@ -1065,6 +1075,12 @@ void AudioFilterControlWidget::enable( bool b_enable ) const
playlist_EnableAudioFilter( THEPL, qtu(name), b_enable ); playlist_EnableAudioFilter( THEPL, qtu(name), b_enable );
} }
void AudioFilterControlWidget::setSaveToConfig( bool b_save )
{
foreach( FilterSliderData *f, sliderDatas )
f->setSaveToConfig( b_save );
}
/********************************************************************** /**********************************************************************
* Equalizer * Equalizer
**********************************************************************/ **********************************************************************/
...@@ -1153,6 +1169,7 @@ void EqualizerSliderData::onValueChanged( int i ) const ...@@ -1153,6 +1169,7 @@ void EqualizerSliderData::onValueChanged( int i ) const
void EqualizerSliderData::writeToConfig() const void EqualizerSliderData::writeToConfig() const
{ {
if ( !b_save_to_config ) return;
QStringList bands = getBandsFromAout(); QStringList bands = getBandsFromAout();
if ( bands.count() > index ) if ( bands.count() > index )
{ {
...@@ -1238,7 +1255,7 @@ void Equalizer::build() ...@@ -1238,7 +1255,7 @@ void Equalizer::build()
ctrlLayout->addWidget( slider, 0, i, Qt::AlignHCenter ); ctrlLayout->addWidget( slider, 0, i, Qt::AlignHCenter );
ctrlLayout->addWidget( valueLabel, 2, i, Qt::AlignHCenter ); ctrlLayout->addWidget( valueLabel, 2, i, Qt::AlignHCenter );
ctrlLayout->addWidget( nameLabel, 1, i, Qt::AlignHCenter ); ctrlLayout->addWidget( nameLabel, 1, i, Qt::AlignHCenter );
eqSliders << filter; /* keep track for applying presets */ sliderDatas << filter; /* keep track for applying presets */
i++; i++;
} }
...@@ -1304,6 +1321,12 @@ void Equalizer::build() ...@@ -1304,6 +1321,12 @@ void Equalizer::build()
CONNECT( ui.eq2PassCheck, toggled(bool), this, enable2Pass(bool) ); CONNECT( ui.eq2PassCheck, toggled(bool), this, enable2Pass(bool) );
} }
void Equalizer::setSaveToConfig( bool b_save )
{
AudioFilterControlWidget::setSaveToConfig( b_save );
preamp->setSaveToConfig( b_save );
}
void Equalizer::setCorePreset( int i_preset ) void Equalizer::setCorePreset( int i_preset )
{ {
if( i_preset < 1 ) if( i_preset < 1 )
...@@ -1313,8 +1336,8 @@ void Equalizer::setCorePreset( int i_preset ) ...@@ -1313,8 +1336,8 @@ void Equalizer::setCorePreset( int i_preset )
preamp->setValue( eqz_preset_10b[i_preset].f_preamp ); preamp->setValue( eqz_preset_10b[i_preset].f_preamp );
for ( int i=0; i< qMin( eqz_preset_10b[i_preset].i_band, for ( int i=0; i< qMin( eqz_preset_10b[i_preset].i_band,
eqSliders.count() ) ; i++ ) sliderDatas.count() ) ; i++ )
eqSliders[i]->setValue( eqz_preset_10b[i_preset].f_amp[i] ); sliderDatas[i]->setValue( eqz_preset_10b[i_preset].f_amp[i] );
vlc_object_t *p_aout = (vlc_object_t *)THEMIM->getAout(); vlc_object_t *p_aout = (vlc_object_t *)THEMIM->getAout();
if( p_aout ) if( p_aout )
......
...@@ -111,11 +111,13 @@ protected: ...@@ -111,11 +111,13 @@ protected:
QLabel *nameLabel; QLabel *nameLabel;
const slider_data_t *p_data; const slider_data_t *p_data;
intf_thread_t *p_intf; intf_thread_t *p_intf;
bool b_save_to_config;
public slots: public slots:
virtual void onValueChanged( int i ) const; virtual void onValueChanged( int i ) const;
virtual void updateText( int i ); virtual void updateText( int i );
virtual void writeToConfig() const; virtual void writeToConfig() const;
void setSaveToConfig( bool );
}; };
class AudioFilterControlWidget : public QWidget class AudioFilterControlWidget : public QWidget
...@@ -129,6 +131,7 @@ public: ...@@ -129,6 +131,7 @@ public:
protected: protected:
virtual void build(); virtual void build();
QVector<FilterSliderData::slider_data_t> controls; QVector<FilterSliderData::slider_data_t> controls;
QVector<FilterSliderData *> sliderDatas;
QGroupBox *slidersBox; QGroupBox *slidersBox;
intf_thread_t *p_intf; intf_thread_t *p_intf;
QString name; // filter's module name QString name; // filter's module name
...@@ -136,6 +139,7 @@ protected: ...@@ -136,6 +139,7 @@ protected:
protected slots: protected slots:
void enable( bool ) const; void enable( bool ) const;
virtual void setSaveToConfig( bool );
}; };
class EqualizerSliderData : public FilterSliderData class EqualizerSliderData : public FilterSliderData
...@@ -168,8 +172,10 @@ public: ...@@ -168,8 +172,10 @@ public:
protected: protected:
virtual void build(); virtual void build();
protected slots:
virtual void setSaveToConfig( bool );
private: private:
QVector<FilterSliderData *> eqSliders;
FilterSliderData *preamp; FilterSliderData *preamp;
FilterSliderData::slider_data_t preamp_values; FilterSliderData::slider_data_t preamp_values;
......
...@@ -70,7 +70,7 @@ ExtendedDialog::ExtendedDialog( intf_thread_t *_p_intf ) ...@@ -70,7 +70,7 @@ ExtendedDialog::ExtendedDialog( intf_thread_t *_p_intf )
audioTab->addTab( spatial, qtr( "Spatializer" ) ); audioTab->addTab( spatial, qtr( "Spatializer" ) );
audioLayout->addWidget( audioTab ); audioLayout->addWidget( audioTab );
mainTabW->addTab( audioWidget, qtr( "Audio Effects" ) ); mainTabW->insertTab( AUDIO_TAB, audioWidget, qtr( "Audio Effects" ) );
/* Video Effects */ /* Video Effects */
QWidget *videoWidget = new QWidget; QWidget *videoWidget = new QWidget;
...@@ -81,23 +81,35 @@ ExtendedDialog::ExtendedDialog( intf_thread_t *_p_intf ) ...@@ -81,23 +81,35 @@ ExtendedDialog::ExtendedDialog( intf_thread_t *_p_intf )
videoLayout->addWidget( videoTab ); videoLayout->addWidget( videoTab );
videoTab->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum ); videoTab->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum );
mainTabW->addTab( videoWidget, qtr( "Video Effects" ) ); mainTabW->insertTab( VIDEO_TAB, videoWidget, qtr( "Video Effects" ) );
syncW = new SyncControls( p_intf, videoTab ); syncW = new SyncControls( p_intf, videoTab );
mainTabW->addTab( syncW, qtr( "Synchronization" ) ); mainTabW->insertTab( SYNCHRO_TAB, syncW, qtr( "Synchronization" ) );
if( module_exists( "v4l2" ) ) if( module_exists( "v4l2" ) )
{ {
ExtV4l2 *v4l2 = new ExtV4l2( p_intf, mainTabW ); ExtV4l2 *v4l2 = new ExtV4l2( p_intf, mainTabW );
mainTabW->addTab( v4l2, qtr( "v4l2 controls" ) ); mainTabW->insertTab( V4L2_TAB, v4l2, qtr( "v4l2 controls" ) );
} }
layout->addWidget( mainTabW ); layout->addWidget( mainTabW );
/* Bottom buttons / checkbox line */
QHBoxLayout *buttonsLayout = new QHBoxLayout();
layout->addLayout( buttonsLayout );
writeChangesBox = new QCheckBox( qtr("&Write changes to config") );
buttonsLayout->addWidget( writeChangesBox );
CONNECT( writeChangesBox, toggled(bool), compres, setSaveToConfig(bool) );
CONNECT( writeChangesBox, toggled(bool), spatial, setSaveToConfig(bool) );
CONNECT( writeChangesBox, toggled(bool), equal, setSaveToConfig(bool) );
CONNECT( mainTabW, currentChanged(int), this, currentTabChanged(int) );
QDialogButtonBox *closeButtonBox = new QDialogButtonBox( Qt::Horizontal, this ); QDialogButtonBox *closeButtonBox = new QDialogButtonBox( Qt::Horizontal, this );
closeButtonBox->addButton( closeButtonBox->addButton(
new QPushButton( qtr("&Close"), this ), QDialogButtonBox::RejectRole ); new QPushButton( qtr("&Close"), this ), QDialogButtonBox::RejectRole );
layout->addWidget( closeButtonBox ); buttonsLayout->addWidget( closeButtonBox );
CONNECT( closeButtonBox, rejected(), this, close() ); CONNECT( closeButtonBox, rejected(), this, close() );
/* Restore geometry or move this dialog on the left pane of the MI */ /* Restore geometry or move this dialog on the left pane of the MI */
...@@ -137,3 +149,8 @@ void ExtendedDialog::changedItem( int i_status ) ...@@ -137,3 +149,8 @@ void ExtendedDialog::changedItem( int i_status )
syncW->clean(); syncW->clean();
videoEffect->clean(); videoEffect->clean();
} }
void ExtendedDialog::currentTabChanged( int i )
{
writeChangesBox->setVisible( i == AUDIO_TAB );
}
...@@ -35,6 +35,13 @@ class ExtendedDialog : public QVLCDialog, public Singleton<ExtendedDialog> ...@@ -35,6 +35,13 @@ class ExtendedDialog : public QVLCDialog, public Singleton<ExtendedDialog>
{ {
Q_OBJECT Q_OBJECT
public: public:
enum
{
AUDIO_TAB = 0,
VIDEO_TAB,
SYNCHRO_TAB,
V4L2_TAB
};
void showTab( int i ); void showTab( int i );
int currentTab(); int currentTab();
private: private:
...@@ -45,8 +52,10 @@ private: ...@@ -45,8 +52,10 @@ private:
ExtVideo *videoEffect; ExtVideo *videoEffect;
Equalizer *equal; Equalizer *equal;
QTabWidget *mainTabW; QTabWidget *mainTabW;
QCheckBox *writeChangesBox;
private slots: private slots:
void changedItem( int ); void changedItem( int );
void currentTabChanged( int );
friend class Singleton<ExtendedDialog>; friend class Singleton<ExtendedDialog>;
}; };
......
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