1 /*****************************************************************************
2 * preferences_widgets.hpp : Widgets for preferences panels
3 ****************************************************************************
4 * Copyright (C) 2006 the VideoLAN team
7 * Authors: Clément Stenac <zorglub@videolan.org>
8 * Antoine Cellerier <dionoea@videolan.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 #ifndef _INFOPANELS_H_
26 #define _INFOPANELS_H_
29 #include <QTreeWidget>
32 #include <QDoubleSpinBox>
45 class ConfigControl : public QObject
49 ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf,
50 QWidget *p ) : p_this( _p_this ), p_item( _p_conf )
52 widget = new QWidget( p );
54 ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf ) :
55 p_this (_p_this ), p_item( _p_conf )
59 virtual ~ConfigControl() {};
60 virtual int getType() = 0;
61 const char * getName() { return p_item->psz_name; }
62 QWidget *getWidget() { assert( widget ); return widget; }
63 bool isAdvanced() { return p_item->b_advanced; }
64 virtual void hide() { getWidget()->hide(); };
65 virtual void show() { getWidget()->show(); };
67 static ConfigControl * createControl( vlc_object_t*,
68 module_config_t*,QWidget* );
69 static ConfigControl * createControl( vlc_object_t*,
70 module_config_t*,QWidget*,
71 QGridLayout *, int& );
72 void doApply( intf_thread_t *);
75 module_config_t *p_item;
83 /*******************************************************
84 * Integer-based controls
85 *******************************************************/
86 class VIntConfigControl : public ConfigControl
89 VIntConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
90 ConfigControl(a,b,c) {};
91 VIntConfigControl( vlc_object_t *a, module_config_t *b ) :
92 ConfigControl(a,b) {};
93 virtual ~VIntConfigControl() {};
94 virtual int getValue() = 0;
95 virtual int getType() { return 1; }
98 class IntegerConfigControl : public VIntConfigControl
101 IntegerConfigControl( vlc_object_t *, module_config_t *, QWidget *,
102 QGridLayout *, int& );
103 IntegerConfigControl( vlc_object_t *, module_config_t *,
104 QLabel*, QSpinBox* );
105 IntegerConfigControl( vlc_object_t *, module_config_t *,
107 virtual ~IntegerConfigControl() {};
108 virtual int getValue();
109 virtual void show() { spin->show(); label->show(); }
110 virtual void hide() { spin->hide(); label->hide(); }
119 class IntegerRangeConfigControl : public IntegerConfigControl
122 IntegerRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
123 QGridLayout *, int& );
124 IntegerRangeConfigControl( vlc_object_t *, module_config_t *,
125 QLabel*, QSpinBox* );
130 class IntegerRangeSliderConfigControl : public VIntConfigControl
133 IntegerRangeSliderConfigControl( vlc_object_t *, module_config_t *,
134 QLabel *, QSlider * );
135 virtual ~IntegerRangeSliderConfigControl() {};
136 virtual int getValue();
144 class IntegerListConfigControl : public VIntConfigControl
147 IntegerListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
148 bool, QGridLayout*, int& );
149 IntegerListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
151 virtual ~IntegerListConfigControl() {};
152 virtual int getValue();
153 virtual void hide() { combo->hide(); label->hide(); }
154 virtual void show() { combo->show(); label->show(); }
161 class BoolConfigControl : public VIntConfigControl
164 BoolConfigControl( vlc_object_t *, module_config_t *, QWidget *,
165 QGridLayout *, int& );
166 BoolConfigControl( vlc_object_t *, module_config_t *,
167 QLabel *, QCheckBox*, bool );
168 virtual ~BoolConfigControl() {};
169 virtual int getValue();
170 virtual void show() { checkbox->show(); }
171 virtual void hide() { checkbox->hide(); }
177 /*******************************************************
178 * Float-based controls
179 *******************************************************/
180 class VFloatConfigControl : public ConfigControl
183 VFloatConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
184 ConfigControl(a,b,c) {};
185 VFloatConfigControl( vlc_object_t *a, module_config_t *b ) :
186 ConfigControl(a,b) {};
187 virtual ~VFloatConfigControl() {};
188 virtual float getValue() = 0;
189 virtual int getType() { return 2; }
192 class FloatConfigControl : public VFloatConfigControl
195 FloatConfigControl( vlc_object_t *, module_config_t *, QWidget *,
196 QGridLayout *, int& );
197 FloatConfigControl( vlc_object_t *, module_config_t *,
198 QLabel*, QDoubleSpinBox* );
199 virtual ~FloatConfigControl() {};
200 virtual float getValue();
201 virtual void show() { spin->show(); label->show(); }
202 virtual void hide() { spin->hide(); label->hide(); }
205 QDoubleSpinBox *spin;
212 class FloatRangeConfigControl : public FloatConfigControl
215 FloatRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
216 QGridLayout *, int& );
217 FloatRangeConfigControl( vlc_object_t *, module_config_t *,
218 QLabel*, QDoubleSpinBox* );
223 /*******************************************************
224 * String-based controls
225 *******************************************************/
226 class VStringConfigControl : public ConfigControl
229 VStringConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
230 ConfigControl(a,b,c) {};
231 VStringConfigControl( vlc_object_t *a, module_config_t *b ) :
232 ConfigControl(a,b) {};
233 virtual ~VStringConfigControl() {};
234 virtual QString getValue() = 0;
235 virtual int getType() { return 3; }
238 class StringConfigControl : public VStringConfigControl
241 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *,
242 QGridLayout *, int&, bool pwd );
243 StringConfigControl( vlc_object_t *, module_config_t *, QLabel *,
244 QLineEdit*, bool pwd );
245 virtual ~StringConfigControl() {};
246 virtual QString getValue() { return text->text(); };
247 virtual void show() { text->show(); label->show(); }
248 virtual void hide() { text->hide(); label->hide(); }
255 class FileConfigControl : public VStringConfigControl
259 FileConfigControl( vlc_object_t *, module_config_t *, QWidget *,
260 QGridLayout *, int&, bool pwd );
261 FileConfigControl( vlc_object_t *, module_config_t *, QLabel *,
262 QLineEdit*, bool pwd );
263 virtual ~FileConfigControl() {};
264 virtual QString getValue() { return text->text(); };
265 virtual void show() { text->show(); label->show(); }
266 virtual void hide() { text->hide(); label->hide(); }
277 class ModuleConfigControl : public VStringConfigControl
280 ModuleConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool,
281 QGridLayout*, int& );
282 ModuleConfigControl( vlc_object_t *, module_config_t *, QLabel *,
284 virtual ~ModuleConfigControl() {};
285 virtual QString getValue();
286 virtual void hide() { combo->hide(); label->hide(); }
287 virtual void show() { combo->show(); label->show(); }
294 class ModuleListConfigControl : public VStringConfigControl
298 ModuleListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
299 bool, QGridLayout*, int& );
300 // ModuleListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
301 // QComboBox*, bool );
302 virtual ~ModuleListConfigControl();
303 virtual QString getValue();
307 void wakeUp_TheUserJustClickedOnSomething( int value );
310 QVector<QCheckBox*> modules;
315 class StringListConfigControl : public VStringConfigControl
318 StringListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
319 bool, QGridLayout*, int& );
320 StringListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
322 virtual ~StringListConfigControl() {};
323 virtual QString getValue();
324 virtual void hide() { combo->hide(); label->hide(); }
325 virtual void show() { combo->show(); label->show(); }
332 struct ModuleCheckBox {
337 class ModuleListConfigControl : public ConfigControl
340 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool
342 virtual ~StringConfigControl();
343 virtual QString getValue();
345 std::vector<ModuleCheckBox> checkboxes;
352 /**********************************************************************
353 * Key selector widget
354 **********************************************************************/
355 class KeyInputDialog : public QDialog
358 KeyInputDialog( QList<module_config_t *> &, const char * );
362 void keyPressEvent( QKeyEvent *);
365 const char * keyToChange;
366 QList<module_config_t*> values;
369 class KeySelectorControl : public ConfigControl
373 KeySelectorControl( vlc_object_t *, module_config_t *, QWidget *,
374 QGridLayout*, int& );
375 virtual int getType() { return 4; }
376 virtual ~KeySelectorControl() {};
377 virtual void hide() { table->hide(); label->hide(); }
378 virtual void show() { table->show(); label->show(); }
384 QList<module_config_t *> values;
386 void selectKey( QTreeWidgetItem *);