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;
53 class QDialogButtonBox;
55 class ConfigControl : public QObject
59 ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf,
60 QWidget *p ) : p_this( _p_this ), p_item( _p_conf )
62 widget = new QWidget( p );
64 ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf ) :
65 p_this (_p_this ), p_item( _p_conf )
69 virtual ~ConfigControl() {};
70 virtual int getType() = 0;
71 const char * getName() { return p_item->psz_name; }
72 QWidget *getWidget() { assert( widget ); return widget; }
73 bool isAdvanced() { return p_item->b_advanced; }
74 virtual void hide() { getWidget()->hide(); };
75 virtual void show() { getWidget()->show(); };
77 static ConfigControl * createControl( vlc_object_t*,
78 module_config_t*,QWidget* );
79 static ConfigControl * createControl( vlc_object_t*,
80 module_config_t*,QWidget*,
81 QGridLayout *, int& );
82 void doApply( intf_thread_t *);
85 module_config_t *p_item;
90 /* You shouldn't use that now..*/
96 /*******************************************************
97 * Integer-based controls
98 *******************************************************/
99 class VIntConfigControl : public ConfigControl
103 VIntConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
104 ConfigControl(a,b,c) {};
105 VIntConfigControl( vlc_object_t *a, module_config_t *b ) :
106 ConfigControl(a,b) {};
107 virtual ~VIntConfigControl() {};
108 virtual int getValue() = 0;
109 virtual int getType() { return 1; }
112 class IntegerConfigControl : public VIntConfigControl
116 IntegerConfigControl( vlc_object_t *, module_config_t *, QWidget *,
117 QGridLayout *, int& );
118 IntegerConfigControl( vlc_object_t *, module_config_t *,
119 QLabel*, QSpinBox* );
120 IntegerConfigControl( vlc_object_t *, module_config_t *,
122 virtual ~IntegerConfigControl() {};
123 virtual int getValue();
124 virtual void show() { spin->show(); if( label ) label->show(); }
125 virtual void hide() { spin->hide(); if( label ) label->hide(); }
134 class IntegerRangeConfigControl : public IntegerConfigControl
137 IntegerRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
138 QGridLayout *, int& );
139 IntegerRangeConfigControl( vlc_object_t *, module_config_t *,
140 QLabel*, QSpinBox* );
145 class IntegerRangeSliderConfigControl : public VIntConfigControl
148 IntegerRangeSliderConfigControl( vlc_object_t *, module_config_t *,
149 QLabel *, QSlider * );
150 virtual ~IntegerRangeSliderConfigControl() {};
151 virtual int getValue();
159 class IntegerListConfigControl : public VIntConfigControl
162 IntegerListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
163 bool, QGridLayout*, int& );
164 IntegerListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
166 virtual ~IntegerListConfigControl() {};
167 virtual int getValue();
168 virtual void hide() { combo->hide(); if( label ) label->hide(); }
169 virtual void show() { combo->show(); if( label ) label->show(); }
176 class BoolConfigControl : public VIntConfigControl
179 BoolConfigControl( vlc_object_t *, module_config_t *, QWidget *,
180 QGridLayout *, int& );
181 BoolConfigControl( vlc_object_t *, module_config_t *,
182 QLabel *, QCheckBox*, bool );
183 virtual ~BoolConfigControl() {};
184 virtual int getValue();
185 virtual void show() { checkbox->show(); }
186 virtual void hide() { checkbox->hide(); }
192 /*******************************************************
193 * Float-based controls
194 *******************************************************/
195 class VFloatConfigControl : public ConfigControl
199 VFloatConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
200 ConfigControl(a,b,c) {};
201 VFloatConfigControl( vlc_object_t *a, module_config_t *b ) :
202 ConfigControl(a,b) {};
203 virtual ~VFloatConfigControl() {};
204 virtual float getValue() = 0;
205 virtual int getType() { return 2; }
208 class FloatConfigControl : public VFloatConfigControl
212 FloatConfigControl( vlc_object_t *, module_config_t *, QWidget *,
213 QGridLayout *, int& );
214 FloatConfigControl( vlc_object_t *, module_config_t *,
215 QLabel*, QDoubleSpinBox* );
216 virtual ~FloatConfigControl() {};
217 virtual float getValue();
218 virtual void show() { spin->show(); if( label ) label->show(); }
219 virtual void hide() { spin->hide(); if( label ) label->hide(); }
222 QDoubleSpinBox *spin;
229 class FloatRangeConfigControl : public FloatConfigControl
233 FloatRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
234 QGridLayout *, int& );
235 FloatRangeConfigControl( vlc_object_t *, module_config_t *,
236 QLabel*, QDoubleSpinBox* );
241 /*******************************************************
242 * String-based controls
243 *******************************************************/
244 class VStringConfigControl : public ConfigControl
248 VStringConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
249 ConfigControl(a,b,c) {};
250 VStringConfigControl( vlc_object_t *a, module_config_t *b ) :
251 ConfigControl(a,b) {};
252 virtual ~VStringConfigControl() {};
253 virtual QString getValue() = 0;
254 virtual int getType() { return 3; }
257 class StringConfigControl : public VStringConfigControl
261 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *,
262 QGridLayout *, int&, bool pwd );
263 StringConfigControl( vlc_object_t *, module_config_t *, QLabel *,
264 QLineEdit*, bool pwd );
265 virtual ~StringConfigControl() {};
266 virtual QString getValue() { return text->text(); };
267 virtual void show() { text->show(); if( label ) label->show(); }
268 virtual void hide() { text->hide(); if( label ) label->hide(); }
275 class FileConfigControl : public VStringConfigControl
279 FileConfigControl( vlc_object_t *, module_config_t *, QWidget *,
280 QGridLayout *, int&, bool pwd );
281 FileConfigControl( vlc_object_t *, module_config_t *, QLabel *,
282 QLineEdit *, QPushButton *, bool pwd );
283 virtual ~FileConfigControl() {};
284 virtual QString getValue() { return text->text(); };
285 virtual void show() { text->show(); if( label ) label->show(); browse->show(); }
286 virtual void hide() { text->hide(); if( label ) label->hide(); browse->hide(); }
288 virtual void updateField();
296 class DirectoryConfigControl : public FileConfigControl
300 DirectoryConfigControl( vlc_object_t *, module_config_t *, QWidget *,
301 QGridLayout *, int&, bool pwd );
302 DirectoryConfigControl( vlc_object_t *, module_config_t *, QLabel *,
303 QLineEdit *, QPushButton *, bool pwd );
304 virtual ~DirectoryConfigControl() {};
306 virtual void updateField();
309 class FontConfigControl : public FileConfigControl
313 FontConfigControl( vlc_object_t *, module_config_t *, QWidget *,
314 QGridLayout *, int&, bool pwd );
315 FontConfigControl( vlc_object_t *, module_config_t *, QLabel *,
316 QLineEdit *, QPushButton *, bool pwd );
317 virtual ~FontConfigControl() {};
319 virtual void updateField();
322 class ModuleConfigControl : public VStringConfigControl
325 ModuleConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool,
326 QGridLayout*, int& );
327 ModuleConfigControl( vlc_object_t *, module_config_t *, QLabel *,
329 virtual ~ModuleConfigControl() {};
330 virtual QString getValue();
331 virtual void hide() { combo->hide(); if( label ) label->hide(); }
332 virtual void show() { combo->show(); if( label ) label->show(); }
339 struct checkBoxListItem {
344 class ModuleListConfigControl : public VStringConfigControl
348 ModuleListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
349 bool, QGridLayout*, int& );
350 // ModuleListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
351 // QComboBox*, bool );
352 virtual ~ModuleListConfigControl();
353 virtual QString getValue();
357 void onUpdate( int value );
360 QVector<checkBoxListItem*> modules;
365 class StringListConfigControl : public VStringConfigControl
369 StringListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
370 bool, QGridLayout*, int& );
371 StringListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
373 virtual ~StringListConfigControl() {};
374 virtual QString getValue();
375 virtual void hide() { combo->hide(); if( label ) label->hide(); }
376 virtual void show() { combo->show(); if( label ) label->show(); }
382 void actionRequested( int );
386 void setfillVLCConfigCombo(const char *configname, intf_thread_t *p_intf,
387 QComboBox *combo, QWidget *parent = 0 );
390 struct ModuleCheckBox {
395 class ModuleListConfigControl : public ConfigControl
398 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool
400 virtual ~StringConfigControl();
401 virtual QString getValue();
403 std::vector<ModuleCheckBox> checkboxes;
410 /**********************************************************************
411 * Key selector widget
412 **********************************************************************/
413 class KeyInputDialog : public QDialog
416 KeyInputDialog( QList<module_config_t *> &, const char *, QWidget * );
420 void checkForConflicts( int i_vlckey );
421 void keyPressEvent( QKeyEvent *);
422 void wheelEvent( QWheelEvent *);
425 const char * keyToChange;
426 QList<module_config_t*> values;
427 QDialogButtonBox *buttonBox;
430 class KeyShortcutEdit: public QLineEdit
434 virtual void mousePressEvent( QMouseEvent *event );
439 class KeySelectorControl : public ConfigControl
443 KeySelectorControl( vlc_object_t *, module_config_t *, QWidget *,
444 QGridLayout*, int& );
445 virtual int getType() { return 4; }
446 virtual ~KeySelectorControl() {};
447 virtual void hide() { table->hide(); if( label ) label->hide(); }
448 virtual void show() { table->show(); if( label ) label->show(); }
454 KeyShortcutEdit *shortcutValue;
455 QList<module_config_t *> values;
458 void selectKey( QTreeWidgetItem * = NULL );
459 void select1Key( QTreeWidgetItem *);