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 * );
68 MINIMAL, // aka WMP12 minimal
71 void setPreview( enum_style );
72 void setNormalPreview( bool b_minimal );
75 /*******************************************************
77 *******************************************************/
79 class ConfigControl : public QObject
83 ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf,
84 QWidget *p ) : p_this( _p_this ), p_item( _p_conf )
86 widget = new QWidget( p );
88 ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf ) :
89 p_this (_p_this ), p_item( _p_conf )
93 virtual ~ConfigControl() {};
94 virtual int getType() = 0;
95 const char * getName() { return p_item->psz_name; }
96 QWidget *getWidget() { assert( widget ); return widget; }
97 bool isAdvanced() { return p_item->b_advanced; }
98 virtual void hide() { getWidget()->hide(); };
99 virtual void show() { getWidget()->show(); };
101 static ConfigControl * createControl( vlc_object_t*,
102 module_config_t*,QWidget* );
103 static ConfigControl * createControl( vlc_object_t*,
104 module_config_t*,QWidget*,
105 QGridLayout *, int& );
106 void doApply( intf_thread_t *);
108 vlc_object_t *p_this;
109 module_config_t *p_item;
114 /* You shouldn't use that now..*/
120 /*******************************************************
121 * Integer-based controls
122 *******************************************************/
123 class VIntConfigControl : public ConfigControl
127 VIntConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
128 ConfigControl(a,b,c) {};
129 VIntConfigControl( vlc_object_t *a, module_config_t *b ) :
130 ConfigControl(a,b) {};
131 virtual ~VIntConfigControl() {};
132 virtual int getValue() = 0;
133 virtual int getType() { return CONFIG_ITEM_INTEGER; }
136 class IntegerConfigControl : public VIntConfigControl
140 IntegerConfigControl( vlc_object_t *, module_config_t *, QWidget *,
141 QGridLayout *, int& );
142 IntegerConfigControl( vlc_object_t *, module_config_t *,
143 QLabel*, QSpinBox* );
144 IntegerConfigControl( vlc_object_t *, module_config_t *,
146 virtual ~IntegerConfigControl() {};
147 virtual int getValue();
148 virtual void show() { spin->show(); if( label ) label->show(); }
149 virtual void hide() { spin->hide(); if( label ) label->hide(); }
158 class IntegerRangeConfigControl : public IntegerConfigControl
161 IntegerRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
162 QGridLayout *, int& );
163 IntegerRangeConfigControl( vlc_object_t *, module_config_t *,
164 QLabel*, QSpinBox* );
169 class IntegerRangeSliderConfigControl : public VIntConfigControl
172 IntegerRangeSliderConfigControl( vlc_object_t *, module_config_t *,
173 QLabel *, QSlider * );
174 virtual ~IntegerRangeSliderConfigControl() {};
175 virtual int getValue();
183 class IntegerListConfigControl : public VIntConfigControl
187 IntegerListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
188 bool, QGridLayout*, int& );
189 IntegerListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
191 virtual ~IntegerListConfigControl() {};
192 virtual int getValue();
193 virtual void hide() { combo->hide(); if( label ) label->hide(); }
194 virtual void show() { combo->show(); if( label ) label->show(); }
196 void finish(module_config_t *, bool );
200 void actionRequested( int );
204 class BoolConfigControl : public VIntConfigControl
207 BoolConfigControl( vlc_object_t *, module_config_t *, QWidget *,
208 QGridLayout *, int& );
209 BoolConfigControl( vlc_object_t *, module_config_t *,
210 QLabel *, QAbstractButton*, bool );
211 virtual ~BoolConfigControl() {};
212 virtual int getValue();
213 virtual void show() { checkbox->show(); }
214 virtual void hide() { checkbox->hide(); }
215 virtual int getType() { return CONFIG_ITEM_BOOL; }
217 QAbstractButton *checkbox;
221 /*******************************************************
222 * Float-based controls
223 *******************************************************/
224 class VFloatConfigControl : public ConfigControl
228 VFloatConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
229 ConfigControl(a,b,c) {};
230 VFloatConfigControl( vlc_object_t *a, module_config_t *b ) :
231 ConfigControl(a,b) {};
232 virtual ~VFloatConfigControl() {};
233 virtual float getValue() = 0;
234 virtual int getType() { return CONFIG_ITEM_FLOAT; }
237 class FloatConfigControl : public VFloatConfigControl
241 FloatConfigControl( vlc_object_t *, module_config_t *, QWidget *,
242 QGridLayout *, int& );
243 FloatConfigControl( vlc_object_t *, module_config_t *,
244 QLabel*, QDoubleSpinBox* );
245 virtual ~FloatConfigControl() {};
246 virtual float getValue();
247 virtual void show() { spin->show(); if( label ) label->show(); }
248 virtual void hide() { spin->hide(); if( label ) label->hide(); }
251 QDoubleSpinBox *spin;
258 class FloatRangeConfigControl : public FloatConfigControl
262 FloatRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
263 QGridLayout *, int& );
264 FloatRangeConfigControl( vlc_object_t *, module_config_t *,
265 QLabel*, QDoubleSpinBox* );
270 /*******************************************************
271 * String-based controls
272 *******************************************************/
273 class VStringConfigControl : public ConfigControl
277 VStringConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
278 ConfigControl(a,b,c) {};
279 VStringConfigControl( vlc_object_t *a, module_config_t *b ) :
280 ConfigControl(a,b) {};
281 virtual ~VStringConfigControl() {};
282 virtual QString getValue() = 0;
283 virtual int getType() { return CONFIG_ITEM_STRING; }
286 class StringConfigControl : public VStringConfigControl
290 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *,
291 QGridLayout *, int&, bool pwd );
292 StringConfigControl( vlc_object_t *, module_config_t *, QLabel *,
293 QLineEdit*, bool pwd );
294 virtual ~StringConfigControl() {};
295 virtual QString getValue() { return text->text(); };
296 virtual void show() { text->show(); if( label ) label->show(); }
297 virtual void hide() { text->hide(); if( label ) label->hide(); }
304 class FileConfigControl : public VStringConfigControl
308 FileConfigControl( vlc_object_t *, module_config_t *, QWidget *,
309 QGridLayout *, int& );
310 FileConfigControl( vlc_object_t *, module_config_t *, QLabel *,
311 QLineEdit *, QPushButton * );
312 virtual ~FileConfigControl() {};
313 virtual QString getValue() { return text->text(); };
314 virtual void show() { text->show(); if( label ) label->show(); browse->show(); }
315 virtual void hide() { text->hide(); if( label ) label->hide(); browse->hide(); }
317 virtual void updateField();
325 class DirectoryConfigControl : public FileConfigControl
329 DirectoryConfigControl( vlc_object_t *, module_config_t *, QWidget *,
330 QGridLayout *, int& );
331 DirectoryConfigControl( vlc_object_t *, module_config_t *, QLabel *,
332 QLineEdit *, QPushButton * );
333 virtual ~DirectoryConfigControl() {};
335 virtual void updateField();
338 class FontConfigControl : public VStringConfigControl
342 FontConfigControl( vlc_object_t *, module_config_t *, QWidget *,
343 QGridLayout *, int&);
344 FontConfigControl( vlc_object_t *, module_config_t *, QLabel *,
346 virtual ~FontConfigControl() {};
347 virtual QString getValue(){ return font->currentFont().family(); }
353 class ModuleConfigControl : public VStringConfigControl
356 ModuleConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool,
357 QGridLayout*, int& );
358 ModuleConfigControl( vlc_object_t *, module_config_t *, QLabel *,
360 virtual ~ModuleConfigControl() {};
361 virtual QString getValue();
362 virtual void hide() { combo->hide(); if( label ) label->hide(); }
363 virtual void show() { combo->show(); if( label ) label->show(); }
370 struct checkBoxListItem {
375 class ModuleListConfigControl : public VStringConfigControl
378 friend class ConfigControl;
380 ModuleListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
381 bool, QGridLayout*, int& );
382 // ModuleListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
383 // QComboBox*, bool );
384 virtual ~ModuleListConfigControl();
385 virtual QString getValue();
392 QVector<checkBoxListItem*> modules;
397 class StringListConfigControl : public VStringConfigControl
401 StringListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
402 bool, QGridLayout*, int& );
403 StringListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
405 virtual ~StringListConfigControl() {};
406 virtual QString getValue();
407 virtual void hide() { combo->hide(); if( label ) label->hide(); }
408 virtual void show() { combo->show(); if( label ) label->show(); }
411 void finish(module_config_t *, bool );
414 void actionRequested( int );
418 void setfillVLCConfigCombo(const char *configname, intf_thread_t *p_intf,
422 struct ModuleCheckBox {
427 class ModuleListConfigControl : public ConfigControl
430 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool
432 virtual ~StringConfigControl();
433 virtual QString getValue();
435 std::vector<ModuleCheckBox> checkboxes;
442 /**********************************************************************
443 * Key selector widget
444 **********************************************************************/
445 class KeyShortcutEdit: public QLineEdit
449 void setValue( int _value ){ value = _value; }
450 int getValue() const { return value; }
452 void setGlobal( bool _value ) { b_global = _value; }
453 bool getGlobal() const { return b_global; }
455 virtual void clear(void) { value = 0; QLineEdit::clear(); }
459 virtual void mousePressEvent( QMouseEvent *event );
464 class SearchLineEdit;
465 class KeySelectorControl : public ConfigControl
469 KeySelectorControl( vlc_object_t *, module_config_t *, QWidget *,
470 QGridLayout*, int& );
471 virtual int getType() { return CONFIG_ITEM_KEY; }
472 virtual ~KeySelectorControl() {};
473 virtual void hide() { table->hide(); if( label ) label->hide(); }
474 virtual void show() { table->show(); if( label ) label->show(); }
480 KeyShortcutEdit *shortcutValue;
481 QList<module_config_t *> values;
482 SearchLineEdit *actionSearch;
485 void selectKey( QTreeWidgetItem * = NULL, int column = 1 );
486 void select( QTreeWidgetItem * = NULL, int column = 1 );
488 void filter( const QString & );
491 class KeyInputDialog : public QDialog
494 KeyInputDialog( QTreeWidget *, const QString&, QWidget *, bool b_global = false);
499 void checkForConflicts( int i_vlckey );
500 void keyPressEvent( QKeyEvent *);
501 void wheelEvent( QWheelEvent *);
502 QLabel *selected, *warning;
503 QVBoxLayout *vLayout;
504 QDialogButtonBox *buttonBox;