]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/extended_panels.hpp
Qt: Equalizer: rework (fix #7923)
[vlc] / modules / gui / qt4 / components / extended_panels.hpp
1 /*****************************************************************************
2  * extended_panels.hpp : Exentended Panels
3  ****************************************************************************
4  * Copyright (C) 2006 the VideoLAN team
5  * $Id$
6  *
7  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
8  *          Antoine Cellerier <dionoea at videolan dot org>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 #ifndef _EQUALIZER_H_
26 #define _EQUALIZER_H_
27
28 #ifdef HAVE_CONFIG_H
29 # include "config.h"
30 #endif
31
32 #include <vlc_common.h>
33
34 #include "ui/equalizer.h"
35 #include "ui/video_effects.h"
36
37 #include <QTabWidget>
38
39 #define BANDS 10
40
41 class QSignalMapper;
42
43 class ExtVideo: public QObject
44 {
45     Q_OBJECT
46     friend class ExtendedDialog;
47 public:
48     ExtVideo( struct intf_thread_t *, QTabWidget * );
49     /*void gotoConf( QObject* );*/
50 private:
51     Ui::ExtVideoWidget ui;
52     QSignalMapper* filterMapper;
53     intf_thread_t *p_intf;
54     void initComboBoxItems( QObject* );
55     void setWidgetValue( QObject* );
56     void clean();
57 private slots:
58     void updateFilters();
59     void updateFilterOptions();
60     void cropChange();
61     void browseLogo();
62     void browseEraseFile();
63 };
64
65 class ExtV4l2 : public QWidget
66 {
67     Q_OBJECT
68 public:
69     ExtV4l2( intf_thread_t *, QWidget * );
70
71     virtual void showEvent( QShowEvent *event );
72
73 private:
74     intf_thread_t *p_intf;
75     QGroupBox *box;
76     QLabel *help;
77
78 private slots:
79     void Refresh( void );
80     void ValueChange( int value );
81     void ValueChange( bool value );
82 };
83
84 class FilterSliderData : public QObject
85 {
86     Q_OBJECT
87
88 public:
89     typedef struct
90     {
91         QString name;
92         QString descs;
93         QString units;
94         float f_min;      // min
95         float f_max;      // max
96         float f_value;    // value
97         float f_resolution; // resolution
98         float f_visual_multiplier; // only for display (f_value *)
99     } slider_data_t;
100     FilterSliderData( QObject *parent, intf_thread_t *p_intf,
101                       QSlider *slider,
102                       QLabel *valueLabel, QLabel *nameLabel,
103                       const slider_data_t *p_data );
104     void setValue( float f );
105
106 protected:
107     FilterSliderData( QObject *parent, QSlider *slider );
108     virtual float initialValue();
109     QSlider *slider;
110     QLabel *valueLabel;
111     QLabel *nameLabel;
112     const slider_data_t *p_data;
113     intf_thread_t *p_intf;
114
115 public slots:
116     virtual void onValueChanged( int i ) const;
117     virtual void updateText( int i );
118     virtual void writeToConfig() const;
119 };
120
121 class AudioFilterControlWidget : public QWidget
122 {
123     Q_OBJECT
124
125 public:
126     AudioFilterControlWidget( intf_thread_t *, QWidget *, const char *name );
127     virtual ~AudioFilterControlWidget();
128
129 protected:
130     virtual void build();
131     QVector<FilterSliderData::slider_data_t> controls;
132     QGroupBox *slidersBox;
133     intf_thread_t *p_intf;
134     QString name; // filter's module name
135     int i_smallfont;
136
137 protected slots:
138     void enable( bool ) const;
139 };
140
141 class EqualizerSliderData : public FilterSliderData
142 {
143     Q_OBJECT
144
145 public:
146     EqualizerSliderData( QObject *parent, intf_thread_t *p_intf,
147                          QSlider *slider,
148                          QLabel *valueLabel, QLabel *nameLabel,
149                          const slider_data_t *p_data, int index );
150
151 protected:
152     virtual float initialValue();
153     int index;
154     QStringList getBandsFromAout() const;
155
156 public slots:
157     virtual void onValueChanged( int i ) const;
158     virtual void writeToConfig() const;
159 };
160
161 class Equalizer: public AudioFilterControlWidget
162 {
163     Q_OBJECT
164
165 public:
166     Equalizer( intf_thread_t *, QWidget * );
167
168 protected:
169     virtual void build();
170
171 private:
172     QVector<FilterSliderData *> eqSliders;
173     FilterSliderData *preamp;
174     FilterSliderData::slider_data_t preamp_values;
175
176 private slots:
177     void setCorePreset( int );
178     void enable2Pass( bool ) const;
179 };
180
181 class Compressor: public AudioFilterControlWidget
182 {
183     Q_OBJECT
184
185 public:
186     Compressor( intf_thread_t *, QWidget * );
187 };
188
189 class Spatializer: public AudioFilterControlWidget
190 {
191     Q_OBJECT
192
193 public:
194     Spatializer( intf_thread_t *, QWidget * );
195 };
196
197 class SyncWidget : public QWidget
198 {
199     Q_OBJECT
200 public:
201     SyncWidget( QWidget * );
202     void setValue( double d );
203 signals:
204     void valueChanged( double );
205 private slots:
206     void valueChangedHandler( double d );
207 private:
208     QDoubleSpinBox spinBox;
209     QLabel spinLabel;
210 };
211
212 class SyncControls : public QWidget
213 {
214     Q_OBJECT
215     friend class ExtendedDialog;
216 public:
217     SyncControls( intf_thread_t *, QWidget * );
218     virtual ~SyncControls();
219 private:
220     intf_thread_t *p_intf;
221     SyncWidget *AVSpin;
222     SyncWidget *subsSpin;
223     QDoubleSpinBox *subSpeedSpin;
224     QDoubleSpinBox *subDurationSpin;
225
226     bool b_userAction;
227
228     void clean();
229
230     void initSubsDuration();
231     void subsdelayClean();
232     void subsdelaySetFactor( double );
233 public slots:
234     void update();
235 private slots:
236     void advanceAudio( double );
237     void advanceSubs( double );
238     void adjustSubsSpeed( double );
239     void adjustSubsDuration( double );
240 };
241
242 #endif