]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/preferences_widgets.hpp
Skeleton for modules list widgets in the prefs. I'm not working on it atm so i figure...
[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 <QLineEdit>
30 #include <QSpinBox>
31 #include <QDoubleSpinBox>
32 #include <QComboBox>
33 #include <QCheckBox>
34 #include <QVector>
35 #include "ui/input_stats.h"
36 #include "qt4.hpp"
37 #include <assert.h>
38
39 class ConfigControl : public QObject
40 {
41     Q_OBJECT;
42 public:
43     ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf,
44                    QWidget *p ) : p_this( _p_this ), p_item( _p_conf )
45     {
46         widget = new QWidget( p );
47     }
48     ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf ) :
49                             p_this (_p_this ), p_item( _p_conf )
50     {
51         widget = NULL;
52     }
53     virtual ~ConfigControl() {};
54     virtual int getType() = 0;
55     char * getName() { return  p_item->psz_name; }
56     QWidget *getWidget() { assert( widget ); return widget; }
57     bool isAdvanced() { return p_item->b_advanced; }
58     virtual void hide() { getWidget()->hide(); };
59     virtual void show() { getWidget()->show(); };
60
61     static ConfigControl * createControl( vlc_object_t*,
62                                           module_config_t*,QWidget* );
63     static ConfigControl * createControl( vlc_object_t*,
64                                           module_config_t*,QWidget*,
65                                           QGridLayout *, int& );
66     void doApply( intf_thread_t *);
67 protected:
68     vlc_object_t *p_this;
69     module_config_t *p_item;
70     QString _name;
71     QWidget *widget;
72     bool _advanced;
73 signals:
74     void Updated();
75 };
76
77 /*******************************************************
78  * Integer-based controls
79  *******************************************************/
80 class VIntConfigControl : public ConfigControl
81 {
82 public:
83     VIntConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
84             ConfigControl(a,b,c) {};
85     VIntConfigControl( vlc_object_t *a, module_config_t *b ) :
86                 ConfigControl(a,b) {};
87     virtual ~VIntConfigControl() {};
88     virtual int getValue() = 0;
89     virtual int getType() { return 1; }
90 };
91
92 class IntegerConfigControl : public VIntConfigControl
93 {
94 public:
95     IntegerConfigControl( vlc_object_t *, module_config_t *, QWidget *,
96                           QGridLayout *, int& );
97     IntegerConfigControl( vlc_object_t *, module_config_t *,
98                           QLabel*, QSpinBox* );
99     virtual ~IntegerConfigControl() {};
100     virtual int getValue();
101     virtual void show() { spin->show(); label->show(); }
102     virtual void hide() { spin->hide(); label->hide(); }
103
104 protected:
105     QSpinBox *spin;
106
107 private:
108     QLabel *label;
109     void finish();
110 };
111
112 class IntegerRangeConfigControl : public IntegerConfigControl
113 {
114 public:
115     IntegerRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
116                                QGridLayout *, int& );
117     IntegerRangeConfigControl( vlc_object_t *, module_config_t *,
118                                QLabel*, QSpinBox* );
119 private:
120     void finish();
121 };
122
123 class IntegerListConfigControl : public VIntConfigControl
124 {
125 public:
126     IntegerListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
127                               bool, QGridLayout*, int& );
128     IntegerListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
129                               QComboBox*, bool );
130     virtual ~IntegerListConfigControl() {};
131     virtual int getValue();
132     virtual void hide() { combo->hide(); label->hide(); }
133     virtual void show() { combo->show(); label->show(); }
134 private:
135     void finish( bool );
136     QLabel *label;
137     QComboBox *combo;
138 };
139
140 class BoolConfigControl : public VIntConfigControl
141 {
142 public:
143     BoolConfigControl( vlc_object_t *, module_config_t *, QWidget *,
144                        QGridLayout *, int& );
145     BoolConfigControl( vlc_object_t *, module_config_t *,
146                        QLabel *, QCheckBox*, bool );
147     virtual ~BoolConfigControl() {};
148     virtual int getValue();
149     virtual void show() { checkbox->show(); }
150     virtual void hide() { checkbox->hide(); }
151 private:
152     QCheckBox *checkbox;
153     void finish();
154 };
155
156 /*******************************************************
157  * Float-based controls
158  *******************************************************/
159 class VFloatConfigControl : public ConfigControl
160 {
161 public:
162     VFloatConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
163                 ConfigControl(a,b,c) {};
164     VFloatConfigControl( vlc_object_t *a, module_config_t *b ) :
165                 ConfigControl(a,b) {};
166     virtual ~VFloatConfigControl() {};
167     virtual float getValue() = 0;
168     virtual int getType() { return 2; }
169 };
170
171 class FloatConfigControl : public VFloatConfigControl
172 {
173 public:
174     FloatConfigControl( vlc_object_t *, module_config_t *, QWidget *,
175                         QGridLayout *, int& );
176     FloatConfigControl( vlc_object_t *, module_config_t *,
177                         QLabel*, QDoubleSpinBox* );
178     virtual ~FloatConfigControl() {};
179     virtual float getValue();
180     virtual void show() { spin->show(); label->show(); }
181     virtual void hide() { spin->hide(); label->hide(); }
182
183 protected:
184     QDoubleSpinBox *spin;
185
186 private:
187     QLabel *label;
188     void finish();
189 };
190
191 class FloatRangeConfigControl : public FloatConfigControl
192 {
193 public:
194     FloatRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
195                              QGridLayout *, int& );
196     FloatRangeConfigControl( vlc_object_t *, module_config_t *,
197                              QLabel*, QDoubleSpinBox* );
198 private:
199     void finish();
200 };
201
202 /*******************************************************
203  * String-based controls
204  *******************************************************/
205 class VStringConfigControl : public ConfigControl
206 {
207 public:
208     VStringConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
209                 ConfigControl(a,b,c) {};
210     VStringConfigControl( vlc_object_t *a, module_config_t *b ) :
211                 ConfigControl(a,b) {};
212     virtual ~VStringConfigControl() {};
213     virtual QString getValue() = 0;
214     virtual int getType() { return 3; }
215 };
216
217 class StringConfigControl : public VStringConfigControl
218 {
219 public:
220     StringConfigControl( vlc_object_t *, module_config_t *, QWidget *,
221                          QGridLayout *, int&,  bool pwd );
222     StringConfigControl( vlc_object_t *, module_config_t *, QLabel *,
223                          QLineEdit*,  bool pwd );
224     virtual ~StringConfigControl() {};
225     virtual QString getValue() { return text->text(); };
226     virtual void show() { text->show(); label->show(); }
227     virtual void hide() { text->hide(); label->hide(); }
228 private:
229     void finish();
230     QLineEdit *text;
231     QLabel *label;
232 };
233
234 class ModuleConfigControl : public VStringConfigControl
235 {
236 public:
237     ModuleConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool,
238                          QGridLayout*, int& );
239     ModuleConfigControl( vlc_object_t *, module_config_t *, QLabel *,
240                          QComboBox*, bool );
241     virtual ~ModuleConfigControl() {};
242     virtual QString getValue();
243     virtual void hide() { combo->hide(); label->hide(); }
244     virtual void show() { combo->show(); label->show(); }
245 private:
246     void finish( bool );
247     QLabel *label;
248     QComboBox *combo;
249 };
250
251 class ModuleListConfigControl : public VStringConfigControl
252 {
253     Q_OBJECT;
254 public:
255     ModuleListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
256                              bool, QGridLayout*, int& );
257 //    ModuleListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
258 //                         QComboBox*, bool );
259     virtual ~ModuleListConfigControl();
260     virtual QString getValue();
261     virtual void hide();
262     virtual void show();
263 public slots:
264     void wakeUp_TheUserJustClickedOnSomething( int value );
265 private:
266     void finish( bool );
267     QVector<QCheckBox*> modules;
268     QLabel *label;
269     QLineEdit *text;
270 };
271
272 class StringListConfigControl : public VStringConfigControl
273 {
274 public:
275     StringListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
276                              bool, QGridLayout*, int& );
277     StringListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
278                              QComboBox*, bool );
279     virtual ~StringListConfigControl() {};
280     virtual QString getValue();
281     virtual void hide() { combo->hide(); label->hide(); }
282     virtual void show() { combo->show(); label->show(); }
283 private:
284     void finish( bool );
285     QLabel *label;
286     QComboBox *combo;
287 };
288 #if 0
289 struct ModuleCheckBox {
290     QCheckBox *checkbox;
291     QString module;
292 };
293
294 class ModuleListConfigControl : public ConfigControl
295 {
296 public:
297     StringConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool
298                          bycat );
299     virtual ~StringConfigControl();
300     virtual QString getValue();
301 private:
302     std::vector<ModuleCheckBox> checkboxes;
303     QLineEdit *text;
304 private slot:
305     void OnUpdate();
306 };
307 #endif
308
309 #endif