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_
39 #include <QTreeWidget>
42 #include <QDoubleSpinBox>
43 #include <QPushButton>
50 class QTreeWidgetItem;
54 class ConfigControl : public QObject
58 ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf,
59 QWidget *p ) : p_this( _p_this ), p_item( _p_conf )
61 widget = new QWidget( p );
63 ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf ) :
64 p_this (_p_this ), p_item( _p_conf )
68 virtual ~ConfigControl() {};
69 virtual int getType() = 0;
70 const char * getName() { return p_item->psz_name; }
71 QWidget *getWidget() { assert( widget ); return widget; }
72 bool isAdvanced() { return p_item->b_advanced; }
73 virtual void hide() { getWidget()->hide(); };
74 virtual void show() { getWidget()->show(); };
76 static ConfigControl * createControl( vlc_object_t*,
77 module_config_t*,QWidget* );
78 static ConfigControl * createControl( vlc_object_t*,
79 module_config_t*,QWidget*,
80 QGridLayout *, int& );
81 void doApply( intf_thread_t *);
84 module_config_t *p_item;
89 /* You shouldn't use that now..*/
95 /*******************************************************
96 * Integer-based controls
97 *******************************************************/
98 class VIntConfigControl : public ConfigControl
102 VIntConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
103 ConfigControl(a,b,c) {};
104 VIntConfigControl( vlc_object_t *a, module_config_t *b ) :
105 ConfigControl(a,b) {};
106 virtual ~VIntConfigControl() {};
107 virtual int getValue() = 0;
108 virtual int getType() { return 1; }
111 class IntegerConfigControl : public VIntConfigControl
115 IntegerConfigControl( vlc_object_t *, module_config_t *, QWidget *,
116 QGridLayout *, int& );
117 IntegerConfigControl( vlc_object_t *, module_config_t *,
118 QLabel*, QSpinBox* );
119 IntegerConfigControl( vlc_object_t *, module_config_t *,
121 virtual ~IntegerConfigControl() {};
122 virtual int getValue();
123 virtual void show() { spin->show(); if( label ) label->show(); }
124 virtual void hide() { spin->hide(); if( label ) label->hide(); }
133 class IntegerRangeConfigControl : public IntegerConfigControl
136 IntegerRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
137 QGridLayout *, int& );
138 IntegerRangeConfigControl( vlc_object_t *, module_config_t *,
139 QLabel*, QSpinBox* );
144 class IntegerRangeSliderConfigControl : public VIntConfigControl
147 IntegerRangeSliderConfigControl( vlc_object_t *, module_config_t *,
148 QLabel *, QSlider * );
149 virtual ~IntegerRangeSliderConfigControl() {};
150 virtual int getValue();
158 class IntegerListConfigControl : public VIntConfigControl
161 IntegerListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
162 bool, QGridLayout*, int& );
163 IntegerListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
165 virtual ~IntegerListConfigControl() {};
166 virtual int getValue();
167 virtual void hide() { combo->hide(); if( label ) label->hide(); }
168 virtual void show() { combo->show(); if( label ) label->show(); }
175 class BoolConfigControl : public VIntConfigControl
178 BoolConfigControl( vlc_object_t *, module_config_t *, QWidget *,
179 QGridLayout *, int& );
180 BoolConfigControl( vlc_object_t *, module_config_t *,
181 QLabel *, QCheckBox*, bool );
182 virtual ~BoolConfigControl() {};
183 virtual int getValue();
184 virtual void show() { checkbox->show(); }
185 virtual void hide() { checkbox->hide(); }
191 /*******************************************************
192 * Float-based controls
193 *******************************************************/
194 class VFloatConfigControl : public ConfigControl
198 VFloatConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
199 ConfigControl(a,b,c) {};
200 VFloatConfigControl( vlc_object_t *a, module_config_t *b ) :
201 ConfigControl(a,b) {};
202 virtual ~VFloatConfigControl() {};
203 virtual float getValue() = 0;
204 virtual int getType() { return 2; }
207 class FloatConfigControl : public VFloatConfigControl
211 FloatConfigControl( vlc_object_t *, module_config_t *, QWidget *,
212 QGridLayout *, int& );
213 FloatConfigControl( vlc_object_t *, module_config_t *,
214 QLabel*, QDoubleSpinBox* );
215 virtual ~FloatConfigControl() {};
216 virtual float getValue();
217 virtual void show() { spin->show(); if( label ) label->show(); }
218 virtual void hide() { spin->hide(); if( label ) label->hide(); }
221 QDoubleSpinBox *spin;
228 class FloatRangeConfigControl : public FloatConfigControl
232 FloatRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
233 QGridLayout *, int& );
234 FloatRangeConfigControl( vlc_object_t *, module_config_t *,
235 QLabel*, QDoubleSpinBox* );
240 /*******************************************************
241 * String-based controls
242 *******************************************************/
243 class VStringConfigControl : public ConfigControl
247 VStringConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
248 ConfigControl(a,b,c) {};
249 VStringConfigControl( vlc_object_t *a, module_config_t *b ) :
250 ConfigControl(a,b) {};
251 virtual ~VStringConfigControl() {};
252 virtual QString getValue() = 0;
253 virtual int getType() { return 3; }
256 class StringConfigControl : public VStringConfigControl
260 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *,
261 QGridLayout *, int&, bool pwd );
262 StringConfigControl( vlc_object_t *, module_config_t *, QLabel *,
263 QLineEdit*, bool pwd );
264 virtual ~StringConfigControl() {};
265 virtual QString getValue() { return text->text(); };
266 virtual void show() { text->show(); if( label ) label->show(); }
267 virtual void hide() { text->hide(); if( label ) label->hide(); }
274 class FileConfigControl : public VStringConfigControl
278 FileConfigControl( vlc_object_t *, module_config_t *, QWidget *,
279 QGridLayout *, int&, bool pwd );
280 FileConfigControl( vlc_object_t *, module_config_t *, QLabel *,
281 QLineEdit *, QPushButton *, bool pwd );
282 virtual ~FileConfigControl() {};
283 virtual QString getValue() { return text->text(); };
284 virtual void show() { text->show(); if( label ) label->show(); browse->show(); }
285 virtual void hide() { text->hide(); if( label ) label->hide(); browse->hide(); }
287 virtual void updateField();
295 class DirectoryConfigControl : public FileConfigControl
299 DirectoryConfigControl( vlc_object_t *, module_config_t *, QWidget *,
300 QGridLayout *, int&, bool pwd );
301 DirectoryConfigControl( vlc_object_t *, module_config_t *, QLabel *,
302 QLineEdit *, QPushButton *, bool pwd );
303 virtual ~DirectoryConfigControl() {};
305 virtual void updateField();
308 class FontConfigControl : public FileConfigControl
312 FontConfigControl( vlc_object_t *, module_config_t *, QWidget *,
313 QGridLayout *, int&, bool pwd );
314 FontConfigControl( vlc_object_t *, module_config_t *, QLabel *,
315 QLineEdit *, QPushButton *, bool pwd );
316 virtual ~FontConfigControl() {};
318 virtual void updateField();
321 class ModuleConfigControl : public VStringConfigControl
324 ModuleConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool,
325 QGridLayout*, int& );
326 ModuleConfigControl( vlc_object_t *, module_config_t *, QLabel *,
328 virtual ~ModuleConfigControl() {};
329 virtual QString getValue();
330 virtual void hide() { combo->hide(); if( label ) label->hide(); }
331 virtual void show() { combo->show(); if( label ) label->show(); }
338 struct checkBoxListItem {
343 class ModuleListConfigControl : public VStringConfigControl
347 ModuleListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
348 bool, QGridLayout*, int& );
349 // ModuleListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
350 // QComboBox*, bool );
351 virtual ~ModuleListConfigControl();
352 virtual QString getValue();
356 void onUpdate( int value );
359 QVector<checkBoxListItem*> modules;
364 class StringListConfigControl : public VStringConfigControl
368 StringListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
369 bool, QGridLayout*, int& );
370 StringListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
372 virtual ~StringListConfigControl() {};
373 virtual QString getValue();
374 virtual void hide() { combo->hide(); if( label ) label->hide(); }
375 virtual void show() { combo->show(); if( label ) label->show(); }
381 void actionRequested( int );
385 void setfillVLCConfigCombo(const char *configname, intf_thread_t *p_intf,
386 QComboBox *combo, QWidget *parent = 0 );
389 struct ModuleCheckBox {
394 class ModuleListConfigControl : public ConfigControl
397 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool
399 virtual ~StringConfigControl();
400 virtual QString getValue();
402 std::vector<ModuleCheckBox> checkboxes;
409 /**********************************************************************
410 * Key selector widget
411 **********************************************************************/
412 class KeyInputDialog : public QDialog
415 KeyInputDialog( QList<module_config_t *> &, const char * );
419 void checkForConflicts( int i_vlckey );
420 void keyPressEvent( QKeyEvent *);
421 void wheelEvent( QWheelEvent *);
424 const char * keyToChange;
425 QList<module_config_t*> values;
428 class KeySelectorControl : public ConfigControl
432 KeySelectorControl( vlc_object_t *, module_config_t *, QWidget *,
433 QGridLayout*, int& );
434 virtual int getType() { return 4; }
435 virtual ~KeySelectorControl() {};
436 virtual void hide() { table->hide(); if( label ) label->hide(); }
437 virtual void show() { table->show(); if( label ) label->show(); }
443 QList<module_config_t *> values;
445 void selectKey( QTreeWidgetItem *);