[vlc-commits] Qt: ExtendedDialog: Add sync to config checkbox for audio filters

Francois Cartegnie git at videolan.org
Fri Mar 22 01:52:42 CET 2013


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Thu Mar 21 19:30:57 2013 +0100| [d68625eae3a6b56c4a74f37bf9750a2aedc14f0a] | committer: Francois Cartegnie

Qt: ExtendedDialog: Add sync to config checkbox for audio filters
(fix #7924)

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

 modules/gui/qt4/components/extended_panels.cpp |   31 +++++++++++++++++++++---
 modules/gui/qt4/components/extended_panels.hpp |    8 +++++-
 modules/gui/qt4/dialogs/extended.cpp           |   27 +++++++++++++++++----
 modules/gui/qt4/dialogs/extended.hpp           |    9 +++++++
 4 files changed, 65 insertions(+), 10 deletions(-)

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



More information about the vlc-commits mailing list