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 _PREFERENCESWIDGETS_H_
27 #define _PREFERENCESWIDGETS_H_
39 #include <QTreeWidget>
42 #include <QDoubleSpinBox>
43 #include <QPushButton>
50 class QTreeWidgetItem;
53 class QDialogButtonBox;
56 class ConfigControl : public QObject
60 ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf,
61 QWidget *p ) : p_this( _p_this ), p_item( _p_conf )
63 widget = new QWidget( p );
65 ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf ) :
66 p_this (_p_this ), p_item( _p_conf )
70 virtual ~ConfigControl() {};
71 virtual int getType() = 0;
72 const char * getName() { return p_item->psz_name; }
73 QWidget *getWidget() { assert( widget ); return widget; }
74 bool isAdvanced() { return p_item->b_advanced; }
75 virtual void hide() { getWidget()->hide(); };
76 virtual void show() { getWidget()->show(); };
78 static ConfigControl * createControl( vlc_object_t*,
79 module_config_t*,QWidget* );
80 static ConfigControl * createControl( vlc_object_t*,
81 module_config_t*,QWidget*,
82 QGridLayout *, int& );
83 void doApply( intf_thread_t *);
86 module_config_t *p_item;
91 /* You shouldn't use that now..*/
97 /*******************************************************
98 * Integer-based controls
99 *******************************************************/
100 class VIntConfigControl : public ConfigControl
104 VIntConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
105 ConfigControl(a,b,c) {};
106 VIntConfigControl( vlc_object_t *a, module_config_t *b ) :
107 ConfigControl(a,b) {};
108 virtual ~VIntConfigControl() {};
109 virtual int getValue() = 0;
110 virtual int getType() { return 1; }
113 class IntegerConfigControl : public VIntConfigControl
117 IntegerConfigControl( vlc_object_t *, module_config_t *, QWidget *,
118 QGridLayout *, int& );
119 IntegerConfigControl( vlc_object_t *, module_config_t *,
120 QLabel*, QSpinBox* );
121 IntegerConfigControl( vlc_object_t *, module_config_t *,
123 virtual ~IntegerConfigControl() {};
124 virtual int getValue();
125 virtual void show() { spin->show(); if( label ) label->show(); }
126 virtual void hide() { spin->hide(); if( label ) label->hide(); }
135 class IntegerRangeConfigControl : public IntegerConfigControl
138 IntegerRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
139 QGridLayout *, int& );
140 IntegerRangeConfigControl( vlc_object_t *, module_config_t *,
141 QLabel*, QSpinBox* );
146 class IntegerRangeSliderConfigControl : public VIntConfigControl
149 IntegerRangeSliderConfigControl( vlc_object_t *, module_config_t *,
150 QLabel *, QSlider * );
151 virtual ~IntegerRangeSliderConfigControl() {};
152 virtual int getValue();
160 class IntegerListConfigControl : public VIntConfigControl
163 IntegerListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
164 bool, QGridLayout*, int& );
165 IntegerListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
167 virtual ~IntegerListConfigControl() {};
168 virtual int getValue();
169 virtual void hide() { combo->hide(); if( label ) label->hide(); }
170 virtual void show() { combo->show(); if( label ) label->show(); }
177 class BoolConfigControl : public VIntConfigControl
180 BoolConfigControl( vlc_object_t *, module_config_t *, QWidget *,
181 QGridLayout *, int& );
182 BoolConfigControl( vlc_object_t *, module_config_t *,
183 QLabel *, QCheckBox*, bool );
184 virtual ~BoolConfigControl() {};
185 virtual int getValue();
186 virtual void show() { checkbox->show(); }
187 virtual void hide() { checkbox->hide(); }
193 /*******************************************************
194 * Float-based controls
195 *******************************************************/
196 class VFloatConfigControl : public ConfigControl
200 VFloatConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
201 ConfigControl(a,b,c) {};
202 VFloatConfigControl( vlc_object_t *a, module_config_t *b ) :
203 ConfigControl(a,b) {};
204 virtual ~VFloatConfigControl() {};
205 virtual float getValue() = 0;
206 virtual int getType() { return 2; }
209 class FloatConfigControl : public VFloatConfigControl
213 FloatConfigControl( vlc_object_t *, module_config_t *, QWidget *,
214 QGridLayout *, int& );
215 FloatConfigControl( vlc_object_t *, module_config_t *,
216 QLabel*, QDoubleSpinBox* );
217 virtual ~FloatConfigControl() {};
218 virtual float getValue();
219 virtual void show() { spin->show(); if( label ) label->show(); }
220 virtual void hide() { spin->hide(); if( label ) label->hide(); }
223 QDoubleSpinBox *spin;
230 class FloatRangeConfigControl : public FloatConfigControl
234 FloatRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
235 QGridLayout *, int& );
236 FloatRangeConfigControl( vlc_object_t *, module_config_t *,
237 QLabel*, QDoubleSpinBox* );
242 /*******************************************************
243 * String-based controls
244 *******************************************************/
245 class VStringConfigControl : public ConfigControl
249 VStringConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
250 ConfigControl(a,b,c) {};
251 VStringConfigControl( vlc_object_t *a, module_config_t *b ) :
252 ConfigControl(a,b) {};
253 virtual ~VStringConfigControl() {};
254 virtual QString getValue() = 0;
255 virtual int getType() { return 3; }
258 class StringConfigControl : public VStringConfigControl
262 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *,
263 QGridLayout *, int&, bool pwd );
264 StringConfigControl( vlc_object_t *, module_config_t *, QLabel *,
265 QLineEdit*, bool pwd );
266 virtual ~StringConfigControl() {};
267 virtual QString getValue() { return text->text(); };
268 virtual void show() { text->show(); if( label ) label->show(); }
269 virtual void hide() { text->hide(); if( label ) label->hide(); }
276 class FileConfigControl : public VStringConfigControl
280 FileConfigControl( vlc_object_t *, module_config_t *, QWidget *,
281 QGridLayout *, int&, bool pwd );
282 FileConfigControl( vlc_object_t *, module_config_t *, QLabel *,
283 QLineEdit *, QPushButton *, bool pwd );
284 virtual ~FileConfigControl() {};
285 virtual QString getValue() { return text->text(); };
286 virtual void show() { text->show(); if( label ) label->show(); browse->show(); }
287 virtual void hide() { text->hide(); if( label ) label->hide(); browse->hide(); }
289 virtual void updateField();
297 class DirectoryConfigControl : public FileConfigControl
301 DirectoryConfigControl( vlc_object_t *, module_config_t *, QWidget *,
302 QGridLayout *, int&, bool pwd );
303 DirectoryConfigControl( vlc_object_t *, module_config_t *, QLabel *,
304 QLineEdit *, QPushButton *, bool pwd );
305 virtual ~DirectoryConfigControl() {};
307 virtual void updateField();
310 class FontConfigControl : public FileConfigControl
314 FontConfigControl( vlc_object_t *, module_config_t *, QWidget *,
315 QGridLayout *, int&, bool pwd );
316 FontConfigControl( vlc_object_t *, module_config_t *, QLabel *,
317 QLineEdit *, QPushButton *, bool pwd );
318 virtual ~FontConfigControl() {};
320 virtual void updateField();
323 class ModuleConfigControl : public VStringConfigControl
326 ModuleConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool,
327 QGridLayout*, int& );
328 ModuleConfigControl( vlc_object_t *, module_config_t *, QLabel *,
330 virtual ~ModuleConfigControl() {};
331 virtual QString getValue();
332 virtual void hide() { combo->hide(); if( label ) label->hide(); }
333 virtual void show() { combo->show(); if( label ) label->show(); }
340 struct checkBoxListItem {
345 class ModuleListConfigControl : public VStringConfigControl
349 ModuleListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
350 bool, QGridLayout*, int& );
351 // ModuleListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
352 // QComboBox*, bool );
353 virtual ~ModuleListConfigControl();
354 virtual QString getValue();
358 void onUpdate( int value );
361 QVector<checkBoxListItem*> modules;
366 class StringListConfigControl : public VStringConfigControl
370 StringListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
371 bool, QGridLayout*, int& );
372 StringListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
374 virtual ~StringListConfigControl() {};
375 virtual QString getValue();
376 virtual void hide() { combo->hide(); if( label ) label->hide(); }
377 virtual void show() { combo->show(); if( label ) label->show(); }
383 void actionRequested( int );
387 void setfillVLCConfigCombo(const char *configname, intf_thread_t *p_intf,
388 QComboBox *combo, QWidget *parent = 0 );
391 struct ModuleCheckBox {
396 class ModuleListConfigControl : public ConfigControl
399 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool
401 virtual ~StringConfigControl();
402 virtual QString getValue();
404 std::vector<ModuleCheckBox> checkboxes;
411 /**********************************************************************
412 * Key selector widget
413 **********************************************************************/
414 class KeyInputDialog : public QDialog
417 KeyInputDialog( QList<module_config_t *> &, const char *, QWidget * );
421 void checkForConflicts( int i_vlckey );
422 void keyPressEvent( QKeyEvent *);
423 void wheelEvent( QWheelEvent *);
425 QVBoxLayout *vLayout;
426 const char *keyToChange;
427 QList<module_config_t*> values;
428 QDialogButtonBox *buttonBox;
431 class KeyShortcutEdit: public QLineEdit
435 virtual void mousePressEvent( QMouseEvent *event );
440 class KeySelectorControl : public ConfigControl
444 KeySelectorControl( vlc_object_t *, module_config_t *, QWidget *,
445 QGridLayout*, int& );
446 virtual int getType() { return 4; }
447 virtual ~KeySelectorControl() {};
448 virtual void hide() { table->hide(); if( label ) label->hide(); }
449 virtual void show() { table->show(); if( label ) label->show(); }
455 KeyShortcutEdit *shortcutValue;
456 QList<module_config_t *> values;
459 void selectKey( QTreeWidgetItem * = NULL );
460 void select1Key( QTreeWidgetItem *);