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
91 VIntConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
92 ConfigControl(a,b,c) {};
93 VIntConfigControl( vlc_object_t *a, module_config_t *b ) :
94 ConfigControl(a,b) {};
95 virtual ~VIntConfigControl() {};
96 virtual int getValue() = 0;
97 virtual int getType() { return 1; }
100 class IntegerConfigControl : public VIntConfigControl
103 IntegerConfigControl( vlc_object_t *, module_config_t *, QWidget *,
104 QGridLayout *, int& );
105 IntegerConfigControl( vlc_object_t *, module_config_t *,
106 QLabel*, QSpinBox* );
107 IntegerConfigControl( vlc_object_t *, module_config_t *,
109 virtual ~IntegerConfigControl() {};
110 virtual int getValue();
111 virtual void show() { spin->show(); label->show(); }
112 virtual void hide() { spin->hide(); label->hide(); }
121 class IntegerRangeConfigControl : public IntegerConfigControl
124 IntegerRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
125 QGridLayout *, int& );
126 IntegerRangeConfigControl( vlc_object_t *, module_config_t *,
127 QLabel*, QSpinBox* );
132 class IntegerRangeSliderConfigControl : public VIntConfigControl
135 IntegerRangeSliderConfigControl( vlc_object_t *, module_config_t *,
136 QLabel *, QSlider * );
137 virtual ~IntegerRangeSliderConfigControl() {};
138 virtual int getValue();
146 class IntegerListConfigControl : public VIntConfigControl
149 IntegerListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
150 bool, QGridLayout*, int& );
151 IntegerListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
153 virtual ~IntegerListConfigControl() {};
154 virtual int getValue();
155 virtual void hide() { combo->hide(); label->hide(); }
156 virtual void show() { combo->show(); label->show(); }
163 class BoolConfigControl : public VIntConfigControl
166 BoolConfigControl( vlc_object_t *, module_config_t *, QWidget *,
167 QGridLayout *, int& );
168 BoolConfigControl( vlc_object_t *, module_config_t *,
169 QLabel *, QCheckBox*, bool );
170 virtual ~BoolConfigControl() {};
171 virtual int getValue();
172 virtual void show() { checkbox->show(); }
173 virtual void hide() { checkbox->hide(); }
179 /*******************************************************
180 * Float-based controls
181 *******************************************************/
182 class VFloatConfigControl : public ConfigControl
185 VFloatConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
186 ConfigControl(a,b,c) {};
187 VFloatConfigControl( vlc_object_t *a, module_config_t *b ) :
188 ConfigControl(a,b) {};
189 virtual ~VFloatConfigControl() {};
190 virtual float getValue() = 0;
191 virtual int getType() { return 2; }
194 class FloatConfigControl : public VFloatConfigControl
197 FloatConfigControl( vlc_object_t *, module_config_t *, QWidget *,
198 QGridLayout *, int& );
199 FloatConfigControl( vlc_object_t *, module_config_t *,
200 QLabel*, QDoubleSpinBox* );
201 virtual ~FloatConfigControl() {};
202 virtual float getValue();
203 virtual void show() { spin->show(); label->show(); }
204 virtual void hide() { spin->hide(); label->hide(); }
207 QDoubleSpinBox *spin;
214 class FloatRangeConfigControl : public FloatConfigControl
217 FloatRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
218 QGridLayout *, int& );
219 FloatRangeConfigControl( vlc_object_t *, module_config_t *,
220 QLabel*, QDoubleSpinBox* );
225 /*******************************************************
226 * String-based controls
227 *******************************************************/
228 class VStringConfigControl : public ConfigControl
231 VStringConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
232 ConfigControl(a,b,c) {};
233 VStringConfigControl( vlc_object_t *a, module_config_t *b ) :
234 ConfigControl(a,b) {};
235 virtual ~VStringConfigControl() {};
236 virtual QString getValue() = 0;
237 virtual int getType() { return 3; }
240 class StringConfigControl : public VStringConfigControl
243 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *,
244 QGridLayout *, int&, bool pwd );
245 StringConfigControl( vlc_object_t *, module_config_t *, QLabel *,
246 QLineEdit*, bool pwd );
247 virtual ~StringConfigControl() {};
248 virtual QString getValue() { return text->text(); };
249 virtual void show() { text->show(); label->show(); }
250 virtual void hide() { text->hide(); label->hide(); }
257 class FileConfigControl : public VStringConfigControl
261 FileConfigControl( vlc_object_t *, module_config_t *, QWidget *,
262 QGridLayout *, int&, bool pwd );
263 FileConfigControl( vlc_object_t *, module_config_t *, QLabel *,
264 QLineEdit *, QPushButton *, bool pwd );
265 virtual ~FileConfigControl() {};
266 virtual QString getValue() { return text->text(); };
267 virtual void show() { text->show(); label->show(); browse->show(); }
268 virtual void hide() { text->hide(); label->hide(); browse->hide(); }
279 class DirectoryConfigControl : public FileConfigControl
283 DirectoryConfigControl( vlc_object_t *, module_config_t *, QWidget *,
284 QGridLayout *, int&, bool pwd );
285 DirectoryConfigControl( vlc_object_t *, module_config_t *, QLabel *,
286 QLineEdit *, QPushButton *, bool pwd );
287 virtual ~DirectoryConfigControl() {};
288 virtual QString getValue() { return text->text(); };
289 virtual void show() { text->show(); label->show(); browse->show(); }
290 virtual void hide() { text->hide(); label->hide(); browse->hide(); }
299 class ModuleConfigControl : public VStringConfigControl
302 ModuleConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool,
303 QGridLayout*, int& );
304 ModuleConfigControl( vlc_object_t *, module_config_t *, QLabel *,
306 virtual ~ModuleConfigControl() {};
307 virtual QString getValue();
308 virtual void hide() { combo->hide(); label->hide(); }
309 virtual void show() { combo->show(); label->show(); }
316 class ModuleListConfigControl : public VStringConfigControl
320 ModuleListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
321 bool, QGridLayout*, int& );
322 // ModuleListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
323 // QComboBox*, bool );
324 virtual ~ModuleListConfigControl();
325 virtual QString getValue();
329 void wakeUp_TheUserJustClickedOnSomething( int value );
332 QVector<QCheckBox*> modules;
337 class StringListConfigControl : public VStringConfigControl
340 StringListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
341 bool, QGridLayout*, int& );
342 StringListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
344 virtual ~StringListConfigControl() {};
345 virtual QString getValue();
346 virtual void hide() { combo->hide(); label->hide(); }
347 virtual void show() { combo->show(); label->show(); }
354 struct ModuleCheckBox {
359 class ModuleListConfigControl : public ConfigControl
362 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool
364 virtual ~StringConfigControl();
365 virtual QString getValue();
367 std::vector<ModuleCheckBox> checkboxes;
374 /**********************************************************************
375 * Key selector widget
376 **********************************************************************/
377 class KeyInputDialog : public QDialog
380 KeyInputDialog( QList<module_config_t *> &, const char * );
384 void keyPressEvent( QKeyEvent *);
387 const char * keyToChange;
388 QList<module_config_t*> values;
391 class KeySelectorControl : public ConfigControl
395 KeySelectorControl( vlc_object_t *, module_config_t *, QWidget *,
396 QGridLayout*, int& );
397 virtual int getType() { return 4; }
398 virtual ~KeySelectorControl() {};
399 virtual void hide() { table->hide(); label->hide(); }
400 virtual void show() { table->show(); label->show(); }
406 QList<module_config_t *> values;
408 void selectKey( QTreeWidgetItem *);