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>
50 class QTreeWidgetItem;
53 class QDialogButtonBox;
56 /*******************************************************
58 *******************************************************/
60 class InterfacePreviewWidget : public QLabel
64 InterfacePreviewWidget( QWidget * );
66 void setPreview( int );
69 /*******************************************************
71 *******************************************************/
73 class ConfigControl : public QObject
77 ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf,
78 QWidget *p ) : p_this( _p_this ), p_item( _p_conf )
80 widget = new QWidget( p );
82 ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf ) :
83 p_this (_p_this ), p_item( _p_conf )
87 virtual ~ConfigControl() {};
88 virtual int getType() = 0;
89 const char * getName() { return p_item->psz_name; }
90 QWidget *getWidget() { assert( widget ); return widget; }
91 bool isAdvanced() { return p_item->b_advanced; }
92 virtual void hide() { getWidget()->hide(); };
93 virtual void show() { getWidget()->show(); };
95 static ConfigControl * createControl( vlc_object_t*,
96 module_config_t*,QWidget* );
97 static ConfigControl * createControl( vlc_object_t*,
98 module_config_t*,QWidget*,
99 QGridLayout *, int& );
100 void doApply( intf_thread_t *);
102 vlc_object_t *p_this;
103 module_config_t *p_item;
108 /* You shouldn't use that now..*/
114 /*******************************************************
115 * Integer-based controls
116 *******************************************************/
117 class VIntConfigControl : public ConfigControl
121 VIntConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
122 ConfigControl(a,b,c) {};
123 VIntConfigControl( vlc_object_t *a, module_config_t *b ) :
124 ConfigControl(a,b) {};
125 virtual ~VIntConfigControl() {};
126 virtual int getValue() = 0;
127 virtual int getType() { return CONFIG_ITEM_INTEGER; }
130 class IntegerConfigControl : public VIntConfigControl
134 IntegerConfigControl( vlc_object_t *, module_config_t *, QWidget *,
135 QGridLayout *, int& );
136 IntegerConfigControl( vlc_object_t *, module_config_t *,
137 QLabel*, QSpinBox* );
138 IntegerConfigControl( vlc_object_t *, module_config_t *,
140 virtual ~IntegerConfigControl() {};
141 virtual int getValue();
142 virtual void show() { spin->show(); if( label ) label->show(); }
143 virtual void hide() { 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 ~IntegerRangeSliderConfigControl() {};
169 virtual int getValue();
177 class IntegerListConfigControl : public VIntConfigControl
181 IntegerListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
182 bool, QGridLayout*, int& );
183 IntegerListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
185 virtual ~IntegerListConfigControl() {};
186 virtual int getValue();
187 virtual void hide() { combo->hide(); if( label ) label->hide(); }
188 virtual void show() { combo->show(); if( label ) label->show(); }
190 void finish(module_config_t *, bool );
194 void actionRequested( int );
198 class BoolConfigControl : public VIntConfigControl
201 BoolConfigControl( vlc_object_t *, module_config_t *, QWidget *,
202 QGridLayout *, int& );
203 BoolConfigControl( vlc_object_t *, module_config_t *,
204 QLabel *, QCheckBox*, bool );
205 virtual ~BoolConfigControl() {};
206 virtual int getValue();
207 virtual void show() { checkbox->show(); }
208 virtual void hide() { checkbox->hide(); }
209 virtual int getType() { return CONFIG_ITEM_BOOL; }
215 /*******************************************************
216 * Float-based controls
217 *******************************************************/
218 class VFloatConfigControl : public ConfigControl
222 VFloatConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
223 ConfigControl(a,b,c) {};
224 VFloatConfigControl( vlc_object_t *a, module_config_t *b ) :
225 ConfigControl(a,b) {};
226 virtual ~VFloatConfigControl() {};
227 virtual float getValue() = 0;
228 virtual int getType() { return CONFIG_ITEM_FLOAT; }
231 class FloatConfigControl : public VFloatConfigControl
235 FloatConfigControl( vlc_object_t *, module_config_t *, QWidget *,
236 QGridLayout *, int& );
237 FloatConfigControl( vlc_object_t *, module_config_t *,
238 QLabel*, QDoubleSpinBox* );
239 virtual ~FloatConfigControl() {};
240 virtual float getValue();
241 virtual void show() { spin->show(); if( label ) label->show(); }
242 virtual void hide() { spin->hide(); if( label ) label->hide(); }
245 QDoubleSpinBox *spin;
252 class FloatRangeConfigControl : public FloatConfigControl
256 FloatRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
257 QGridLayout *, int& );
258 FloatRangeConfigControl( vlc_object_t *, module_config_t *,
259 QLabel*, QDoubleSpinBox* );
264 /*******************************************************
265 * String-based controls
266 *******************************************************/
267 class VStringConfigControl : public ConfigControl
271 VStringConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
272 ConfigControl(a,b,c) {};
273 VStringConfigControl( vlc_object_t *a, module_config_t *b ) :
274 ConfigControl(a,b) {};
275 virtual ~VStringConfigControl() {};
276 virtual QString getValue() = 0;
277 virtual int getType() { return CONFIG_ITEM_STRING; }
280 class StringConfigControl : public VStringConfigControl
284 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *,
285 QGridLayout *, int&, bool pwd );
286 StringConfigControl( vlc_object_t *, module_config_t *, QLabel *,
287 QLineEdit*, bool pwd );
288 virtual ~StringConfigControl() {};
289 virtual QString getValue() { return text->text(); };
290 virtual void show() { text->show(); if( label ) label->show(); }
291 virtual void hide() { text->hide(); if( label ) label->hide(); }
298 class FileConfigControl : public VStringConfigControl
302 FileConfigControl( vlc_object_t *, module_config_t *, QWidget *,
303 QGridLayout *, int& );
304 FileConfigControl( vlc_object_t *, module_config_t *, QLabel *,
305 QLineEdit *, QPushButton * );
306 virtual ~FileConfigControl() {};
307 virtual QString getValue() { return text->text(); };
308 virtual void show() { text->show(); if( label ) label->show(); browse->show(); }
309 virtual void hide() { text->hide(); if( label ) label->hide(); browse->hide(); }
311 virtual void updateField();
319 class DirectoryConfigControl : public FileConfigControl
323 DirectoryConfigControl( vlc_object_t *, module_config_t *, QWidget *,
324 QGridLayout *, int& );
325 DirectoryConfigControl( vlc_object_t *, module_config_t *, QLabel *,
326 QLineEdit *, QPushButton * );
327 virtual ~DirectoryConfigControl() {};
329 virtual void updateField();
333 class FontConfigControl : public FileConfigControl
337 FontConfigControl( vlc_object_t *, module_config_t *, QWidget *,
338 QGridLayout *, int&, bool pwd );
339 FontConfigControl( vlc_object_t *, module_config_t *, QLabel *,
340 QLineEdit *, QPushButton *, bool pwd );
341 virtual ~FontConfigControl() {};
343 virtual void updateField();
347 class ModuleConfigControl : public VStringConfigControl
350 ModuleConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool,
351 QGridLayout*, int& );
352 ModuleConfigControl( vlc_object_t *, module_config_t *, QLabel *,
354 virtual ~ModuleConfigControl() {};
355 virtual QString getValue();
356 virtual void hide() { combo->hide(); if( label ) label->hide(); }
357 virtual void show() { combo->show(); if( label ) label->show(); }
364 struct checkBoxListItem {
369 class ModuleListConfigControl : public VStringConfigControl
372 friend class ConfigControl;
374 ModuleListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
375 bool, QGridLayout*, int& );
376 // ModuleListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
377 // QComboBox*, bool );
378 virtual ~ModuleListConfigControl();
379 virtual QString getValue();
386 QVector<checkBoxListItem*> modules;
391 class StringListConfigControl : public VStringConfigControl
395 StringListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
396 bool, QGridLayout*, int& );
397 StringListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
399 virtual ~StringListConfigControl() {};
400 virtual QString getValue();
401 virtual void hide() { combo->hide(); if( label ) label->hide(); }
402 virtual void show() { combo->show(); if( label ) label->show(); }
405 void finish(module_config_t *, bool );
408 void actionRequested( int );
412 void setfillVLCConfigCombo(const char *configname, intf_thread_t *p_intf,
416 struct ModuleCheckBox {
421 class ModuleListConfigControl : public ConfigControl
424 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool
426 virtual ~StringConfigControl();
427 virtual QString getValue();
429 std::vector<ModuleCheckBox> checkboxes;
436 /**********************************************************************
437 * Key selector widget
438 **********************************************************************/
439 class KeyShortcutEdit: public QLineEdit
443 void setValue( int _value ){ value = _value; }
444 int getValue() const { return value; }
446 void setGlobal( bool _value ) { b_global = _value; }
447 bool getGlobal() const { return b_global; }
449 virtual void clear(void) { value = 0; QLineEdit::clear(); b_global = false;}
453 virtual void mousePressEvent( QMouseEvent *event );
458 class SearchLineEdit;
459 class KeySelectorControl : public ConfigControl
463 KeySelectorControl( vlc_object_t *, module_config_t *, QWidget *,
464 QGridLayout*, int& );
465 virtual int getType() { return CONFIG_ITEM_KEY; }
466 virtual ~KeySelectorControl() {};
467 virtual void hide() { table->hide(); if( label ) label->hide(); }
468 virtual void show() { table->show(); if( label ) label->show(); }
474 KeyShortcutEdit *shortcutValue;
475 QList<module_config_t *> values;
476 SearchLineEdit *actionSearch;
479 void selectKey( QTreeWidgetItem * = NULL, int column = 1 );
481 void filter( const QString & );
484 class KeyInputDialog : public QDialog
487 KeyInputDialog( QTreeWidget *, const QString&, QWidget *, bool b_global = false);
492 void checkForConflicts( int i_vlckey );
493 void keyPressEvent( QKeyEvent *);
494 void wheelEvent( QWheelEvent *);
495 QLabel *selected, *warning;
496 QVBoxLayout *vLayout;
497 QDialogButtonBox *buttonBox;