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_
41 #include <QTreeWidget>
44 #include <QDoubleSpinBox>
45 #include <QPushButton>
48 #include <QFontComboBox>
51 class QTreeWidgetItem;
54 class QDialogButtonBox;
57 /*******************************************************
59 *******************************************************/
61 class InterfacePreviewWidget : public QLabel
65 InterfacePreviewWidget( QWidget * );
67 /* 0: sample_classic, aka VLC 0.8.6
68 1: sample_complete, aka MPC
69 2: sample_minimal, aka WMP12 minimal
71 void setPreview( int );
74 /*******************************************************
76 *******************************************************/
78 class ConfigControl : public QObject
82 ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf,
83 QWidget *p ) : p_this( _p_this ), p_item( _p_conf )
85 widget = new QWidget( p );
87 ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf ) :
88 p_this (_p_this ), p_item( _p_conf )
92 virtual ~ConfigControl() {};
93 virtual int getType() = 0;
94 const char * getName() { return p_item->psz_name; }
95 QWidget *getWidget() { assert( widget ); return widget; }
96 bool isAdvanced() { return p_item->b_advanced; }
97 virtual void hide() { getWidget()->hide(); };
98 virtual void show() { getWidget()->show(); };
100 static ConfigControl * createControl( vlc_object_t*,
101 module_config_t*,QWidget* );
102 static ConfigControl * createControl( vlc_object_t*,
103 module_config_t*,QWidget*,
104 QGridLayout *, int& );
105 void doApply( intf_thread_t *);
107 vlc_object_t *p_this;
108 module_config_t *p_item;
113 /* You shouldn't use that now..*/
119 /*******************************************************
120 * Integer-based controls
121 *******************************************************/
122 class VIntConfigControl : public ConfigControl
126 VIntConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
127 ConfigControl(a,b,c) {};
128 VIntConfigControl( vlc_object_t *a, module_config_t *b ) :
129 ConfigControl(a,b) {};
130 virtual ~VIntConfigControl() {};
131 virtual int getValue() = 0;
132 virtual int getType() { return CONFIG_ITEM_INTEGER; }
135 class IntegerConfigControl : public VIntConfigControl
139 IntegerConfigControl( vlc_object_t *, module_config_t *, QWidget *,
140 QGridLayout *, int& );
141 IntegerConfigControl( vlc_object_t *, module_config_t *,
142 QLabel*, QSpinBox* );
143 IntegerConfigControl( vlc_object_t *, module_config_t *,
145 virtual ~IntegerConfigControl() {};
146 virtual int getValue();
147 virtual void show() { spin->show(); if( label ) label->show(); }
148 virtual void hide() { spin->hide(); if( label ) label->hide(); }
157 class IntegerRangeConfigControl : public IntegerConfigControl
160 IntegerRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
161 QGridLayout *, int& );
162 IntegerRangeConfigControl( vlc_object_t *, module_config_t *,
163 QLabel*, QSpinBox* );
168 class IntegerRangeSliderConfigControl : public VIntConfigControl
171 IntegerRangeSliderConfigControl( vlc_object_t *, module_config_t *,
172 QLabel *, QSlider * );
173 virtual ~IntegerRangeSliderConfigControl() {};
174 virtual int getValue();
182 class IntegerListConfigControl : public VIntConfigControl
186 IntegerListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
187 bool, QGridLayout*, int& );
188 IntegerListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
190 virtual ~IntegerListConfigControl() {};
191 virtual int getValue();
192 virtual void hide() { combo->hide(); if( label ) label->hide(); }
193 virtual void show() { combo->show(); if( label ) label->show(); }
195 void finish(module_config_t *, bool );
199 void actionRequested( int );
203 class BoolConfigControl : public VIntConfigControl
206 BoolConfigControl( vlc_object_t *, module_config_t *, QWidget *,
207 QGridLayout *, int& );
208 BoolConfigControl( vlc_object_t *, module_config_t *,
209 QLabel *, QAbstractButton*, bool );
210 virtual ~BoolConfigControl() {};
211 virtual int getValue();
212 virtual void show() { checkbox->show(); }
213 virtual void hide() { checkbox->hide(); }
214 virtual int getType() { return CONFIG_ITEM_BOOL; }
216 QAbstractButton *checkbox;
220 /*******************************************************
221 * Float-based controls
222 *******************************************************/
223 class VFloatConfigControl : public ConfigControl
227 VFloatConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
228 ConfigControl(a,b,c) {};
229 VFloatConfigControl( vlc_object_t *a, module_config_t *b ) :
230 ConfigControl(a,b) {};
231 virtual ~VFloatConfigControl() {};
232 virtual float getValue() = 0;
233 virtual int getType() { return CONFIG_ITEM_FLOAT; }
236 class FloatConfigControl : public VFloatConfigControl
240 FloatConfigControl( vlc_object_t *, module_config_t *, QWidget *,
241 QGridLayout *, int& );
242 FloatConfigControl( vlc_object_t *, module_config_t *,
243 QLabel*, QDoubleSpinBox* );
244 virtual ~FloatConfigControl() {};
245 virtual float getValue();
246 virtual void show() { spin->show(); if( label ) label->show(); }
247 virtual void hide() { spin->hide(); if( label ) label->hide(); }
250 QDoubleSpinBox *spin;
257 class FloatRangeConfigControl : public FloatConfigControl
261 FloatRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
262 QGridLayout *, int& );
263 FloatRangeConfigControl( vlc_object_t *, module_config_t *,
264 QLabel*, QDoubleSpinBox* );
269 /*******************************************************
270 * String-based controls
271 *******************************************************/
272 class VStringConfigControl : public ConfigControl
276 VStringConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
277 ConfigControl(a,b,c) {};
278 VStringConfigControl( vlc_object_t *a, module_config_t *b ) :
279 ConfigControl(a,b) {};
280 virtual ~VStringConfigControl() {};
281 virtual QString getValue() = 0;
282 virtual int getType() { return CONFIG_ITEM_STRING; }
285 class StringConfigControl : public VStringConfigControl
289 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *,
290 QGridLayout *, int&, bool pwd );
291 StringConfigControl( vlc_object_t *, module_config_t *, QLabel *,
292 QLineEdit*, bool pwd );
293 virtual ~StringConfigControl() {};
294 virtual QString getValue() { return text->text(); };
295 virtual void show() { text->show(); if( label ) label->show(); }
296 virtual void hide() { text->hide(); if( label ) label->hide(); }
303 class FileConfigControl : public VStringConfigControl
307 FileConfigControl( vlc_object_t *, module_config_t *, QWidget *,
308 QGridLayout *, int& );
309 FileConfigControl( vlc_object_t *, module_config_t *, QLabel *,
310 QLineEdit *, QPushButton * );
311 virtual ~FileConfigControl() {};
312 virtual QString getValue() { return text->text(); };
313 virtual void show() { text->show(); if( label ) label->show(); browse->show(); }
314 virtual void hide() { text->hide(); if( label ) label->hide(); browse->hide(); }
316 virtual void updateField();
324 class DirectoryConfigControl : public FileConfigControl
328 DirectoryConfigControl( vlc_object_t *, module_config_t *, QWidget *,
329 QGridLayout *, int& );
330 DirectoryConfigControl( vlc_object_t *, module_config_t *, QLabel *,
331 QLineEdit *, QPushButton * );
332 virtual ~DirectoryConfigControl() {};
334 virtual void updateField();
337 class FontConfigControl : public VStringConfigControl
341 FontConfigControl( vlc_object_t *, module_config_t *, QWidget *,
342 QGridLayout *, int&);
343 FontConfigControl( vlc_object_t *, module_config_t *, QLabel *,
345 virtual ~FontConfigControl() {};
346 virtual QString getValue(){ return font->currentFont().family(); }
352 class ModuleConfigControl : public VStringConfigControl
355 ModuleConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool,
356 QGridLayout*, int& );
357 ModuleConfigControl( vlc_object_t *, module_config_t *, QLabel *,
359 virtual ~ModuleConfigControl() {};
360 virtual QString getValue();
361 virtual void hide() { combo->hide(); if( label ) label->hide(); }
362 virtual void show() { combo->show(); if( label ) label->show(); }
369 struct checkBoxListItem {
374 class ModuleListConfigControl : public VStringConfigControl
377 friend class ConfigControl;
379 ModuleListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
380 bool, QGridLayout*, int& );
381 // ModuleListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
382 // QComboBox*, bool );
383 virtual ~ModuleListConfigControl();
384 virtual QString getValue();
391 QVector<checkBoxListItem*> modules;
396 class StringListConfigControl : public VStringConfigControl
400 StringListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
401 bool, QGridLayout*, int& );
402 StringListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
404 virtual ~StringListConfigControl() {};
405 virtual QString getValue();
406 virtual void hide() { combo->hide(); if( label ) label->hide(); }
407 virtual void show() { combo->show(); if( label ) label->show(); }
410 void finish(module_config_t *, bool );
413 void actionRequested( int );
417 void setfillVLCConfigCombo(const char *configname, intf_thread_t *p_intf,
421 struct ModuleCheckBox {
426 class ModuleListConfigControl : public ConfigControl
429 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool
431 virtual ~StringConfigControl();
432 virtual QString getValue();
434 std::vector<ModuleCheckBox> checkboxes;
441 /**********************************************************************
442 * Key selector widget
443 **********************************************************************/
444 class KeyShortcutEdit: public QLineEdit
448 void setValue( int _value ){ value = _value; }
449 int getValue() const { return value; }
451 void setGlobal( bool _value ) { b_global = _value; }
452 bool getGlobal() const { return b_global; }
454 virtual void clear(void) { value = 0; QLineEdit::clear(); b_global = false;}
458 virtual void mousePressEvent( QMouseEvent *event );
463 class SearchLineEdit;
464 class KeySelectorControl : public ConfigControl
468 KeySelectorControl( vlc_object_t *, module_config_t *, QWidget *,
469 QGridLayout*, int& );
470 virtual int getType() { return CONFIG_ITEM_KEY; }
471 virtual ~KeySelectorControl() {};
472 virtual void hide() { table->hide(); if( label ) label->hide(); }
473 virtual void show() { table->show(); if( label ) label->show(); }
479 KeyShortcutEdit *shortcutValue;
480 QList<module_config_t *> values;
481 SearchLineEdit *actionSearch;
484 void selectKey( QTreeWidgetItem * = NULL, int column = 1 );
486 void filter( const QString & );
489 class KeyInputDialog : public QDialog
492 KeyInputDialog( QTreeWidget *, const QString&, QWidget *, bool b_global = false);
497 void checkForConflicts( int i_vlckey );
498 void keyPressEvent( QKeyEvent *);
499 void wheelEvent( QWheelEvent *);
500 QLabel *selected, *warning;
501 QVBoxLayout *vLayout;
502 QDialogButtonBox *buttonBox;