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 void setPreview( int );
70 /*******************************************************
72 *******************************************************/
74 class ConfigControl : public QObject
78 ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf,
79 QWidget *p ) : p_this( _p_this ), p_item( _p_conf )
81 widget = new QWidget( p );
83 ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf ) :
84 p_this (_p_this ), p_item( _p_conf )
88 virtual ~ConfigControl() {};
89 virtual int getType() = 0;
90 const char * getName() { return p_item->psz_name; }
91 QWidget *getWidget() { assert( widget ); return widget; }
92 bool isAdvanced() { return p_item->b_advanced; }
93 virtual void hide() { getWidget()->hide(); };
94 virtual void show() { getWidget()->show(); };
96 static ConfigControl * createControl( vlc_object_t*,
97 module_config_t*,QWidget* );
98 static ConfigControl * createControl( vlc_object_t*,
99 module_config_t*,QWidget*,
100 QGridLayout *, int& );
101 void doApply( intf_thread_t *);
103 vlc_object_t *p_this;
104 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 ~VIntConfigControl() {};
127 virtual int getValue() = 0;
128 virtual int getType() { return CONFIG_ITEM_INTEGER; }
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 ~IntegerConfigControl() {};
142 virtual int getValue();
143 virtual void show() { spin->show(); if( label ) label->show(); }
144 virtual void hide() { spin->hide(); if( label ) label->hide(); }
153 class IntegerRangeConfigControl : public IntegerConfigControl
156 IntegerRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
157 QGridLayout *, int& );
158 IntegerRangeConfigControl( vlc_object_t *, module_config_t *,
159 QLabel*, QSpinBox* );
164 class IntegerRangeSliderConfigControl : public VIntConfigControl
167 IntegerRangeSliderConfigControl( vlc_object_t *, module_config_t *,
168 QLabel *, QSlider * );
169 virtual ~IntegerRangeSliderConfigControl() {};
170 virtual int getValue();
178 class IntegerListConfigControl : public VIntConfigControl
182 IntegerListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
183 bool, QGridLayout*, int& );
184 IntegerListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
186 virtual ~IntegerListConfigControl() {};
187 virtual int getValue();
188 virtual void hide() { combo->hide(); if( label ) label->hide(); }
189 virtual void show() { combo->show(); if( label ) label->show(); }
191 void finish(module_config_t *, bool );
195 void actionRequested( int );
199 class BoolConfigControl : public VIntConfigControl
202 BoolConfigControl( vlc_object_t *, module_config_t *, QWidget *,
203 QGridLayout *, int& );
204 BoolConfigControl( vlc_object_t *, module_config_t *,
205 QLabel *, QAbstractButton*, bool );
206 virtual ~BoolConfigControl() {};
207 virtual int getValue();
208 virtual void show() { checkbox->show(); }
209 virtual void hide() { checkbox->hide(); }
210 virtual int getType() { return CONFIG_ITEM_BOOL; }
212 QAbstractButton *checkbox;
216 /*******************************************************
217 * Float-based controls
218 *******************************************************/
219 class VFloatConfigControl : public ConfigControl
223 VFloatConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
224 ConfigControl(a,b,c) {};
225 VFloatConfigControl( vlc_object_t *a, module_config_t *b ) :
226 ConfigControl(a,b) {};
227 virtual ~VFloatConfigControl() {};
228 virtual float getValue() = 0;
229 virtual int getType() { return CONFIG_ITEM_FLOAT; }
232 class FloatConfigControl : public VFloatConfigControl
236 FloatConfigControl( vlc_object_t *, module_config_t *, QWidget *,
237 QGridLayout *, int& );
238 FloatConfigControl( vlc_object_t *, module_config_t *,
239 QLabel*, QDoubleSpinBox* );
240 virtual ~FloatConfigControl() {};
241 virtual float getValue();
242 virtual void show() { spin->show(); if( label ) label->show(); }
243 virtual void hide() { spin->hide(); if( label ) label->hide(); }
246 QDoubleSpinBox *spin;
253 class FloatRangeConfigControl : public FloatConfigControl
257 FloatRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
258 QGridLayout *, int& );
259 FloatRangeConfigControl( vlc_object_t *, module_config_t *,
260 QLabel*, QDoubleSpinBox* );
265 /*******************************************************
266 * String-based controls
267 *******************************************************/
268 class VStringConfigControl : public ConfigControl
272 VStringConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
273 ConfigControl(a,b,c) {};
274 VStringConfigControl( vlc_object_t *a, module_config_t *b ) :
275 ConfigControl(a,b) {};
276 virtual ~VStringConfigControl() {};
277 virtual QString getValue() = 0;
278 virtual int getType() { return CONFIG_ITEM_STRING; }
281 class StringConfigControl : public VStringConfigControl
285 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *,
286 QGridLayout *, int&, bool pwd );
287 StringConfigControl( vlc_object_t *, module_config_t *, QLabel *,
288 QLineEdit*, bool pwd );
289 virtual ~StringConfigControl() {};
290 virtual QString getValue() { return text->text(); };
291 virtual void show() { text->show(); if( label ) label->show(); }
292 virtual void hide() { text->hide(); if( label ) label->hide(); }
299 class FileConfigControl : public VStringConfigControl
303 FileConfigControl( vlc_object_t *, module_config_t *, QWidget *,
304 QGridLayout *, int& );
305 FileConfigControl( vlc_object_t *, module_config_t *, QLabel *,
306 QLineEdit *, QPushButton * );
307 virtual ~FileConfigControl() {};
308 virtual QString getValue() { return text->text(); };
309 virtual void show() { text->show(); if( label ) label->show(); browse->show(); }
310 virtual void hide() { text->hide(); if( label ) label->hide(); browse->hide(); }
312 virtual void updateField();
320 class DirectoryConfigControl : public FileConfigControl
324 DirectoryConfigControl( vlc_object_t *, module_config_t *, QWidget *,
325 QGridLayout *, int& );
326 DirectoryConfigControl( vlc_object_t *, module_config_t *, QLabel *,
327 QLineEdit *, QPushButton * );
328 virtual ~DirectoryConfigControl() {};
330 virtual void updateField();
333 class FontConfigControl : public VStringConfigControl
337 FontConfigControl( vlc_object_t *, module_config_t *, QWidget *,
338 QGridLayout *, int&);
339 FontConfigControl( vlc_object_t *, module_config_t *, QLabel *,
341 virtual ~FontConfigControl() {};
342 virtual QString getValue(){ return font->currentFont().family(); }
348 class ModuleConfigControl : public VStringConfigControl
351 ModuleConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool,
352 QGridLayout*, int& );
353 ModuleConfigControl( vlc_object_t *, module_config_t *, QLabel *,
355 virtual ~ModuleConfigControl() {};
356 virtual QString getValue();
357 virtual void hide() { combo->hide(); if( label ) label->hide(); }
358 virtual void show() { combo->show(); if( label ) label->show(); }
365 struct checkBoxListItem {
370 class ModuleListConfigControl : public VStringConfigControl
373 friend class ConfigControl;
375 ModuleListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
376 bool, QGridLayout*, int& );
377 // ModuleListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
378 // QComboBox*, bool );
379 virtual ~ModuleListConfigControl();
380 virtual QString getValue();
387 QVector<checkBoxListItem*> modules;
392 class StringListConfigControl : public VStringConfigControl
396 StringListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
397 bool, QGridLayout*, int& );
398 StringListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
400 virtual ~StringListConfigControl() {};
401 virtual QString getValue();
402 virtual void hide() { combo->hide(); if( label ) label->hide(); }
403 virtual void show() { combo->show(); if( label ) label->show(); }
406 void finish(module_config_t *, bool );
409 void actionRequested( int );
413 void setfillVLCConfigCombo(const char *configname, intf_thread_t *p_intf,
417 struct ModuleCheckBox {
422 class ModuleListConfigControl : public ConfigControl
425 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool
427 virtual ~StringConfigControl();
428 virtual QString getValue();
430 std::vector<ModuleCheckBox> checkboxes;
437 /**********************************************************************
438 * Key selector widget
439 **********************************************************************/
440 class KeyShortcutEdit: public QLineEdit
444 void setValue( int _value ){ value = _value; }
445 int getValue() const { return value; }
447 void setGlobal( bool _value ) { b_global = _value; }
448 bool getGlobal() const { return b_global; }
450 virtual void clear(void) { value = 0; QLineEdit::clear(); b_global = false;}
454 virtual void mousePressEvent( QMouseEvent *event );
459 class SearchLineEdit;
460 class KeySelectorControl : public ConfigControl
464 KeySelectorControl( vlc_object_t *, module_config_t *, QWidget *,
465 QGridLayout*, int& );
466 virtual int getType() { return CONFIG_ITEM_KEY; }
467 virtual ~KeySelectorControl() {};
468 virtual void hide() { table->hide(); if( label ) label->hide(); }
469 virtual void show() { table->show(); if( label ) label->show(); }
475 KeyShortcutEdit *shortcutValue;
476 QList<module_config_t *> values;
477 SearchLineEdit *actionSearch;
480 void selectKey( QTreeWidgetItem * = NULL, int column = 1 );
482 void filter( const QString & );
485 class KeyInputDialog : public QDialog
488 KeyInputDialog( QTreeWidget *, const QString&, QWidget *, bool b_global = false);
493 void checkForConflicts( int i_vlckey );
494 void keyPressEvent( QKeyEvent *);
495 void wheelEvent( QWheelEvent *);
496 QLabel *selected, *warning;
497 QVBoxLayout *vLayout;
498 QDialogButtonBox *buttonBox;