1 /*****************************************************************************
2 * preferences_widgets.hpp : Widgets for preferences panels
3 ****************************************************************************
4 * Copyright (C) 2006-2011 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 _PREFERENCESWIDGETS_H_
27 #define _PREFERENCESWIDGETS_H_
41 #include <QTreeWidget>
44 #include <QDoubleSpinBox>
45 #include <QPushButton>
47 #include <QFontComboBox>
50 class QTreeWidgetItem;
53 class QDialogButtonBox;
58 /*******************************************************
60 *******************************************************/
62 class InterfacePreviewWidget : public QLabel
66 InterfacePreviewWidget( QWidget * );
69 MINIMAL, // aka WMP12 minimal
72 void setPreview( enum_style );
73 void setNormalPreview( bool b_minimal );
76 /*******************************************************
78 *******************************************************/
80 class ConfigControl : public QObject
84 virtual int getType() const = 0;
85 const char * getName() const { return p_item->psz_name; }
86 bool isAdvanced() const { return p_item->b_advanced; }
87 void hide() { changeVisibility( false ); }
88 void show() { changeVisibility( true ); }
89 /* ConfigControl factory */
90 static ConfigControl * createControl( vlc_object_t*,
91 module_config_t*,QWidget*,
92 QGridLayout *, int line = 0 );
93 /* Inserts control into another layout block, using a sublayout */
94 void insertInto( QBoxLayout * );
95 /* Inserts control into an existing grid layout */
96 void insertIntoExistingGrid( QGridLayout*, int );
97 virtual void doApply() = 0;
99 ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf ) :
100 p_this (_p_this ), p_item( _p_conf ) {}
101 virtual void changeVisibility( bool b ) { Q_UNUSED(b); };
102 vlc_object_t *p_this;
103 module_config_t *p_item;
104 virtual void fillGrid( QGridLayout*, int ) {};
108 /* You shouldn't use that now..*/
113 /*******************************************************
114 * Integer-based controls
115 *******************************************************/
116 class VIntConfigControl : public ConfigControl
120 virtual int getValue() const = 0;
121 virtual int getType() const;
122 virtual void doApply();
124 VIntConfigControl( vlc_object_t *a, module_config_t *b ) :
125 ConfigControl(a,b) {};
128 class IntegerConfigControl : public VIntConfigControl
132 IntegerConfigControl( vlc_object_t *, module_config_t *, QWidget * );
133 IntegerConfigControl( vlc_object_t *, module_config_t *,
134 QLabel*, QSpinBox* );
135 virtual int getValue() const;
138 virtual void changeVisibility( bool b )
140 spin->setVisible( b );
141 if ( label ) label->setVisible( b );
143 virtual void fillGrid( QGridLayout*, int );
149 class IntegerRangeConfigControl : public IntegerConfigControl
152 IntegerRangeConfigControl( vlc_object_t *, module_config_t *, QWidget * );
153 IntegerRangeConfigControl( vlc_object_t *, module_config_t *,
154 QLabel*, QSpinBox* );
155 IntegerRangeConfigControl( vlc_object_t *, module_config_t *,
161 class IntegerRangeSliderConfigControl : public VIntConfigControl
164 IntegerRangeSliderConfigControl( vlc_object_t *, module_config_t *,
165 QLabel *, QSlider * );
166 virtual int getValue() const;
169 virtual void changeVisibility( bool b )
171 slider->setVisible( b );
172 if ( label ) label->setVisible( b );
179 class IntegerListConfigControl : public VIntConfigControl
183 IntegerListConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool );
184 IntegerListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
186 virtual int getValue() const;
188 virtual void changeVisibility( bool b )
190 combo->setVisible( b );
191 if ( label ) label->setVisible( b );
193 virtual void fillGrid( QGridLayout*, int );
195 void finish(module_config_t * );
198 QList<QPushButton *> buttons;
201 class BoolConfigControl : public VIntConfigControl
204 BoolConfigControl( vlc_object_t *, module_config_t *, QWidget * );
205 BoolConfigControl( vlc_object_t *, module_config_t *,
206 QLabel *, QAbstractButton* );
207 virtual int getValue() const;
208 virtual int getType() const;
210 virtual void changeVisibility( bool b )
212 checkbox->setVisible( b );
214 virtual void fillGrid( QGridLayout*, int );
216 QAbstractButton *checkbox;
220 class ColorConfigControl : public VIntConfigControl
224 ColorConfigControl( vlc_object_t *, module_config_t *, QWidget * );
225 ColorConfigControl( vlc_object_t *, module_config_t *,
226 QLabel *, QAbstractButton* );
227 virtual ~ColorConfigControl() { delete color_px; }
228 virtual int getValue() const;
230 virtual void changeVisibility( bool b )
232 color_but->setVisible( b );
233 if ( label ) label->setVisible( b );
235 virtual void fillGrid( QGridLayout*, int );
238 QAbstractButton *color_but;
246 /*******************************************************
247 * Float-based controls
248 *******************************************************/
249 class VFloatConfigControl : public ConfigControl
253 virtual float getValue() const = 0;
254 virtual int getType() const;
255 virtual void doApply();
257 VFloatConfigControl( vlc_object_t *a, module_config_t *b ) :
258 ConfigControl(a,b) {};
261 class FloatConfigControl : public VFloatConfigControl
265 FloatConfigControl( vlc_object_t *, module_config_t *, QWidget * );
266 FloatConfigControl( vlc_object_t *, module_config_t *,
267 QLabel*, QDoubleSpinBox* );
268 virtual float getValue() const;
271 virtual void changeVisibility( bool b )
273 spin->setVisible( b );
274 if ( label ) label->setVisible( b );
276 virtual void fillGrid( QGridLayout*, int );
277 QDoubleSpinBox *spin;
284 class FloatRangeConfigControl : public FloatConfigControl
288 FloatRangeConfigControl( vlc_object_t *, module_config_t *, QWidget * );
289 FloatRangeConfigControl( vlc_object_t *, module_config_t *,
290 QLabel*, QDoubleSpinBox* );
295 /*******************************************************
296 * String-based controls
297 *******************************************************/
298 class VStringConfigControl : public ConfigControl
302 virtual QString getValue() const = 0;
303 virtual int getType() const;
304 virtual void doApply();
306 VStringConfigControl( vlc_object_t *a, module_config_t *b ) :
307 ConfigControl(a,b) {};
310 class StringConfigControl : public VStringConfigControl
314 StringConfigControl( vlc_object_t *, module_config_t *,
315 QWidget *, bool pwd );
316 StringConfigControl( vlc_object_t *, module_config_t *, QLabel *,
317 QLineEdit*, bool pwd );
318 virtual QString getValue() const { return text->text(); };
320 virtual void changeVisibility( bool b )
322 text->setVisible( b );
323 if ( label ) label->setVisible( b );
325 virtual void fillGrid( QGridLayout*, int );
332 class FileConfigControl : public VStringConfigControl
336 FileConfigControl( vlc_object_t *, module_config_t *, QWidget * );
337 FileConfigControl( vlc_object_t *, module_config_t *, QLabel *,
338 QLineEdit *, QPushButton * );
339 virtual QString getValue() const { return text->text(); };
341 virtual void updateField();
343 virtual void changeVisibility( bool b )
345 text->setVisible( b );
346 browse->setVisible( b );
347 if ( label ) label->setVisible( b );
349 virtual void fillGrid( QGridLayout*, int );
356 class DirectoryConfigControl : public FileConfigControl
360 DirectoryConfigControl( vlc_object_t *, module_config_t *, QWidget * );
361 DirectoryConfigControl( vlc_object_t *, module_config_t *, QLabel *,
362 QLineEdit *, QPushButton * );
364 virtual void updateField();
367 class FontConfigControl : public VStringConfigControl
371 FontConfigControl( vlc_object_t *, module_config_t *, QWidget * );
372 FontConfigControl( vlc_object_t *, module_config_t *, QLabel *,
374 virtual QString getValue() const { return font->currentFont().family(); }
376 virtual void changeVisibility( bool b )
378 font->setVisible( b );
379 if ( label ) label->setVisible( b );
381 virtual void fillGrid( QGridLayout*, int );
386 class ModuleConfigControl : public VStringConfigControl
389 ModuleConfigControl( vlc_object_t *, module_config_t *, QWidget * );
390 ModuleConfigControl( vlc_object_t *, module_config_t *, QLabel *,
392 virtual QString getValue() const;
394 virtual void changeVisibility( bool b )
396 combo->setVisible( b );
397 if ( label ) label->setVisible( b );
399 virtual void fillGrid( QGridLayout*, int );
406 struct checkBoxListItem {
411 class ModuleListConfigControl : public VStringConfigControl
414 friend class ConfigControl;
416 ModuleListConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool );
417 // ModuleListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
418 // QComboBox*, bool );
419 virtual ~ModuleListConfigControl();
420 virtual QString getValue() const;
424 virtual void changeVisibility( bool );
425 virtual void fillGrid( QGridLayout*, int );
428 void checkbox_lists(module_t*);
429 void checkbox_lists( QString, QString, const char* );
430 QList<checkBoxListItem*> modules;
435 class StringListConfigControl : public VStringConfigControl
439 StringListConfigControl( vlc_object_t *, module_config_t *, QWidget * );
440 StringListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
442 virtual QString getValue() const;
444 virtual void changeVisibility( bool b )
446 combo->setVisible( b );
447 if ( label ) label->setVisible( b );
449 virtual void fillGrid( QGridLayout*, int );
452 void finish(module_config_t * );
454 QList<QPushButton *> buttons;
456 void comboIndexChanged( int );
459 void setfillVLCConfigCombo(const char *configname, intf_thread_t *p_intf,
463 struct ModuleCheckBox {
468 class ModuleListConfigControl : public ConfigControl
471 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool
473 virtual ~StringConfigControl();
474 virtual QString getValue();
476 QVector<ModuleCheckBox> checkboxes;
483 /**********************************************************************
484 * Key selector widget
485 **********************************************************************/
486 class KeySelectorControl : public ConfigControl
490 KeySelectorControl( vlc_object_t *, module_config_t *, QWidget * );
491 virtual int getType() const;
492 virtual void doApply();
494 virtual bool eventFilter( QObject *, QEvent * );
495 virtual void changeVisibility( bool b )
497 table->setVisible( b );
498 if ( label ) label->setVisible( b );
500 virtual void fillGrid( QGridLayout*, int );
505 SearchLineEdit *actionSearch;
507 QList<module_config_t *> values;
509 void selectKey( QTreeWidgetItem * = NULL, int column = 1 );
510 void filter( const QString & );
513 class KeyInputDialog : public QDialog
516 KeyInputDialog( QTreeWidget *, const QString&, QWidget *, bool b_global = false);
522 QLabel *selected, *warning;
523 QDialogButtonBox *buttonBox;
525 void checkForConflicts( int i_vlckey );
526 void keyPressEvent( QKeyEvent *);
527 void wheelEvent( QWheelEvent *);