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;
92 /*******************************************************
93 * Integer-based controls
94 *******************************************************/
95 class VIntConfigControl : public ConfigControl
99 VIntConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
100 ConfigControl(a,b,c) {};
101 VIntConfigControl( vlc_object_t *a, module_config_t *b ) :
102 ConfigControl(a,b) {};
103 virtual ~VIntConfigControl() {};
104 virtual int getValue() = 0;
105 virtual int getType() { return 1; }
108 class IntegerConfigControl : public VIntConfigControl
112 IntegerConfigControl( vlc_object_t *, module_config_t *, QWidget *,
113 QGridLayout *, int& );
114 IntegerConfigControl( vlc_object_t *, module_config_t *,
115 QLabel*, QSpinBox* );
116 IntegerConfigControl( vlc_object_t *, module_config_t *,
118 virtual ~IntegerConfigControl() {};
119 virtual int getValue();
120 virtual void show() { spin->show(); if( label ) label->show(); }
121 virtual void hide() { spin->hide(); if( label ) label->hide(); }
130 class IntegerRangeConfigControl : public IntegerConfigControl
133 IntegerRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
134 QGridLayout *, int& );
135 IntegerRangeConfigControl( vlc_object_t *, module_config_t *,
136 QLabel*, QSpinBox* );
141 class IntegerRangeSliderConfigControl : public VIntConfigControl
144 IntegerRangeSliderConfigControl( vlc_object_t *, module_config_t *,
145 QLabel *, QSlider * );
146 virtual ~IntegerRangeSliderConfigControl() {};
147 virtual int getValue();
155 class IntegerListConfigControl : public VIntConfigControl
158 IntegerListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
159 bool, QGridLayout*, int& );
160 IntegerListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
162 virtual ~IntegerListConfigControl() {};
163 virtual int getValue();
164 virtual void hide() { combo->hide(); if( label ) label->hide(); }
165 virtual void show() { combo->show(); if( label ) label->show(); }
172 class BoolConfigControl : public VIntConfigControl
175 BoolConfigControl( vlc_object_t *, module_config_t *, QWidget *,
176 QGridLayout *, int& );
177 BoolConfigControl( vlc_object_t *, module_config_t *,
178 QLabel *, QCheckBox*, bool );
179 virtual ~BoolConfigControl() {};
180 virtual int getValue();
181 virtual void show() { checkbox->show(); }
182 virtual void hide() { checkbox->hide(); }
188 /*******************************************************
189 * Float-based controls
190 *******************************************************/
191 class VFloatConfigControl : public ConfigControl
195 VFloatConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
196 ConfigControl(a,b,c) {};
197 VFloatConfigControl( vlc_object_t *a, module_config_t *b ) :
198 ConfigControl(a,b) {};
199 virtual ~VFloatConfigControl() {};
200 virtual float getValue() = 0;
201 virtual int getType() { return 2; }
204 class FloatConfigControl : public VFloatConfigControl
208 FloatConfigControl( vlc_object_t *, module_config_t *, QWidget *,
209 QGridLayout *, int& );
210 FloatConfigControl( vlc_object_t *, module_config_t *,
211 QLabel*, QDoubleSpinBox* );
212 virtual ~FloatConfigControl() {};
213 virtual float getValue();
214 virtual void show() { spin->show(); if( label ) label->show(); }
215 virtual void hide() { spin->hide(); if( label ) label->hide(); }
218 QDoubleSpinBox *spin;
225 class FloatRangeConfigControl : public FloatConfigControl
229 FloatRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
230 QGridLayout *, int& );
231 FloatRangeConfigControl( vlc_object_t *, module_config_t *,
232 QLabel*, QDoubleSpinBox* );
237 /*******************************************************
238 * String-based controls
239 *******************************************************/
240 class VStringConfigControl : public ConfigControl
244 VStringConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
245 ConfigControl(a,b,c) {};
246 VStringConfigControl( vlc_object_t *a, module_config_t *b ) :
247 ConfigControl(a,b) {};
248 virtual ~VStringConfigControl() {};
249 virtual QString getValue() = 0;
250 virtual int getType() { return 3; }
253 class StringConfigControl : public VStringConfigControl
257 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *,
258 QGridLayout *, int&, bool pwd );
259 StringConfigControl( vlc_object_t *, module_config_t *, QLabel *,
260 QLineEdit*, bool pwd );
261 virtual ~StringConfigControl() {};
262 virtual QString getValue() { return text->text(); };
263 virtual void show() { text->show(); if( label ) label->show(); }
264 virtual void hide() { text->hide(); if( label ) label->hide(); }
271 class FileConfigControl : public VStringConfigControl
275 FileConfigControl( vlc_object_t *, module_config_t *, QWidget *,
276 QGridLayout *, int&, bool pwd );
277 FileConfigControl( vlc_object_t *, module_config_t *, QLabel *,
278 QLineEdit *, QPushButton *, bool pwd );
279 virtual ~FileConfigControl() {};
280 virtual QString getValue() { return text->text(); };
281 virtual void show() { text->show(); if( label ) label->show(); browse->show(); }
282 virtual void hide() { text->hide(); if( label ) label->hide(); browse->hide(); }
284 virtual void updateField();
292 class DirectoryConfigControl : public FileConfigControl
296 DirectoryConfigControl( vlc_object_t *, module_config_t *, QWidget *,
297 QGridLayout *, int&, bool pwd );
298 DirectoryConfigControl( vlc_object_t *, module_config_t *, QLabel *,
299 QLineEdit *, QPushButton *, bool pwd );
300 virtual ~DirectoryConfigControl() {};
302 virtual void updateField();
305 class FontConfigControl : public FileConfigControl
309 FontConfigControl( vlc_object_t *, module_config_t *, QWidget *,
310 QGridLayout *, int&, bool pwd );
311 FontConfigControl( vlc_object_t *, module_config_t *, QLabel *,
312 QLineEdit *, QPushButton *, bool pwd );
313 virtual ~FontConfigControl() {};
315 virtual void updateField();
318 class ModuleConfigControl : public VStringConfigControl
321 ModuleConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool,
322 QGridLayout*, int& );
323 ModuleConfigControl( vlc_object_t *, module_config_t *, QLabel *,
325 virtual ~ModuleConfigControl() {};
326 virtual QString getValue();
327 virtual void hide() { combo->hide(); if( label ) label->hide(); }
328 virtual void show() { combo->show(); if( label ) label->show(); }
335 struct checkBoxListItem {
340 class ModuleListConfigControl : public VStringConfigControl
344 ModuleListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
345 bool, QGridLayout*, int& );
346 // ModuleListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
347 // QComboBox*, bool );
348 virtual ~ModuleListConfigControl();
349 virtual QString getValue();
353 void onUpdate( int value );
356 QVector<checkBoxListItem*> modules;
361 class StringListConfigControl : public VStringConfigControl
365 StringListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
366 bool, QGridLayout*, int& );
367 StringListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
369 virtual ~StringListConfigControl() {};
370 virtual QString getValue();
371 virtual void hide() { combo->hide(); if( label ) label->hide(); }
372 virtual void show() { combo->show(); if( label ) label->show(); }
378 void actionRequested( int );
382 void setfillVLCConfigCombo(const char *configname, intf_thread_t *p_intf,
383 QComboBox *combo, QWidget *parent = 0 );
387 struct ModuleCheckBox {
392 class ModuleListConfigControl : public ConfigControl
395 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool
397 virtual ~StringConfigControl();
398 virtual QString getValue();
400 std::vector<ModuleCheckBox> checkboxes;
407 /**********************************************************************
408 * Key selector widget
409 **********************************************************************/
410 class KeyInputDialog : public QDialog
413 KeyInputDialog( QList<module_config_t *> &, const char * );
417 void checkForConflicts( int i_vlckey );
418 void keyPressEvent( QKeyEvent *);
419 void wheelEvent( QWheelEvent *);
422 const char * keyToChange;
423 QList<module_config_t*> values;
426 class KeySelectorControl : public ConfigControl
430 KeySelectorControl( vlc_object_t *, module_config_t *, QWidget *,
431 QGridLayout*, int& );
432 virtual int getType() { return 4; }
433 virtual ~KeySelectorControl() {};
434 virtual void hide() { table->hide(); if( label ) label->hide(); }
435 virtual void show() { table->show(); if( label ) label->show(); }
441 QList<module_config_t *> values;
443 void selectKey( QTreeWidgetItem *);