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>
44 class ConfigControl : public QObject
48 ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf,
49 QWidget *p ) : p_this( _p_this ), p_item( _p_conf )
51 widget = new QWidget( p );
53 ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf ) :
54 p_this (_p_this ), p_item( _p_conf )
58 virtual ~ConfigControl() {};
59 virtual int getType() = 0;
60 const char * getName() { return p_item->psz_name; }
61 QWidget *getWidget() { assert( widget ); return widget; }
62 bool isAdvanced() { return p_item->b_advanced; }
63 virtual void hide() { getWidget()->hide(); };
64 virtual void show() { getWidget()->show(); };
66 static ConfigControl * createControl( vlc_object_t*,
67 module_config_t*,QWidget* );
68 static ConfigControl * createControl( vlc_object_t*,
69 module_config_t*,QWidget*,
70 QGridLayout *, int& );
71 void doApply( intf_thread_t *);
74 module_config_t *p_item;
82 /*******************************************************
83 * Integer-based controls
84 *******************************************************/
85 class VIntConfigControl : public ConfigControl
88 VIntConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
89 ConfigControl(a,b,c) {};
90 VIntConfigControl( vlc_object_t *a, module_config_t *b ) :
91 ConfigControl(a,b) {};
92 virtual ~VIntConfigControl() {};
93 virtual int getValue() = 0;
94 virtual int getType() { return 1; }
97 class IntegerConfigControl : public VIntConfigControl
100 IntegerConfigControl( vlc_object_t *, module_config_t *, QWidget *,
101 QGridLayout *, int& );
102 IntegerConfigControl( vlc_object_t *, module_config_t *,
103 QLabel*, QSpinBox* );
104 IntegerConfigControl( vlc_object_t *, module_config_t *,
106 virtual ~IntegerConfigControl() {};
107 virtual int getValue();
108 virtual void show() { spin->show(); label->show(); }
109 virtual void hide() { spin->hide(); label->hide(); }
118 class IntegerRangeConfigControl : public IntegerConfigControl
121 IntegerRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
122 QGridLayout *, int& );
123 IntegerRangeConfigControl( vlc_object_t *, module_config_t *,
124 QLabel*, QSpinBox* );
129 class IntegerRangeSliderConfigControl : public VIntConfigControl
132 IntegerRangeSliderConfigControl( vlc_object_t *, module_config_t *,
133 QLabel *, QSlider *, bool * );
134 virtual ~IntegerRangeSliderConfigControl() {};
135 virtual int getValue();
143 class IntegerListConfigControl : public VIntConfigControl
146 IntegerListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
147 bool, QGridLayout*, int& );
148 IntegerListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
150 virtual ~IntegerListConfigControl() {};
151 virtual int getValue();
152 virtual void hide() { combo->hide(); label->hide(); }
153 virtual void show() { combo->show(); label->show(); }
160 class BoolConfigControl : public VIntConfigControl
163 BoolConfigControl( vlc_object_t *, module_config_t *, QWidget *,
164 QGridLayout *, int& );
165 BoolConfigControl( vlc_object_t *, module_config_t *,
166 QLabel *, QCheckBox*, bool );
167 virtual ~BoolConfigControl() {};
168 virtual int getValue();
169 virtual void show() { checkbox->show(); }
170 virtual void hide() { checkbox->hide(); }
176 /*******************************************************
177 * Float-based controls
178 *******************************************************/
179 class VFloatConfigControl : public ConfigControl
182 VFloatConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
183 ConfigControl(a,b,c) {};
184 VFloatConfigControl( vlc_object_t *a, module_config_t *b ) :
185 ConfigControl(a,b) {};
186 virtual ~VFloatConfigControl() {};
187 virtual float getValue() = 0;
188 virtual int getType() { return 2; }
191 class FloatConfigControl : public VFloatConfigControl
194 FloatConfigControl( vlc_object_t *, module_config_t *, QWidget *,
195 QGridLayout *, int& );
196 FloatConfigControl( vlc_object_t *, module_config_t *,
197 QLabel*, QDoubleSpinBox* );
198 virtual ~FloatConfigControl() {};
199 virtual float getValue();
200 virtual void show() { spin->show(); label->show(); }
201 virtual void hide() { spin->hide(); label->hide(); }
204 QDoubleSpinBox *spin;
211 class FloatRangeConfigControl : public FloatConfigControl
214 FloatRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
215 QGridLayout *, int& );
216 FloatRangeConfigControl( vlc_object_t *, module_config_t *,
217 QLabel*, QDoubleSpinBox* );
222 /*******************************************************
223 * String-based controls
224 *******************************************************/
225 class VStringConfigControl : public ConfigControl
228 VStringConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
229 ConfigControl(a,b,c) {};
230 VStringConfigControl( vlc_object_t *a, module_config_t *b ) :
231 ConfigControl(a,b) {};
232 virtual ~VStringConfigControl() {};
233 virtual QString getValue() = 0;
234 virtual int getType() { return 3; }
237 class StringConfigControl : public VStringConfigControl
240 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *,
241 QGridLayout *, int&, bool pwd );
242 StringConfigControl( vlc_object_t *, module_config_t *, QLabel *,
243 QLineEdit*, bool pwd );
244 virtual ~StringConfigControl() {};
245 virtual QString getValue() { return text->text(); };
246 virtual void show() { text->show(); label->show(); }
247 virtual void hide() { text->hide(); label->hide(); }
254 class ModuleConfigControl : public VStringConfigControl
257 ModuleConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool,
258 QGridLayout*, int& );
259 ModuleConfigControl( vlc_object_t *, module_config_t *, QLabel *,
261 virtual ~ModuleConfigControl() {};
262 virtual QString getValue();
263 virtual void hide() { combo->hide(); label->hide(); }
264 virtual void show() { combo->show(); label->show(); }
271 class ModuleListConfigControl : public VStringConfigControl
275 ModuleListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
276 bool, QGridLayout*, int& );
277 // ModuleListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
278 // QComboBox*, bool );
279 virtual ~ModuleListConfigControl();
280 virtual QString getValue();
284 void wakeUp_TheUserJustClickedOnSomething( int value );
287 QVector<QCheckBox*> modules;
292 class StringListConfigControl : public VStringConfigControl
295 StringListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
296 bool, QGridLayout*, int& );
297 StringListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
299 virtual ~StringListConfigControl() {};
300 virtual QString getValue();
301 virtual void hide() { combo->hide(); label->hide(); }
302 virtual void show() { combo->show(); label->show(); }
309 struct ModuleCheckBox {
314 class ModuleListConfigControl : public ConfigControl
317 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool
319 virtual ~StringConfigControl();
320 virtual QString getValue();
322 std::vector<ModuleCheckBox> checkboxes;
329 /**********************************************************************
330 * Key selector widget
331 **********************************************************************/
332 class KeyInputDialog : public QDialog
335 KeyInputDialog( QList<module_config_t *> &, const char * );
339 void keyPressEvent( QKeyEvent *);
342 const char * keyToChange;
343 QList<module_config_t*> values;
346 class KeySelectorControl : public ConfigControl
350 KeySelectorControl( vlc_object_t *, module_config_t *, QWidget *,
351 QGridLayout*, int& );
352 virtual int getType() { return 4; }
353 virtual ~KeySelectorControl() {};
354 virtual void hide() { table->hide(); label->hide(); }
355 virtual void show() { table->show(); label->show(); }
361 QList<module_config_t *> values;
363 void selectKey( QTreeWidgetItem *);