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_
43 #include <QTreeWidget>
46 #include <QDoubleSpinBox>
47 #include <QPushButton>
54 class QTreeWidgetItem;
57 class QDialogButtonBox;
60 class ConfigControl : public QObject
64 ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf,
65 QWidget *p ) : p_this( _p_this ), p_item( _p_conf )
67 widget = new QWidget( p );
69 ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf ) :
70 p_this (_p_this ), p_item( _p_conf )
74 virtual ~ConfigControl() {};
75 virtual int getType() = 0;
76 const char * getName() { return p_item->psz_name; }
77 QWidget *getWidget() { assert( widget ); return widget; }
78 bool isAdvanced() { return p_item->b_advanced; }
79 virtual void hide() { getWidget()->hide(); };
80 virtual void show() { getWidget()->show(); };
82 static ConfigControl * createControl( vlc_object_t*,
83 module_config_t*,QWidget* );
84 static ConfigControl * createControl( vlc_object_t*,
85 module_config_t*,QWidget*,
86 QGridLayout *, int& );
87 void doApply( intf_thread_t *);
90 module_config_t *p_item;
95 /* You shouldn't use that now..*/
101 /*******************************************************
102 * Integer-based controls
103 *******************************************************/
104 class VIntConfigControl : public ConfigControl
108 VIntConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
109 ConfigControl(a,b,c) {};
110 VIntConfigControl( vlc_object_t *a, module_config_t *b ) :
111 ConfigControl(a,b) {};
112 virtual ~VIntConfigControl() {};
113 virtual int getValue() = 0;
114 virtual int getType() { return CONFIG_ITEM_INTEGER; }
117 class IntegerConfigControl : public VIntConfigControl
121 IntegerConfigControl( vlc_object_t *, module_config_t *, QWidget *,
122 QGridLayout *, int& );
123 IntegerConfigControl( vlc_object_t *, module_config_t *,
124 QLabel*, QSpinBox* );
125 IntegerConfigControl( vlc_object_t *, module_config_t *,
127 virtual ~IntegerConfigControl() {};
128 virtual int getValue();
129 virtual void show() { spin->show(); if( label ) label->show(); }
130 virtual void hide() { spin->hide(); if( label ) label->hide(); }
139 class IntegerRangeConfigControl : public IntegerConfigControl
142 IntegerRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
143 QGridLayout *, int& );
144 IntegerRangeConfigControl( vlc_object_t *, module_config_t *,
145 QLabel*, QSpinBox* );
150 class IntegerRangeSliderConfigControl : public VIntConfigControl
153 IntegerRangeSliderConfigControl( vlc_object_t *, module_config_t *,
154 QLabel *, QSlider * );
155 virtual ~IntegerRangeSliderConfigControl() {};
156 virtual int getValue();
164 class IntegerListConfigControl : public VIntConfigControl
167 IntegerListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
168 bool, QGridLayout*, int& );
169 IntegerListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
171 virtual ~IntegerListConfigControl() {};
172 virtual int getValue();
173 virtual void hide() { combo->hide(); if( label ) label->hide(); }
174 virtual void show() { combo->show(); if( label ) label->show(); }
181 class BoolConfigControl : public VIntConfigControl
184 BoolConfigControl( vlc_object_t *, module_config_t *, QWidget *,
185 QGridLayout *, int& );
186 BoolConfigControl( vlc_object_t *, module_config_t *,
187 QLabel *, QCheckBox*, bool );
188 virtual ~BoolConfigControl() {};
189 virtual int getValue();
190 virtual void show() { checkbox->show(); }
191 virtual void hide() { checkbox->hide(); }
192 virtual int getType() { return CONFIG_ITEM_BOOL; }
198 /*******************************************************
199 * Float-based controls
200 *******************************************************/
201 class VFloatConfigControl : public ConfigControl
205 VFloatConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
206 ConfigControl(a,b,c) {};
207 VFloatConfigControl( vlc_object_t *a, module_config_t *b ) :
208 ConfigControl(a,b) {};
209 virtual ~VFloatConfigControl() {};
210 virtual float getValue() = 0;
211 virtual int getType() { return CONFIG_ITEM_FLOAT; }
214 class FloatConfigControl : public VFloatConfigControl
218 FloatConfigControl( vlc_object_t *, module_config_t *, QWidget *,
219 QGridLayout *, int& );
220 FloatConfigControl( vlc_object_t *, module_config_t *,
221 QLabel*, QDoubleSpinBox* );
222 virtual ~FloatConfigControl() {};
223 virtual float getValue();
224 virtual void show() { spin->show(); if( label ) label->show(); }
225 virtual void hide() { spin->hide(); if( label ) label->hide(); }
228 QDoubleSpinBox *spin;
235 class FloatRangeConfigControl : public FloatConfigControl
239 FloatRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
240 QGridLayout *, int& );
241 FloatRangeConfigControl( vlc_object_t *, module_config_t *,
242 QLabel*, QDoubleSpinBox* );
247 /*******************************************************
248 * String-based controls
249 *******************************************************/
250 class VStringConfigControl : public ConfigControl
254 VStringConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
255 ConfigControl(a,b,c) {};
256 VStringConfigControl( vlc_object_t *a, module_config_t *b ) :
257 ConfigControl(a,b) {};
258 virtual ~VStringConfigControl() {};
259 virtual QString getValue() = 0;
260 virtual int getType() { return CONFIG_ITEM_STRING; }
263 class StringConfigControl : public VStringConfigControl
267 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *,
268 QGridLayout *, int&, bool pwd );
269 StringConfigControl( vlc_object_t *, module_config_t *, QLabel *,
270 QLineEdit*, bool pwd );
271 virtual ~StringConfigControl() {};
272 virtual QString getValue() { return text->text(); };
273 virtual void show() { text->show(); if( label ) label->show(); }
274 virtual void hide() { text->hide(); if( label ) label->hide(); }
281 class FileConfigControl : public VStringConfigControl
285 FileConfigControl( vlc_object_t *, module_config_t *, QWidget *,
286 QGridLayout *, int&, bool pwd );
287 FileConfigControl( vlc_object_t *, module_config_t *, QLabel *,
288 QLineEdit *, QPushButton *, bool pwd );
289 virtual ~FileConfigControl() {};
290 virtual QString getValue() { return text->text(); };
291 virtual void show() { text->show(); if( label ) label->show(); browse->show(); }
292 virtual void hide() { text->hide(); if( label ) label->hide(); browse->hide(); }
294 virtual void updateField();
302 class DirectoryConfigControl : public FileConfigControl
306 DirectoryConfigControl( vlc_object_t *, module_config_t *, QWidget *,
307 QGridLayout *, int&, bool pwd );
308 DirectoryConfigControl( vlc_object_t *, module_config_t *, QLabel *,
309 QLineEdit *, QPushButton *, bool pwd );
310 virtual ~DirectoryConfigControl() {};
312 virtual void updateField();
315 class FontConfigControl : public FileConfigControl
319 FontConfigControl( vlc_object_t *, module_config_t *, QWidget *,
320 QGridLayout *, int&, bool pwd );
321 FontConfigControl( vlc_object_t *, module_config_t *, QLabel *,
322 QLineEdit *, QPushButton *, bool pwd );
323 virtual ~FontConfigControl() {};
325 virtual void updateField();
328 class ModuleConfigControl : public VStringConfigControl
331 ModuleConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool,
332 QGridLayout*, int& );
333 ModuleConfigControl( vlc_object_t *, module_config_t *, QLabel *,
335 virtual ~ModuleConfigControl() {};
336 virtual QString getValue();
337 virtual void hide() { combo->hide(); if( label ) label->hide(); }
338 virtual void show() { combo->show(); if( label ) label->show(); }
345 struct checkBoxListItem {
350 class ModuleListConfigControl : public VStringConfigControl
354 ModuleListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
355 bool, QGridLayout*, int& );
356 // ModuleListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
357 // QComboBox*, bool );
358 virtual ~ModuleListConfigControl();
359 virtual QString getValue();
363 void onUpdate( int value );
366 QVector<checkBoxListItem*> modules;
371 class StringListConfigControl : public VStringConfigControl
375 StringListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
376 bool, QGridLayout*, int& );
377 StringListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
379 virtual ~StringListConfigControl() {};
380 virtual QString getValue();
381 virtual void hide() { combo->hide(); if( label ) label->hide(); }
382 virtual void show() { combo->show(); if( label ) label->show(); }
388 void actionRequested( int );
392 void setfillVLCConfigCombo(const char *configname, intf_thread_t *p_intf,
393 QComboBox *combo, QWidget *parent = 0 );
396 struct ModuleCheckBox {
401 class ModuleListConfigControl : public ConfigControl
404 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool
406 virtual ~StringConfigControl();
407 virtual QString getValue();
409 std::vector<ModuleCheckBox> checkboxes;
416 /**********************************************************************
417 * Key selector widget
418 **********************************************************************/
419 class KeyShortcutEdit: public QLineEdit
423 void setValue( int _value ){ value = _value; }
424 int getValue(){ return value; }
427 virtual void mousePressEvent( QMouseEvent *event );
432 class KeySelectorControl : public ConfigControl
436 KeySelectorControl( vlc_object_t *, module_config_t *, QWidget *,
437 QGridLayout*, int& );
438 virtual int getType() { return CONFIG_ITEM_KEY; }
439 virtual ~KeySelectorControl() {};
440 virtual void hide() { table->hide(); if( label ) label->hide(); }
441 virtual void show() { table->show(); if( label ) label->show(); }
447 KeyShortcutEdit *shortcutValue;
448 QList<module_config_t *> values;
451 void selectKey( QTreeWidgetItem * = NULL );
452 void select1Key( QTreeWidgetItem *);
455 class KeyInputDialog : public QDialog
458 KeyInputDialog( QTreeWidget *, QString, QWidget * );
463 void checkForConflicts( int i_vlckey );
464 void keyPressEvent( QKeyEvent *);
465 void wheelEvent( QWheelEvent *);
467 QVBoxLayout *vLayout;
468 QDialogButtonBox *buttonBox;