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 virtual ~IntegerConfigControl() {};
105 virtual int getValue();
106 virtual void show() { spin->show(); label->show(); }
107 virtual void hide() { spin->hide(); label->hide(); }
117 class IntegerRangeConfigControl : public IntegerConfigControl
120 IntegerRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
121 QGridLayout *, int& );
122 IntegerRangeConfigControl( vlc_object_t *, module_config_t *,
123 QLabel*, QSpinBox* );
128 class IntegerListConfigControl : public VIntConfigControl
131 IntegerListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
132 bool, QGridLayout*, int& );
133 IntegerListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
135 virtual ~IntegerListConfigControl() {};
136 virtual int getValue();
137 virtual void hide() { combo->hide(); label->hide(); }
138 virtual void show() { combo->show(); label->show(); }
145 class BoolConfigControl : public VIntConfigControl
148 BoolConfigControl( vlc_object_t *, module_config_t *, QWidget *,
149 QGridLayout *, int& );
150 BoolConfigControl( vlc_object_t *, module_config_t *,
151 QLabel *, QCheckBox*, bool );
152 virtual ~BoolConfigControl() {};
153 virtual int getValue();
154 virtual void show() { checkbox->show(); }
155 virtual void hide() { checkbox->hide(); }
161 /*******************************************************
162 * Float-based controls
163 *******************************************************/
164 class VFloatConfigControl : public ConfigControl
167 VFloatConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
168 ConfigControl(a,b,c) {};
169 VFloatConfigControl( vlc_object_t *a, module_config_t *b ) :
170 ConfigControl(a,b) {};
171 virtual ~VFloatConfigControl() {};
172 virtual float getValue() = 0;
173 virtual int getType() { return 2; }
176 class FloatConfigControl : public VFloatConfigControl
179 FloatConfigControl( vlc_object_t *, module_config_t *, QWidget *,
180 QGridLayout *, int& );
181 FloatConfigControl( vlc_object_t *, module_config_t *,
182 QLabel*, QDoubleSpinBox* );
183 virtual ~FloatConfigControl() {};
184 virtual float getValue();
185 virtual void show() { spin->show(); label->show(); }
186 virtual void hide() { spin->hide(); label->hide(); }
189 QDoubleSpinBox *spin;
196 class FloatRangeConfigControl : public FloatConfigControl
199 FloatRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
200 QGridLayout *, int& );
201 FloatRangeConfigControl( vlc_object_t *, module_config_t *,
202 QLabel*, QDoubleSpinBox* );
207 /*******************************************************
208 * String-based controls
209 *******************************************************/
210 class VStringConfigControl : public ConfigControl
213 VStringConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
214 ConfigControl(a,b,c) {};
215 VStringConfigControl( vlc_object_t *a, module_config_t *b ) :
216 ConfigControl(a,b) {};
217 virtual ~VStringConfigControl() {};
218 virtual QString getValue() = 0;
219 virtual int getType() { return 3; }
222 class StringConfigControl : public VStringConfigControl
225 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *,
226 QGridLayout *, int&, bool pwd );
227 StringConfigControl( vlc_object_t *, module_config_t *, QLabel *,
228 QLineEdit*, bool pwd );
229 virtual ~StringConfigControl() {};
230 virtual QString getValue() { return text->text(); };
231 virtual void show() { text->show(); label->show(); }
232 virtual void hide() { text->hide(); label->hide(); }
239 class ModuleConfigControl : public VStringConfigControl
242 ModuleConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool,
243 QGridLayout*, int& );
244 ModuleConfigControl( vlc_object_t *, module_config_t *, QLabel *,
246 virtual ~ModuleConfigControl() {};
247 virtual QString getValue();
248 virtual void hide() { combo->hide(); label->hide(); }
249 virtual void show() { combo->show(); label->show(); }
256 class ModuleListConfigControl : public VStringConfigControl
260 ModuleListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
261 bool, QGridLayout*, int& );
262 // ModuleListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
263 // QComboBox*, bool );
264 virtual ~ModuleListConfigControl();
265 virtual QString getValue();
269 void wakeUp_TheUserJustClickedOnSomething( int value );
272 QVector<QCheckBox*> modules;
277 class StringListConfigControl : public VStringConfigControl
280 StringListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
281 bool, QGridLayout*, int& );
282 StringListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
284 virtual ~StringListConfigControl() {};
285 virtual QString getValue();
286 virtual void hide() { combo->hide(); label->hide(); }
287 virtual void show() { combo->show(); label->show(); }
294 struct ModuleCheckBox {
299 class ModuleListConfigControl : public ConfigControl
302 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool
304 virtual ~StringConfigControl();
305 virtual QString getValue();
307 std::vector<ModuleCheckBox> checkboxes;
314 /**********************************************************************
315 * Key selector widget
316 **********************************************************************/
317 class KeyInputDialog : public QDialog
320 KeyInputDialog( QList<module_config_t *> &, const char * );
324 void keyPressEvent( QKeyEvent *);
327 const char * keyToChange;
328 QList<module_config_t*> values;
331 class KeySelectorControl : public ConfigControl
335 KeySelectorControl( vlc_object_t *, module_config_t *, QWidget *,
336 QGridLayout*, int& );
337 virtual int getType() { return 4; }
338 virtual ~KeySelectorControl() {};
339 virtual void hide() { table->hide(); label->hide(); }
340 virtual void show() { table->show(); label->show(); }
346 QList<module_config_t *> values;
348 void selectKey( QTreeWidgetItem *);