]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/preferences_widgets.hpp
Qt4: Compile Fix.
[vlc] / modules / gui / qt4 / components / preferences_widgets.hpp
1 /*****************************************************************************
2  * preferences_widgets.hpp : Widgets for preferences panels
3  ****************************************************************************
4  * Copyright (C) 2006 the VideoLAN team
5  * $Id$
6  *
7  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
8  *          Antoine Cellerier <dionoea@videolan.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 _INFOPANELS_H_
26 #define _INFOPANELS_H_
27 #include <vlc/vlc.h>
28 #include <QWidget>
29 #include <QTreeWidget>
30 #include <QLineEdit>
31 #include <QSpinBox>
32 #include <QDoubleSpinBox>
33 #include <QComboBox>
34 #include <QCheckBox>
35 #include <QVector>
36 #include <QDialog>
37 #include <QLabel>
38
39 #include "qt4.hpp"
40 #include <assert.h>
41
42 class QGridLayout;
43
44 class ConfigControl : public QObject
45 {
46     Q_OBJECT;
47 public:
48     ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf,
49                    QWidget *p ) : p_this( _p_this ), p_item( _p_conf )
50     {
51         widget = new QWidget( p );
52     }
53     ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf ) :
54                             p_this (_p_this ), p_item( _p_conf )
55     {
56         widget = NULL;
57     }
58     virtual ~ConfigControl() {};
59     virtual int getType() = 0;
60     const char * getName() { return  p_item->psz_name; }
61     QWidget *getWidget() { assert( widget ); return widget; }
62     bool isAdvanced() { return p_item->b_advanced; }
63     virtual void hide() { getWidget()->hide(); };
64     virtual void show() { getWidget()->show(); };
65
66     static ConfigControl * createControl( vlc_object_t*,
67                                           module_config_t*,QWidget* );
68     static ConfigControl * createControl( vlc_object_t*,
69                                           module_config_t*,QWidget*,
70                                           QGridLayout *, int& );
71     void doApply( intf_thread_t *);
72 protected:
73     vlc_object_t *p_this;
74     module_config_t *p_item;
75     QString _name;
76     QWidget *widget;
77     bool _advanced;
78 signals:
79     void Updated();
80 };
81
82 /*******************************************************
83  * Integer-based controls
84  *******************************************************/
85 class VIntConfigControl : public ConfigControl
86 {
87 public:
88     VIntConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
89             ConfigControl(a,b,c) {};
90     VIntConfigControl( vlc_object_t *a, module_config_t *b ) :
91                 ConfigControl(a,b) {};
92     virtual ~VIntConfigControl() {};
93     virtual int getValue() = 0;
94     virtual int getType() { return 1; }
95 };
96
97 class IntegerConfigControl : public VIntConfigControl
98 {
99 public:
100     IntegerConfigControl( vlc_object_t *, module_config_t *, QWidget *,
101                           QGridLayout *, int& );
102     IntegerConfigControl( vlc_object_t *, module_config_t *,
103                           QLabel*, QSpinBox* );
104     virtual ~IntegerConfigControl() {};
105     virtual int getValue();
106     virtual void show() { spin->show(); label->show(); }
107     virtual void hide() { spin->hide(); label->hide(); }
108
109 protected:
110     QSpinBox *spin;
111
112 private:
113     QLabel *label;
114     void finish();
115 };
116
117 class IntegerRangeConfigControl : public IntegerConfigControl
118 {
119 public:
120     IntegerRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
121                                QGridLayout *, int& );
122     IntegerRangeConfigControl( vlc_object_t *, module_config_t *,
123                                QLabel*, QSpinBox* );
124 private:
125     void finish();
126 };
127
128 class IntegerListConfigControl : public VIntConfigControl
129 {
130 public:
131     IntegerListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
132                               bool, QGridLayout*, int& );
133     IntegerListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
134                               QComboBox*, bool );
135     virtual ~IntegerListConfigControl() {};
136     virtual int getValue();
137     virtual void hide() { combo->hide(); label->hide(); }
138     virtual void show() { combo->show(); label->show(); }
139 private:
140     void finish( bool );
141     QLabel *label;
142     QComboBox *combo;
143 };
144
145 class BoolConfigControl : public VIntConfigControl
146 {
147 public:
148     BoolConfigControl( vlc_object_t *, module_config_t *, QWidget *,
149                        QGridLayout *, int& );
150     BoolConfigControl( vlc_object_t *, module_config_t *,
151                        QLabel *, QCheckBox*, bool );
152     virtual ~BoolConfigControl() {};
153     virtual int getValue();
154     virtual void show() { checkbox->show(); }
155     virtual void hide() { checkbox->hide(); }
156 private:
157     QCheckBox *checkbox;
158     void finish();
159 };
160
161 /*******************************************************
162  * Float-based controls
163  *******************************************************/
164 class VFloatConfigControl : public ConfigControl
165 {
166 public:
167     VFloatConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
168                 ConfigControl(a,b,c) {};
169     VFloatConfigControl( vlc_object_t *a, module_config_t *b ) :
170                 ConfigControl(a,b) {};
171     virtual ~VFloatConfigControl() {};
172     virtual float getValue() = 0;
173     virtual int getType() { return 2; }
174 };
175
176 class FloatConfigControl : public VFloatConfigControl
177 {
178 public:
179     FloatConfigControl( vlc_object_t *, module_config_t *, QWidget *,
180                         QGridLayout *, int& );
181     FloatConfigControl( vlc_object_t *, module_config_t *,
182                         QLabel*, QDoubleSpinBox* );
183     virtual ~FloatConfigControl() {};
184     virtual float getValue();
185     virtual void show() { spin->show(); label->show(); }
186     virtual void hide() { spin->hide(); label->hide(); }
187
188 protected:
189     QDoubleSpinBox *spin;
190
191 private:
192     QLabel *label;
193     void finish();
194 };
195
196 class FloatRangeConfigControl : public FloatConfigControl
197 {
198 public:
199     FloatRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
200                              QGridLayout *, int& );
201     FloatRangeConfigControl( vlc_object_t *, module_config_t *,
202                              QLabel*, QDoubleSpinBox* );
203 private:
204     void finish();
205 };
206
207 /*******************************************************
208  * String-based controls
209  *******************************************************/
210 class VStringConfigControl : public ConfigControl
211 {
212 public:
213     VStringConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
214                 ConfigControl(a,b,c) {};
215     VStringConfigControl( vlc_object_t *a, module_config_t *b ) :
216                 ConfigControl(a,b) {};
217     virtual ~VStringConfigControl() {};
218     virtual QString getValue() = 0;
219     virtual int getType() { return 3; }
220 };
221
222 class StringConfigControl : public VStringConfigControl
223 {
224 public:
225     StringConfigControl( vlc_object_t *, module_config_t *, QWidget *,
226                          QGridLayout *, int&,  bool pwd );
227     StringConfigControl( vlc_object_t *, module_config_t *, QLabel *,
228                          QLineEdit*,  bool pwd );
229     virtual ~StringConfigControl() {};
230     virtual QString getValue() { return text->text(); };
231     virtual void show() { text->show(); label->show(); }
232     virtual void hide() { text->hide(); label->hide(); }
233 private:
234     void finish();
235     QLineEdit *text;
236     QLabel *label;
237 };
238
239 class ModuleConfigControl : public VStringConfigControl
240 {
241 public:
242     ModuleConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool,
243                          QGridLayout*, int& );
244     ModuleConfigControl( vlc_object_t *, module_config_t *, QLabel *,
245                          QComboBox*, bool );
246     virtual ~ModuleConfigControl() {};
247     virtual QString getValue();
248     virtual void hide() { combo->hide(); label->hide(); }
249     virtual void show() { combo->show(); label->show(); }
250 private:
251     void finish( bool );
252     QLabel *label;
253     QComboBox *combo;
254 };
255
256 class ModuleListConfigControl : public VStringConfigControl
257 {
258     Q_OBJECT;
259 public:
260     ModuleListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
261                              bool, QGridLayout*, int& );
262 //    ModuleListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
263 //                         QComboBox*, bool );
264     virtual ~ModuleListConfigControl();
265     virtual QString getValue();
266     virtual void hide();
267     virtual void show();
268 public slots:
269     void wakeUp_TheUserJustClickedOnSomething( int value );
270 private:
271     void finish( bool );
272     QVector<QCheckBox*> modules;
273     QLabel *label;
274     QLineEdit *text;
275 };
276
277 class StringListConfigControl : public VStringConfigControl
278 {
279 public:
280     StringListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
281                              bool, QGridLayout*, int& );
282     StringListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
283                              QComboBox*, bool );
284     virtual ~StringListConfigControl() {};
285     virtual QString getValue();
286     virtual void hide() { combo->hide(); label->hide(); }
287     virtual void show() { combo->show(); label->show(); }
288 private:
289     void finish( bool );
290     QLabel *label;
291     QComboBox *combo;
292 };
293 #if 0
294 struct ModuleCheckBox {
295     QCheckBox *checkbox;
296     QString module;
297 };
298
299 class ModuleListConfigControl : public ConfigControl
300 {
301 public:
302     StringConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool
303                          bycat );
304     virtual ~StringConfigControl();
305     virtual QString getValue();
306 private:
307     std::vector<ModuleCheckBox> checkboxes;
308     QLineEdit *text;
309 private slot:
310     void OnUpdate();
311 };
312 #endif
313
314 /**********************************************************************
315  * Key selector widget
316  **********************************************************************/
317 class KeyInputDialog : public QDialog
318 {
319 public:
320     KeyInputDialog( QList<module_config_t *> &, const char * );
321     int keyValue;
322     bool conflicts;
323 private:
324     void keyPressEvent( QKeyEvent *);
325     QLabel *selected;
326     QLabel *warning;
327     const char * keyToChange;
328     QList<module_config_t*> values;
329 };
330
331 class KeySelectorControl : public ConfigControl
332 {
333     Q_OBJECT;
334 public:
335     KeySelectorControl( vlc_object_t *, module_config_t *, QWidget *,
336                         QGridLayout*, int& );
337     virtual int getType() { return 4; }
338     virtual ~KeySelectorControl() {};
339     virtual void hide() { table->hide(); label->hide(); }
340     virtual void show() { table->show(); label->show(); }
341     void doApply();
342 private:
343     void finish();
344     QLabel *label;
345     QTreeWidget *table;
346     QList<module_config_t *> values;
347 private slots:
348     void selectKey( QTreeWidgetItem *);
349 };
350
351 #endif