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