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_
33 #include <vlc_common.h>
43 #include <QTreeWidget>
46 #include <QDoubleSpinBox>
47 #include <QPushButton>
54 class QTreeWidgetItem;
57 class QDialogButtonBox;
60 class ConfigControl : public QObject
64 ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf,
65 QWidget *p ) : p_this( _p_this ), p_item( _p_conf )
67 widget = new QWidget( p );
69 ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf ) :
70 p_this (_p_this ), p_item( _p_conf )
74 virtual ~ConfigControl() {};
75 virtual int getType() = 0;
76 const char * getName() { return p_item->psz_name; }
77 QWidget *getWidget() { assert( widget ); return widget; }
78 bool isAdvanced() { return p_item->b_advanced; }
79 virtual void hide() { getWidget()->hide(); };
80 virtual void show() { getWidget()->show(); };
82 static ConfigControl * createControl( vlc_object_t*,
83 module_config_t*,QWidget* );
84 static ConfigControl * createControl( vlc_object_t*,
85 module_config_t*,QWidget*,
86 QGridLayout *, int& );
87 void doApply( intf_thread_t *);
90 module_config_t *p_item;
95 /* You shouldn't use that now..*/
101 /*******************************************************
102 * Integer-based controls
103 *******************************************************/
104 class VIntConfigControl : public ConfigControl
108 VIntConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
109 ConfigControl(a,b,c) {};
110 VIntConfigControl( vlc_object_t *a, module_config_t *b ) :
111 ConfigControl(a,b) {};
112 virtual ~VIntConfigControl() {};
113 virtual int getValue() = 0;
114 virtual int getType() { return CONFIG_ITEM_INTEGER; }
117 class IntegerConfigControl : public VIntConfigControl
121 IntegerConfigControl( vlc_object_t *, module_config_t *, QWidget *,
122 QGridLayout *, int& );
123 IntegerConfigControl( vlc_object_t *, module_config_t *,
124 QLabel*, QSpinBox* );
125 IntegerConfigControl( vlc_object_t *, module_config_t *,
127 virtual ~IntegerConfigControl() {};
128 virtual int getValue();
129 virtual void show() { spin->show(); if( label ) label->show(); }
130 virtual void hide() { spin->hide(); if( label ) label->hide(); }
139 class IntegerRangeConfigControl : public IntegerConfigControl
142 IntegerRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
143 QGridLayout *, int& );
144 IntegerRangeConfigControl( vlc_object_t *, module_config_t *,
145 QLabel*, QSpinBox* );
150 class IntegerRangeSliderConfigControl : public VIntConfigControl
153 IntegerRangeSliderConfigControl( vlc_object_t *, module_config_t *,
154 QLabel *, QSlider * );
155 virtual ~IntegerRangeSliderConfigControl() {};
156 virtual int getValue();
164 class IntegerListConfigControl : public VIntConfigControl
168 IntegerListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
169 bool, QGridLayout*, int& );
170 IntegerListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
172 virtual ~IntegerListConfigControl() {};
173 virtual int getValue();
174 virtual void hide() { combo->hide(); if( label ) label->hide(); }
175 virtual void show() { combo->show(); if( label ) label->show(); }
177 void finish(module_config_t *, bool );
181 void actionRequested( int );
185 class BoolConfigControl : public VIntConfigControl
188 BoolConfigControl( vlc_object_t *, module_config_t *, QWidget *,
189 QGridLayout *, int& );
190 BoolConfigControl( vlc_object_t *, module_config_t *,
191 QLabel *, QCheckBox*, bool );
192 virtual ~BoolConfigControl() {};
193 virtual int getValue();
194 virtual void show() { checkbox->show(); }
195 virtual void hide() { checkbox->hide(); }
196 virtual int getType() { return CONFIG_ITEM_BOOL; }
202 /*******************************************************
203 * Float-based controls
204 *******************************************************/
205 class VFloatConfigControl : public ConfigControl
209 VFloatConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
210 ConfigControl(a,b,c) {};
211 VFloatConfigControl( vlc_object_t *a, module_config_t *b ) :
212 ConfigControl(a,b) {};
213 virtual ~VFloatConfigControl() {};
214 virtual float getValue() = 0;
215 virtual int getType() { return CONFIG_ITEM_FLOAT; }
218 class FloatConfigControl : public VFloatConfigControl
222 FloatConfigControl( vlc_object_t *, module_config_t *, QWidget *,
223 QGridLayout *, int& );
224 FloatConfigControl( vlc_object_t *, module_config_t *,
225 QLabel*, QDoubleSpinBox* );
226 virtual ~FloatConfigControl() {};
227 virtual float getValue();
228 virtual void show() { spin->show(); if( label ) label->show(); }
229 virtual void hide() { spin->hide(); if( label ) label->hide(); }
232 QDoubleSpinBox *spin;
239 class FloatRangeConfigControl : public FloatConfigControl
243 FloatRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
244 QGridLayout *, int& );
245 FloatRangeConfigControl( vlc_object_t *, module_config_t *,
246 QLabel*, QDoubleSpinBox* );
251 /*******************************************************
252 * String-based controls
253 *******************************************************/
254 class VStringConfigControl : public ConfigControl
258 VStringConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
259 ConfigControl(a,b,c) {};
260 VStringConfigControl( vlc_object_t *a, module_config_t *b ) :
261 ConfigControl(a,b) {};
262 virtual ~VStringConfigControl() {};
263 virtual QString getValue() = 0;
264 virtual int getType() { return CONFIG_ITEM_STRING; }
267 class StringConfigControl : public VStringConfigControl
271 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *,
272 QGridLayout *, int&, bool pwd );
273 StringConfigControl( vlc_object_t *, module_config_t *, QLabel *,
274 QLineEdit*, bool pwd );
275 virtual ~StringConfigControl() {};
276 virtual QString getValue() { return text->text(); };
277 virtual void show() { text->show(); if( label ) label->show(); }
278 virtual void hide() { text->hide(); if( label ) label->hide(); }
285 class FileConfigControl : public VStringConfigControl
289 FileConfigControl( vlc_object_t *, module_config_t *, QWidget *,
290 QGridLayout *, int&, bool pwd );
291 FileConfigControl( vlc_object_t *, module_config_t *, QLabel *,
292 QLineEdit *, QPushButton *, bool pwd );
293 virtual ~FileConfigControl() {};
294 virtual QString getValue() { return text->text(); };
295 virtual void show() { text->show(); if( label ) label->show(); browse->show(); }
296 virtual void hide() { text->hide(); if( label ) label->hide(); browse->hide(); }
298 virtual void updateField();
306 class DirectoryConfigControl : public FileConfigControl
310 DirectoryConfigControl( vlc_object_t *, module_config_t *, QWidget *,
311 QGridLayout *, int&, bool pwd );
312 DirectoryConfigControl( vlc_object_t *, module_config_t *, QLabel *,
313 QLineEdit *, QPushButton *, bool pwd );
314 virtual ~DirectoryConfigControl() {};
316 virtual void updateField();
320 class FontConfigControl : public FileConfigControl
324 FontConfigControl( vlc_object_t *, module_config_t *, QWidget *,
325 QGridLayout *, int&, bool pwd );
326 FontConfigControl( vlc_object_t *, module_config_t *, QLabel *,
327 QLineEdit *, QPushButton *, bool pwd );
328 virtual ~FontConfigControl() {};
330 virtual void updateField();
334 class ModuleConfigControl : public VStringConfigControl
337 ModuleConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool,
338 QGridLayout*, int& );
339 ModuleConfigControl( vlc_object_t *, module_config_t *, QLabel *,
341 virtual ~ModuleConfigControl() {};
342 virtual QString getValue();
343 virtual void hide() { combo->hide(); if( label ) label->hide(); }
344 virtual void show() { combo->show(); if( label ) label->show(); }
351 struct checkBoxListItem {
356 class ModuleListConfigControl : public VStringConfigControl
360 ModuleListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
361 bool, QGridLayout*, int& );
362 // ModuleListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
363 // QComboBox*, bool );
364 virtual ~ModuleListConfigControl();
365 virtual QString getValue();
369 void onUpdate( int value );
372 QVector<checkBoxListItem*> modules;
377 class StringListConfigControl : public VStringConfigControl
381 StringListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
382 bool, QGridLayout*, int& );
383 StringListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
385 virtual ~StringListConfigControl() {};
386 virtual QString getValue();
387 virtual void hide() { combo->hide(); if( label ) label->hide(); }
388 virtual void show() { combo->show(); if( label ) label->show(); }
391 void finish(module_config_t *, bool );
394 void actionRequested( int );
398 void setfillVLCConfigCombo(const char *configname, intf_thread_t *p_intf,
399 QComboBox *combo, QWidget *parent = 0 );
402 struct ModuleCheckBox {
407 class ModuleListConfigControl : public ConfigControl
410 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool
412 virtual ~StringConfigControl();
413 virtual QString getValue();
415 std::vector<ModuleCheckBox> checkboxes;
422 /**********************************************************************
423 * Key selector widget
424 **********************************************************************/
425 class KeyShortcutEdit: public QLineEdit
429 void setValue( int _value ){ value = _value; }
430 int getValue() const { return value; }
432 virtual void clear(void) { value = 0; QLineEdit::clear(); }
435 virtual void mousePressEvent( QMouseEvent *event );
440 class KeySelectorControl : public ConfigControl
444 KeySelectorControl( vlc_object_t *, module_config_t *, QWidget *,
445 QGridLayout*, int& );
446 virtual int getType() { return CONFIG_ITEM_KEY; }
447 virtual ~KeySelectorControl() {};
448 virtual void hide() { table->hide(); if( label ) label->hide(); }
449 virtual void show() { table->show(); if( label ) label->show(); }
455 KeyShortcutEdit *shortcutValue;
456 QList<module_config_t *> values;
459 void selectKey( QTreeWidgetItem * = NULL );
460 void select1Key( QTreeWidgetItem *);
463 class KeyInputDialog : public QDialog
466 KeyInputDialog( QTreeWidget *, QString, QWidget * );
471 void checkForConflicts( int i_vlckey );
472 void keyPressEvent( QKeyEvent *);
473 void wheelEvent( QWheelEvent *);
475 QVBoxLayout *vLayout;
476 QDialogButtonBox *buttonBox;