1 /*****************************************************************************
2 * preferences_widgets.hpp : Widgets for preferences panels
3 ****************************************************************************
4 * Copyright (C) 2006-2007 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>
48 class ConfigControl : public QObject
52 ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf,
53 QWidget *p ) : p_this( _p_this ), p_item( _p_conf )
55 widget = new QWidget( p );
57 ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf ) :
58 p_this (_p_this ), p_item( _p_conf )
62 virtual ~ConfigControl() {};
63 virtual int getType() = 0;
64 const char * getName() { return p_item->psz_name; }
65 QWidget *getWidget() { assert( widget ); return widget; }
66 bool isAdvanced() { return p_item->b_advanced; }
67 virtual void hide() { getWidget()->hide(); };
68 virtual void show() { getWidget()->show(); };
70 static ConfigControl * createControl( vlc_object_t*,
71 module_config_t*,QWidget* );
72 static ConfigControl * createControl( vlc_object_t*,
73 module_config_t*,QWidget*,
74 QGridLayout *, int& );
75 void doApply( intf_thread_t *);
78 module_config_t *p_item;
86 /*******************************************************
87 * Integer-based controls
88 *******************************************************/
89 class VIntConfigControl : public ConfigControl
93 VIntConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
94 ConfigControl(a,b,c) {};
95 VIntConfigControl( vlc_object_t *a, module_config_t *b ) :
96 ConfigControl(a,b) {};
97 virtual ~VIntConfigControl() {};
98 virtual int getValue() = 0;
99 virtual int getType() { return 1; }
102 class IntegerConfigControl : public VIntConfigControl
106 IntegerConfigControl( vlc_object_t *, module_config_t *, QWidget *,
107 QGridLayout *, int& );
108 IntegerConfigControl( vlc_object_t *, module_config_t *,
109 QLabel*, QSpinBox* );
110 IntegerConfigControl( vlc_object_t *, module_config_t *,
112 virtual ~IntegerConfigControl() {};
113 virtual int getValue();
114 virtual void show() { spin->show(); label->show(); }
115 virtual void hide() { spin->hide(); label->hide(); }
124 class IntegerRangeConfigControl : public IntegerConfigControl
127 IntegerRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
128 QGridLayout *, int& );
129 IntegerRangeConfigControl( vlc_object_t *, module_config_t *,
130 QLabel*, QSpinBox* );
135 class IntegerRangeSliderConfigControl : public VIntConfigControl
138 IntegerRangeSliderConfigControl( vlc_object_t *, module_config_t *,
139 QLabel *, QSlider * );
140 virtual ~IntegerRangeSliderConfigControl() {};
141 virtual int getValue();
149 class IntegerListConfigControl : public VIntConfigControl
152 IntegerListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
153 bool, QGridLayout*, int& );
154 IntegerListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
156 virtual ~IntegerListConfigControl() {};
157 virtual int getValue();
158 virtual void hide() { combo->hide(); label->hide(); }
159 virtual void show() { combo->show(); label->show(); }
166 class BoolConfigControl : public VIntConfigControl
169 BoolConfigControl( vlc_object_t *, module_config_t *, QWidget *,
170 QGridLayout *, int& );
171 BoolConfigControl( vlc_object_t *, module_config_t *,
172 QLabel *, QCheckBox*, bool );
173 virtual ~BoolConfigControl() {};
174 virtual int getValue();
175 virtual void show() { checkbox->show(); }
176 virtual void hide() { checkbox->hide(); }
182 /*******************************************************
183 * Float-based controls
184 *******************************************************/
185 class VFloatConfigControl : public ConfigControl
189 VFloatConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
190 ConfigControl(a,b,c) {};
191 VFloatConfigControl( vlc_object_t *a, module_config_t *b ) :
192 ConfigControl(a,b) {};
193 virtual ~VFloatConfigControl() {};
194 virtual float getValue() = 0;
195 virtual int getType() { return 2; }
198 class FloatConfigControl : public VFloatConfigControl
202 FloatConfigControl( vlc_object_t *, module_config_t *, QWidget *,
203 QGridLayout *, int& );
204 FloatConfigControl( vlc_object_t *, module_config_t *,
205 QLabel*, QDoubleSpinBox* );
206 virtual ~FloatConfigControl() {};
207 virtual float getValue();
208 virtual void show() { spin->show(); label->show(); }
209 virtual void hide() { spin->hide(); label->hide(); }
212 QDoubleSpinBox *spin;
219 class FloatRangeConfigControl : public FloatConfigControl
223 FloatRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
224 QGridLayout *, int& );
225 FloatRangeConfigControl( vlc_object_t *, module_config_t *,
226 QLabel*, QDoubleSpinBox* );
231 /*******************************************************
232 * String-based controls
233 *******************************************************/
234 class VStringConfigControl : public ConfigControl
238 VStringConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
239 ConfigControl(a,b,c) {};
240 VStringConfigControl( vlc_object_t *a, module_config_t *b ) :
241 ConfigControl(a,b) {};
242 virtual ~VStringConfigControl() {};
243 virtual QString getValue() = 0;
244 virtual int getType() { return 3; }
247 class StringConfigControl : public VStringConfigControl
251 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *,
252 QGridLayout *, int&, bool pwd );
253 StringConfigControl( vlc_object_t *, module_config_t *, QLabel *,
254 QLineEdit*, bool pwd );
255 virtual ~StringConfigControl() {};
256 virtual QString getValue() { return text->text(); };
257 virtual void show() { text->show(); label->show(); }
258 virtual void hide() { text->hide(); label->hide(); }
265 class FileConfigControl : public VStringConfigControl
269 FileConfigControl( vlc_object_t *, module_config_t *, QWidget *,
270 QGridLayout *, int&, bool pwd );
271 FileConfigControl( vlc_object_t *, module_config_t *, QLabel *,
272 QLineEdit *, QPushButton *, bool pwd );
273 virtual ~FileConfigControl() {};
274 virtual QString getValue() { return text->text(); };
275 virtual void show() { text->show(); label->show(); browse->show(); }
276 virtual void hide() { text->hide(); label->hide(); browse->hide(); }
278 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() {};
296 virtual void updateField();
299 class FontConfigControl : public FileConfigControl
303 FontConfigControl( vlc_object_t *, module_config_t *, QWidget *,
304 QGridLayout *, int&, bool pwd );
305 FontConfigControl( vlc_object_t *, module_config_t *, QLabel *,
306 QLineEdit *, QPushButton *, bool pwd );
307 virtual ~FontConfigControl() {};
309 virtual void updateField();
312 class ModuleConfigControl : public VStringConfigControl
315 ModuleConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool,
316 QGridLayout*, int& );
317 ModuleConfigControl( vlc_object_t *, module_config_t *, QLabel *,
319 virtual ~ModuleConfigControl() {};
320 virtual QString getValue();
321 virtual void hide() { combo->hide(); label->hide(); }
322 virtual void show() { combo->show(); label->show(); }
329 class ModuleListConfigControl : public VStringConfigControl
333 ModuleListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
334 bool, QGridLayout*, int& );
335 // ModuleListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
336 // QComboBox*, bool );
337 virtual ~ModuleListConfigControl();
338 virtual QString getValue();
342 void wakeUp_TheUserJustClickedOnSomething( int value );
345 QVector<QCheckBox*> modules;
350 class StringListConfigControl : public VStringConfigControl
353 StringListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
354 bool, QGridLayout*, int& );
355 StringListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
357 virtual ~StringListConfigControl() {};
358 virtual QString getValue();
359 virtual void hide() { combo->hide(); label->hide(); }
360 virtual void show() { combo->show(); label->show(); }
367 struct ModuleCheckBox {
372 class ModuleListConfigControl : public ConfigControl
375 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool
377 virtual ~StringConfigControl();
378 virtual QString getValue();
380 std::vector<ModuleCheckBox> checkboxes;
387 /**********************************************************************
388 * Key selector widget
389 **********************************************************************/
390 class KeyInputDialog : public QDialog
393 KeyInputDialog( QList<module_config_t *> &, const char * );
397 void checkForConflicts( int i_vlckey );
398 void keyPressEvent( QKeyEvent *);
399 void wheelEvent( QWheelEvent *);
402 const char * keyToChange;
403 QList<module_config_t*> values;
406 class KeySelectorControl : public ConfigControl
410 KeySelectorControl( vlc_object_t *, module_config_t *, QWidget *,
411 QGridLayout*, int& );
412 virtual int getType() { return 4; }
413 virtual ~KeySelectorControl() {};
414 virtual void hide() { table->hide(); label->hide(); }
415 virtual void show() { table->show(); label->show(); }
421 QList<module_config_t *> values;
423 void selectKey( QTreeWidgetItem *);