1 /*****************************************************************************
2 * preferences_widgets.hpp : Widgets for preferences panels
3 ****************************************************************************
4 * Copyright (C) 2006 the VideoLAN team
7 * Authors: Clément Stenac <zorglub@videolan.org>
8 * Antoine Cellerier <dionoea@videolan.org>
9 * Jean-Baptiste Kempf <jb@videolan.org>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24 *****************************************************************************/
26 #ifndef _INFOPANELS_H_
27 #define _INFOPANELS_H_
30 #include <QTreeWidget>
33 #include <QDoubleSpinBox>
40 #include <QPushButton>
47 class ConfigControl : public QObject
51 ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf,
52 QWidget *p ) : p_this( _p_this ), p_item( _p_conf )
54 widget = new QWidget( p );
56 ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf ) :
57 p_this (_p_this ), p_item( _p_conf )
61 virtual ~ConfigControl() {};
62 virtual int getType() = 0;
63 const char * getName() { return p_item->psz_name; }
64 QWidget *getWidget() { assert( widget ); return widget; }
65 bool isAdvanced() { return p_item->b_advanced; }
66 virtual void hide() { getWidget()->hide(); };
67 virtual void show() { getWidget()->show(); };
69 static ConfigControl * createControl( vlc_object_t*,
70 module_config_t*,QWidget* );
71 static ConfigControl * createControl( vlc_object_t*,
72 module_config_t*,QWidget*,
73 QGridLayout *, int& );
74 void doApply( intf_thread_t *);
77 module_config_t *p_item;
85 /*******************************************************
86 * Integer-based controls
87 *******************************************************/
88 class VIntConfigControl : public ConfigControl
92 VIntConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
93 ConfigControl(a,b,c) {};
94 VIntConfigControl( vlc_object_t *a, module_config_t *b ) :
95 ConfigControl(a,b) {};
96 virtual ~VIntConfigControl() {};
97 virtual int getValue() = 0;
98 virtual int getType() { return 1; }
101 class IntegerConfigControl : public VIntConfigControl
105 IntegerConfigControl( vlc_object_t *, module_config_t *, QWidget *,
106 QGridLayout *, int& );
107 IntegerConfigControl( vlc_object_t *, module_config_t *,
108 QLabel*, QSpinBox* );
109 IntegerConfigControl( vlc_object_t *, module_config_t *,
111 virtual ~IntegerConfigControl() {};
112 virtual int getValue();
113 virtual void show() { spin->show(); label->show(); }
114 virtual void hide() { spin->hide(); label->hide(); }
123 class IntegerRangeConfigControl : public IntegerConfigControl
126 IntegerRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
127 QGridLayout *, int& );
128 IntegerRangeConfigControl( vlc_object_t *, module_config_t *,
129 QLabel*, QSpinBox* );
134 class IntegerRangeSliderConfigControl : public VIntConfigControl
137 IntegerRangeSliderConfigControl( vlc_object_t *, module_config_t *,
138 QLabel *, QSlider * );
139 virtual ~IntegerRangeSliderConfigControl() {};
140 virtual int getValue();
148 class IntegerListConfigControl : public VIntConfigControl
151 IntegerListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
152 bool, QGridLayout*, int& );
153 IntegerListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
155 virtual ~IntegerListConfigControl() {};
156 virtual int getValue();
157 virtual void hide() { combo->hide(); label->hide(); }
158 virtual void show() { combo->show(); label->show(); }
165 class BoolConfigControl : public VIntConfigControl
168 BoolConfigControl( vlc_object_t *, module_config_t *, QWidget *,
169 QGridLayout *, int& );
170 BoolConfigControl( vlc_object_t *, module_config_t *,
171 QLabel *, QCheckBox*, bool );
172 virtual ~BoolConfigControl() {};
173 virtual int getValue();
174 virtual void show() { checkbox->show(); }
175 virtual void hide() { checkbox->hide(); }
181 /*******************************************************
182 * Float-based controls
183 *******************************************************/
184 class VFloatConfigControl : public ConfigControl
188 VFloatConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
189 ConfigControl(a,b,c) {};
190 VFloatConfigControl( vlc_object_t *a, module_config_t *b ) :
191 ConfigControl(a,b) {};
192 virtual ~VFloatConfigControl() {};
193 virtual float getValue() = 0;
194 virtual int getType() { return 2; }
197 class FloatConfigControl : public VFloatConfigControl
201 FloatConfigControl( vlc_object_t *, module_config_t *, QWidget *,
202 QGridLayout *, int& );
203 FloatConfigControl( vlc_object_t *, module_config_t *,
204 QLabel*, QDoubleSpinBox* );
205 virtual ~FloatConfigControl() {};
206 virtual float getValue();
207 virtual void show() { spin->show(); label->show(); }
208 virtual void hide() { spin->hide(); label->hide(); }
211 QDoubleSpinBox *spin;
218 class FloatRangeConfigControl : public FloatConfigControl
222 FloatRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
223 QGridLayout *, int& );
224 FloatRangeConfigControl( vlc_object_t *, module_config_t *,
225 QLabel*, QDoubleSpinBox* );
230 /*******************************************************
231 * String-based controls
232 *******************************************************/
233 class VStringConfigControl : public ConfigControl
237 VStringConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
238 ConfigControl(a,b,c) {};
239 VStringConfigControl( vlc_object_t *a, module_config_t *b ) :
240 ConfigControl(a,b) {};
241 virtual ~VStringConfigControl() {};
242 virtual QString getValue() = 0;
243 virtual int getType() { return 3; }
246 class StringConfigControl : public VStringConfigControl
250 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *,
251 QGridLayout *, int&, bool pwd );
252 StringConfigControl( vlc_object_t *, module_config_t *, QLabel *,
253 QLineEdit*, bool pwd );
254 virtual ~StringConfigControl() {};
255 virtual QString getValue() { return text->text(); };
256 virtual void show() { text->show(); label->show(); }
257 virtual void hide() { text->hide(); label->hide(); }
264 class FileConfigControl : public VStringConfigControl
268 FileConfigControl( vlc_object_t *, module_config_t *, QWidget *,
269 QGridLayout *, int&, bool pwd );
270 FileConfigControl( vlc_object_t *, module_config_t *, QLabel *,
271 QLineEdit *, QPushButton *, bool pwd );
272 virtual ~FileConfigControl() {};
273 virtual QString getValue() { return text->text(); };
274 virtual void show() { text->show(); label->show(); browse->show(); }
275 virtual void hide() { text->hide(); label->hide(); browse->hide(); }
277 virtual void updateField();
286 class DirectoryConfigControl : public FileConfigControl
290 DirectoryConfigControl( vlc_object_t *, module_config_t *, QWidget *,
291 QGridLayout *, int&, bool pwd );
292 DirectoryConfigControl( vlc_object_t *, module_config_t *, QLabel *,
293 QLineEdit *, QPushButton *, bool pwd );
294 virtual ~DirectoryConfigControl() {};
295 virtual QString getValue() { return text->text(); };
296 virtual void show() { text->show(); label->show(); browse->show(); }
297 virtual void hide() { text->hide(); label->hide(); browse->hide(); }
299 virtual void updateField();
306 class ModuleConfigControl : public VStringConfigControl
309 ModuleConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool,
310 QGridLayout*, int& );
311 ModuleConfigControl( vlc_object_t *, module_config_t *, QLabel *,
313 virtual ~ModuleConfigControl() {};
314 virtual QString getValue();
315 virtual void hide() { combo->hide(); label->hide(); }
316 virtual void show() { combo->show(); label->show(); }
323 class ModuleListConfigControl : public VStringConfigControl
327 ModuleListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
328 bool, QGridLayout*, int& );
329 // ModuleListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
330 // QComboBox*, bool );
331 virtual ~ModuleListConfigControl();
332 virtual QString getValue();
336 void wakeUp_TheUserJustClickedOnSomething( int value );
339 QVector<QCheckBox*> modules;
344 class StringListConfigControl : public VStringConfigControl
347 StringListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
348 bool, QGridLayout*, int& );
349 StringListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
351 virtual ~StringListConfigControl() {};
352 virtual QString getValue();
353 virtual void hide() { combo->hide(); label->hide(); }
354 virtual void show() { combo->show(); label->show(); }
361 struct ModuleCheckBox {
366 class ModuleListConfigControl : public ConfigControl
369 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool
371 virtual ~StringConfigControl();
372 virtual QString getValue();
374 std::vector<ModuleCheckBox> checkboxes;
381 /**********************************************************************
382 * Key selector widget
383 **********************************************************************/
384 class KeyInputDialog : public QDialog
387 KeyInputDialog( QList<module_config_t *> &, const char * );
391 void keyPressEvent( QKeyEvent *);
394 const char * keyToChange;
395 QList<module_config_t*> values;
398 class KeySelectorControl : public ConfigControl
402 KeySelectorControl( vlc_object_t *, module_config_t *, QWidget *,
403 QGridLayout*, int& );
404 virtual int getType() { return 4; }
405 virtual ~KeySelectorControl() {};
406 virtual void hide() { table->hide(); label->hide(); }
407 virtual void show() { table->show(); label->show(); }
413 QList<module_config_t *> values;
415 void selectKey( QTreeWidgetItem *);