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 CONFIG_ITEM_INTEGER; }
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(); }
188 virtual int getType() { return CONFIG_ITEM_BOOL; }
194 /*******************************************************
195 * Float-based controls
196 *******************************************************/
197 class VFloatConfigControl : public ConfigControl
201 VFloatConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
202 ConfigControl(a,b,c) {};
203 VFloatConfigControl( vlc_object_t *a, module_config_t *b ) :
204 ConfigControl(a,b) {};
205 virtual ~VFloatConfigControl() {};
206 virtual float getValue() = 0;
207 virtual int getType() { return CONFIG_ITEM_FLOAT; }
210 class FloatConfigControl : public VFloatConfigControl
214 FloatConfigControl( vlc_object_t *, module_config_t *, QWidget *,
215 QGridLayout *, int& );
216 FloatConfigControl( vlc_object_t *, module_config_t *,
217 QLabel*, QDoubleSpinBox* );
218 virtual ~FloatConfigControl() {};
219 virtual float getValue();
220 virtual void show() { spin->show(); if( label ) label->show(); }
221 virtual void hide() { spin->hide(); if( label ) label->hide(); }
224 QDoubleSpinBox *spin;
231 class FloatRangeConfigControl : public FloatConfigControl
235 FloatRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
236 QGridLayout *, int& );
237 FloatRangeConfigControl( vlc_object_t *, module_config_t *,
238 QLabel*, QDoubleSpinBox* );
243 /*******************************************************
244 * String-based controls
245 *******************************************************/
246 class VStringConfigControl : public ConfigControl
250 VStringConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
251 ConfigControl(a,b,c) {};
252 VStringConfigControl( vlc_object_t *a, module_config_t *b ) :
253 ConfigControl(a,b) {};
254 virtual ~VStringConfigControl() {};
255 virtual QString getValue() = 0;
256 virtual int getType() { return CONFIG_ITEM_STRING; }
259 class StringConfigControl : public VStringConfigControl
263 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *,
264 QGridLayout *, int&, bool pwd );
265 StringConfigControl( vlc_object_t *, module_config_t *, QLabel *,
266 QLineEdit*, bool pwd );
267 virtual ~StringConfigControl() {};
268 virtual QString getValue() { return text->text(); };
269 virtual void show() { text->show(); if( label ) label->show(); }
270 virtual void hide() { text->hide(); if( label ) label->hide(); }
277 class FileConfigControl : public VStringConfigControl
281 FileConfigControl( vlc_object_t *, module_config_t *, QWidget *,
282 QGridLayout *, int&, bool pwd );
283 FileConfigControl( vlc_object_t *, module_config_t *, QLabel *,
284 QLineEdit *, QPushButton *, bool pwd );
285 virtual ~FileConfigControl() {};
286 virtual QString getValue() { return text->text(); };
287 virtual void show() { text->show(); if( label ) label->show(); browse->show(); }
288 virtual void hide() { text->hide(); if( label ) label->hide(); browse->hide(); }
290 virtual void updateField();
298 class DirectoryConfigControl : public FileConfigControl
302 DirectoryConfigControl( vlc_object_t *, module_config_t *, QWidget *,
303 QGridLayout *, int&, bool pwd );
304 DirectoryConfigControl( vlc_object_t *, module_config_t *, QLabel *,
305 QLineEdit *, QPushButton *, bool pwd );
306 virtual ~DirectoryConfigControl() {};
308 virtual void updateField();
311 class FontConfigControl : public FileConfigControl
315 FontConfigControl( vlc_object_t *, module_config_t *, QWidget *,
316 QGridLayout *, int&, bool pwd );
317 FontConfigControl( vlc_object_t *, module_config_t *, QLabel *,
318 QLineEdit *, QPushButton *, bool pwd );
319 virtual ~FontConfigControl() {};
321 virtual void updateField();
324 class ModuleConfigControl : public VStringConfigControl
327 ModuleConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool,
328 QGridLayout*, int& );
329 ModuleConfigControl( vlc_object_t *, module_config_t *, QLabel *,
331 virtual ~ModuleConfigControl() {};
332 virtual QString getValue();
333 virtual void hide() { combo->hide(); if( label ) label->hide(); }
334 virtual void show() { combo->show(); if( label ) label->show(); }
341 struct checkBoxListItem {
346 class ModuleListConfigControl : public VStringConfigControl
350 ModuleListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
351 bool, QGridLayout*, int& );
352 // ModuleListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
353 // QComboBox*, bool );
354 virtual ~ModuleListConfigControl();
355 virtual QString getValue();
359 void onUpdate( int value );
362 QVector<checkBoxListItem*> modules;
367 class StringListConfigControl : public VStringConfigControl
371 StringListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
372 bool, QGridLayout*, int& );
373 StringListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
375 virtual ~StringListConfigControl() {};
376 virtual QString getValue();
377 virtual void hide() { combo->hide(); if( label ) label->hide(); }
378 virtual void show() { combo->show(); if( label ) label->show(); }
384 void actionRequested( int );
388 void setfillVLCConfigCombo(const char *configname, intf_thread_t *p_intf,
389 QComboBox *combo, QWidget *parent = 0 );
392 struct ModuleCheckBox {
397 class ModuleListConfigControl : public ConfigControl
400 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool
402 virtual ~StringConfigControl();
403 virtual QString getValue();
405 std::vector<ModuleCheckBox> checkboxes;
412 /**********************************************************************
413 * Key selector widget
414 **********************************************************************/
415 class KeyInputDialog : public QDialog
418 KeyInputDialog( QList<module_config_t *> &, const char *, QWidget * );
422 void checkForConflicts( int i_vlckey );
423 void keyPressEvent( QKeyEvent *);
424 void wheelEvent( QWheelEvent *);
426 QVBoxLayout *vLayout;
427 const char *keyToChange;
428 QList<module_config_t*> values;
429 QDialogButtonBox *buttonBox;
432 class KeyShortcutEdit: public QLineEdit
436 virtual void mousePressEvent( QMouseEvent *event );
441 class KeySelectorControl : public ConfigControl
445 KeySelectorControl( vlc_object_t *, module_config_t *, QWidget *,
446 QGridLayout*, int& );
447 virtual int getType() { return CONFIG_ITEM_KEY; }
448 virtual ~KeySelectorControl() {};
449 virtual void hide() { table->hide(); if( label ) label->hide(); }
450 virtual void show() { table->show(); if( label ) label->show(); }
456 KeyShortcutEdit *shortcutValue;
457 QList<module_config_t *> values;
460 void selectKey( QTreeWidgetItem * = NULL );
461 void select1Key( QTreeWidgetItem *);