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>
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 /*******************************************************
213 * Float-based controls
214 *******************************************************/
215 class VFloatConfigControl : public ConfigControl
219 VFloatConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
220 ConfigControl(a,b,c) {};
221 VFloatConfigControl( vlc_object_t *a, module_config_t *b ) :
222 ConfigControl(a,b) {};
223 virtual float getValue() const = 0;
224 virtual int getType() const { return CONFIG_ITEM_FLOAT; }
225 virtual void doApply();
228 class FloatConfigControl : public VFloatConfigControl
232 FloatConfigControl( vlc_object_t *, module_config_t *, QWidget *,
233 QGridLayout *, int );
234 FloatConfigControl( vlc_object_t *, module_config_t *,
235 QLabel*, QDoubleSpinBox* );
236 virtual float getValue() const;
237 virtual void show() { spin->show(); if( label ) label->show(); }
238 virtual void hide() { spin->hide(); if( label ) label->hide(); }
241 QDoubleSpinBox *spin;
248 class FloatRangeConfigControl : public FloatConfigControl
252 FloatRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
253 QGridLayout *, int );
254 FloatRangeConfigControl( vlc_object_t *, module_config_t *,
255 QLabel*, QDoubleSpinBox* );
260 /*******************************************************
261 * String-based controls
262 *******************************************************/
263 class VStringConfigControl : public ConfigControl
267 VStringConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
268 ConfigControl(a,b,c) {};
269 VStringConfigControl( vlc_object_t *a, module_config_t *b ) :
270 ConfigControl(a,b) {};
271 virtual QString getValue() const = 0;
272 virtual int getType() const { return CONFIG_ITEM_STRING; }
273 virtual void doApply();
276 class StringConfigControl : public VStringConfigControl
280 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *,
281 QGridLayout *, int, bool pwd );
282 StringConfigControl( vlc_object_t *, module_config_t *, QLabel *,
283 QLineEdit*, bool pwd );
284 virtual QString getValue() const { return text->text(); };
285 virtual void show() { text->show(); if( label ) label->show(); }
286 virtual void hide() { text->hide(); if( label ) label->hide(); }
293 class FileConfigControl : public VStringConfigControl
297 FileConfigControl( vlc_object_t *, module_config_t *, QWidget *,
298 QGridLayout *, int );
299 FileConfigControl( vlc_object_t *, module_config_t *, QLabel *,
300 QLineEdit *, QPushButton * );
301 virtual QString getValue() const { return text->text(); };
302 virtual void show() { text->show(); if( label ) label->show(); browse->show(); }
303 virtual void hide() { text->hide(); if( label ) label->hide(); browse->hide(); }
305 virtual void updateField();
313 class DirectoryConfigControl : public FileConfigControl
317 DirectoryConfigControl( vlc_object_t *, module_config_t *, QWidget *,
318 QGridLayout *, int );
319 DirectoryConfigControl( vlc_object_t *, module_config_t *, QLabel *,
320 QLineEdit *, QPushButton * );
322 virtual void updateField();
325 class FontConfigControl : public VStringConfigControl
329 FontConfigControl( vlc_object_t *, module_config_t *, QWidget *,
331 FontConfigControl( vlc_object_t *, module_config_t *, QLabel *,
333 virtual QString getValue() const { return font->currentFont().family(); }
339 class ModuleConfigControl : public VStringConfigControl
342 ModuleConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool,
344 ModuleConfigControl( vlc_object_t *, module_config_t *, QLabel *,
346 virtual QString getValue() const;
347 virtual void hide() { combo->hide(); if( label ) label->hide(); }
348 virtual void show() { combo->show(); if( label ) label->show(); }
355 struct checkBoxListItem {
360 class ModuleListConfigControl : public VStringConfigControl
363 friend class ConfigControl;
365 ModuleListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
366 bool, QGridLayout*, int );
367 // ModuleListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
368 // QComboBox*, bool );
369 virtual ~ModuleListConfigControl();
370 virtual QString getValue() const;
377 QList<checkBoxListItem*> modules;
382 class StringListConfigControl : public VStringConfigControl
386 StringListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
388 StringListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
390 virtual QString getValue() const;
391 virtual void hide() { combo->hide(); if( label ) label->hide(); }
392 virtual void show() { combo->show(); if( label ) label->show(); }
395 void finish(module_config_t * );
398 void actionRequested( int );
402 void setfillVLCConfigCombo(const char *configname, intf_thread_t *p_intf,
406 struct ModuleCheckBox {
411 class ModuleListConfigControl : public ConfigControl
414 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool
416 virtual ~StringConfigControl();
417 virtual QString getValue();
419 QVector<ModuleCheckBox> checkboxes;
426 /**********************************************************************
427 * Key selector widget
428 **********************************************************************/
429 class KeyShortcutEdit: public QLineEdit
433 void setValue( const QString& value ){ this->value = value; }
434 QString getValue() const { return value; }
436 void setGlobal( bool _value ) { b_global = _value; }
437 bool getGlobal() const { return b_global; }
439 virtual void clear(void) { value = qfu(""); QLineEdit::clear(); }
443 virtual void mousePressEvent( QMouseEvent *event );
448 class SearchLineEdit;
449 class KeySelectorControl : public ConfigControl
453 KeySelectorControl( vlc_object_t *, module_config_t *, QWidget *,
455 virtual int getType() const { return CONFIG_ITEM_KEY; }
456 virtual void hide() { table->hide(); if( label ) label->hide(); }
457 virtual void show() { table->show(); if( label ) label->show(); }
458 virtual void doApply();
463 KeyShortcutEdit *shortcutValue;
464 QList<module_config_t *> values;
465 SearchLineEdit *actionSearch;
468 void selectKey( QTreeWidgetItem * = NULL, int column = 1 );
469 void select( QTreeWidgetItem * = NULL, int column = 1 );
471 void filter( const QString & );
474 class KeyInputDialog : public QDialog
477 KeyInputDialog( QTreeWidget *, const QString&, QWidget *, bool b_global = false);
482 void checkForConflicts( int i_vlckey );
483 void keyPressEvent( QKeyEvent *);
484 void wheelEvent( QWheelEvent *);
485 QLabel *selected, *warning;
486 QVBoxLayout *vLayout;
487 QDialogButtonBox *buttonBox;