1 /*****************************************************************************
2 * preferences_widgets.hpp : Widgets for preferences panels
3 ****************************************************************************
4 * Copyright (C) 2006-2011 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>
47 #include <QFontComboBox>
50 class QTreeWidgetItem;
53 class QDialogButtonBox;
56 /*******************************************************
58 *******************************************************/
60 class InterfacePreviewWidget : public QLabel
64 InterfacePreviewWidget( QWidget * );
67 MINIMAL, // aka WMP12 minimal
70 void setPreview( enum_style );
71 void setNormalPreview( bool b_minimal );
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 int getType() const = 0;
93 const char * getName() const { return p_item->psz_name; }
94 QWidget *getWidget() const { assert( widget ); return widget; }
95 bool isAdvanced() const { return p_item->b_advanced; }
96 virtual void hide() { getWidget()->hide(); };
97 virtual void show() { getWidget()->show(); };
99 static ConfigControl * createControl( vlc_object_t*,
100 module_config_t*,QWidget*,
101 QGridLayout *, int line = 0 );
102 virtual void doApply() = 0;
104 vlc_object_t *p_this;
105 module_config_t *p_item;
109 /* You shouldn't use that now..*/
115 /*******************************************************
116 * Integer-based controls
117 *******************************************************/
118 class VIntConfigControl : public ConfigControl
122 VIntConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
123 ConfigControl(a,b,c) {};
124 VIntConfigControl( vlc_object_t *a, module_config_t *b ) :
125 ConfigControl(a,b) {};
126 virtual int getValue() const = 0;
127 virtual int getType() const { return CONFIG_ITEM_INTEGER; }
128 virtual void doApply();
131 class IntegerConfigControl : public VIntConfigControl
135 IntegerConfigControl( vlc_object_t *, module_config_t *, QWidget *,
136 QGridLayout *, int );
137 IntegerConfigControl( vlc_object_t *, module_config_t *,
138 QLabel*, QSpinBox* );
139 IntegerConfigControl( vlc_object_t *, module_config_t *,
141 virtual int getValue() const;
142 virtual void show() const { spin->show(); if( label ) label->show(); }
143 virtual void hide() const { spin->hide(); if( label ) label->hide(); }
152 class IntegerRangeConfigControl : public IntegerConfigControl
155 IntegerRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
156 QGridLayout *, int );
157 IntegerRangeConfigControl( vlc_object_t *, module_config_t *,
158 QLabel*, QSpinBox* );
163 class IntegerRangeSliderConfigControl : public VIntConfigControl
166 IntegerRangeSliderConfigControl( vlc_object_t *, module_config_t *,
167 QLabel *, QSlider * );
168 virtual int getValue() const;
176 class IntegerListConfigControl : public VIntConfigControl
180 IntegerListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
181 bool, QGridLayout*, int );
182 IntegerListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
184 virtual int getValue() const;
185 virtual void hide() { combo->hide(); if( label ) label->hide(); }
186 virtual void show() { combo->show(); if( label ) label->show(); }
188 void finish(module_config_t * );
192 void actionRequested( int );
196 class BoolConfigControl : public VIntConfigControl
199 BoolConfigControl( vlc_object_t *, module_config_t *, QWidget *,
200 QGridLayout *, int );
201 BoolConfigControl( vlc_object_t *, module_config_t *,
202 QLabel *, QAbstractButton* );
203 virtual int getValue() const;
204 virtual void show() { checkbox->show(); }
205 virtual void hide() { checkbox->hide(); }
206 virtual int getType() const { return CONFIG_ITEM_BOOL; }
208 QAbstractButton *checkbox;
212 class ColorConfigControl : public VIntConfigControl
216 ColorConfigControl( vlc_object_t *, module_config_t *, QWidget *,
217 QGridLayout *, int );
218 ColorConfigControl( vlc_object_t *, module_config_t *,
219 QLabel *, QAbstractButton* );
220 virtual ~ColorConfigControl() { delete color_px; }
221 virtual int getValue() const;
224 QAbstractButton *color_but;
232 /*******************************************************
233 * Float-based controls
234 *******************************************************/
235 class VFloatConfigControl : public ConfigControl
239 VFloatConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
240 ConfigControl(a,b,c) {};
241 VFloatConfigControl( vlc_object_t *a, module_config_t *b ) :
242 ConfigControl(a,b) {};
243 virtual float getValue() const = 0;
244 virtual int getType() const { return CONFIG_ITEM_FLOAT; }
245 virtual void doApply();
248 class FloatConfigControl : public VFloatConfigControl
252 FloatConfigControl( vlc_object_t *, module_config_t *, QWidget *,
253 QGridLayout *, int );
254 FloatConfigControl( vlc_object_t *, module_config_t *,
255 QLabel*, QDoubleSpinBox* );
256 virtual float getValue() const;
257 virtual void show() { spin->show(); if( label ) label->show(); }
258 virtual void hide() { spin->hide(); if( label ) label->hide(); }
261 QDoubleSpinBox *spin;
268 class FloatRangeConfigControl : public FloatConfigControl
272 FloatRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
273 QGridLayout *, int );
274 FloatRangeConfigControl( vlc_object_t *, module_config_t *,
275 QLabel*, QDoubleSpinBox* );
280 /*******************************************************
281 * String-based controls
282 *******************************************************/
283 class VStringConfigControl : public ConfigControl
287 VStringConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
288 ConfigControl(a,b,c) {};
289 VStringConfigControl( vlc_object_t *a, module_config_t *b ) :
290 ConfigControl(a,b) {};
291 virtual QString getValue() const = 0;
292 virtual int getType() const { return CONFIG_ITEM_STRING; }
293 virtual void doApply();
296 class StringConfigControl : public VStringConfigControl
300 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *,
301 QGridLayout *, int, bool pwd );
302 StringConfigControl( vlc_object_t *, module_config_t *, QLabel *,
303 QLineEdit*, bool pwd );
304 virtual QString getValue() const { return text->text(); };
305 virtual void show() { text->show(); if( label ) label->show(); }
306 virtual void hide() { text->hide(); if( label ) label->hide(); }
313 class FileConfigControl : public VStringConfigControl
317 FileConfigControl( vlc_object_t *, module_config_t *, QWidget *,
318 QGridLayout *, int );
319 FileConfigControl( vlc_object_t *, module_config_t *, QLabel *,
320 QLineEdit *, QPushButton * );
321 virtual QString getValue() const { return text->text(); };
322 virtual void show() { text->show(); if( label ) label->show(); browse->show(); }
323 virtual void hide() { text->hide(); if( label ) label->hide(); browse->hide(); }
325 virtual void updateField();
333 class DirectoryConfigControl : public FileConfigControl
337 DirectoryConfigControl( vlc_object_t *, module_config_t *, QWidget *,
338 QGridLayout *, int );
339 DirectoryConfigControl( vlc_object_t *, module_config_t *, QLabel *,
340 QLineEdit *, QPushButton * );
342 virtual void updateField();
345 class FontConfigControl : public VStringConfigControl
349 FontConfigControl( vlc_object_t *, module_config_t *, QWidget *,
351 FontConfigControl( vlc_object_t *, module_config_t *, QLabel *,
353 virtual QString getValue() const { return font->currentFont().family(); }
359 class ModuleConfigControl : public VStringConfigControl
362 ModuleConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool,
364 ModuleConfigControl( vlc_object_t *, module_config_t *, QLabel *,
366 virtual QString getValue() const;
367 virtual void hide() { combo->hide(); if( label ) label->hide(); }
368 virtual void show() { combo->show(); if( label ) label->show(); }
375 struct checkBoxListItem {
380 class ModuleListConfigControl : public VStringConfigControl
383 friend class ConfigControl;
385 ModuleListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
386 bool, QGridLayout*, int );
387 // ModuleListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
388 // QComboBox*, bool );
389 virtual ~ModuleListConfigControl();
390 virtual QString getValue() const;
397 QList<checkBoxListItem*> modules;
402 class StringListConfigControl : public VStringConfigControl
406 StringListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
408 StringListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
410 virtual QString getValue() const;
411 virtual void hide() { combo->hide(); if( label ) label->hide(); }
412 virtual void show() { combo->show(); if( label ) label->show(); }
415 void finish(module_config_t * );
418 void actionRequested( int );
422 void setfillVLCConfigCombo(const char *configname, intf_thread_t *p_intf,
426 struct ModuleCheckBox {
431 class ModuleListConfigControl : public ConfigControl
434 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool
436 virtual ~StringConfigControl();
437 virtual QString getValue();
439 QVector<ModuleCheckBox> checkboxes;
446 /**********************************************************************
447 * Key selector widget
448 **********************************************************************/
449 class KeyShortcutEdit: public QLineEdit
453 void setValue( const QString& value ){ this->value = value; }
454 QString getValue() const { return value; }
456 void setGlobal( bool _value ) { b_global = _value; }
457 bool getGlobal() const { return b_global; }
459 virtual void clear(void) { value = qfu(""); QLineEdit::clear(); }
463 virtual void mousePressEvent( QMouseEvent *event );
468 class SearchLineEdit;
469 class KeySelectorControl : public ConfigControl
473 KeySelectorControl( vlc_object_t *, module_config_t *, QWidget *,
475 virtual int getType() const { return CONFIG_ITEM_KEY; }
476 virtual void hide() { table->hide(); if( label ) label->hide(); }
477 virtual void show() { table->show(); if( label ) label->show(); }
478 virtual void doApply();
483 KeyShortcutEdit *shortcutValue;
484 QList<module_config_t *> values;
485 SearchLineEdit *actionSearch;
488 void selectKey( QTreeWidgetItem * = NULL, int column = 1 );
489 void select( QTreeWidgetItem * = NULL, int column = 1 );
491 void filter( const QString & );
494 class KeyInputDialog : public QDialog
497 KeyInputDialog( QTreeWidget *, const QString&, QWidget *, bool b_global = false);
502 void checkForConflicts( int i_vlckey );
503 void keyPressEvent( QKeyEvent *);
504 void wheelEvent( QWheelEvent *);
505 QLabel *selected, *warning;
506 QVBoxLayout *vLayout;
507 QDialogButtonBox *buttonBox;