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_
31 #include <QDoubleSpinBox>
35 #include "ui/input_stats.h"
39 class ConfigControl : public QObject
43 ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf,
44 QWidget *p ) : p_this( _p_this ), p_item( _p_conf )
46 widget = new QWidget( p );
48 ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf ) :
49 p_this (_p_this ), p_item( _p_conf )
53 virtual ~ConfigControl() {};
54 virtual int getType() = 0;
55 char * getName() { return p_item->psz_name; }
56 QWidget *getWidget() { assert( widget ); return widget; }
57 bool isAdvanced() { return p_item->b_advanced; }
58 virtual void hide() { getWidget()->hide(); };
59 virtual void show() { getWidget()->show(); };
61 static ConfigControl * createControl( vlc_object_t*,
62 module_config_t*,QWidget* );
63 static ConfigControl * createControl( vlc_object_t*,
64 module_config_t*,QWidget*,
65 QGridLayout *, int& );
66 void doApply( intf_thread_t *);
69 module_config_t *p_item;
77 /*******************************************************
78 * Integer-based controls
79 *******************************************************/
80 class VIntConfigControl : public ConfigControl
83 VIntConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
84 ConfigControl(a,b,c) {};
85 VIntConfigControl( vlc_object_t *a, module_config_t *b ) :
86 ConfigControl(a,b) {};
87 virtual ~VIntConfigControl() {};
88 virtual int getValue() = 0;
89 virtual int getType() { return 1; }
92 class IntegerConfigControl : public VIntConfigControl
95 IntegerConfigControl( vlc_object_t *, module_config_t *, QWidget *,
96 QGridLayout *, int& );
97 IntegerConfigControl( vlc_object_t *, module_config_t *,
99 virtual ~IntegerConfigControl() {};
100 virtual int getValue();
101 virtual void show() { spin->show(); label->show(); }
102 virtual void hide() { spin->hide(); label->hide(); }
112 class IntegerRangeConfigControl : public IntegerConfigControl
115 IntegerRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
116 QGridLayout *, int& );
117 IntegerRangeConfigControl( vlc_object_t *, module_config_t *,
118 QLabel*, QSpinBox* );
123 class IntegerListConfigControl : public VIntConfigControl
126 IntegerListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
127 bool, QGridLayout*, int& );
128 IntegerListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
130 virtual ~IntegerListConfigControl() {};
131 virtual int getValue();
132 virtual void hide() { combo->hide(); label->hide(); }
133 virtual void show() { combo->show(); label->show(); }
140 class BoolConfigControl : public VIntConfigControl
143 BoolConfigControl( vlc_object_t *, module_config_t *, QWidget *,
144 QGridLayout *, int& );
145 BoolConfigControl( vlc_object_t *, module_config_t *,
146 QLabel *, QCheckBox*, bool );
147 virtual ~BoolConfigControl() {};
148 virtual int getValue();
149 virtual void show() { checkbox->show(); }
150 virtual void hide() { checkbox->hide(); }
156 /*******************************************************
157 * Float-based controls
158 *******************************************************/
159 class VFloatConfigControl : public ConfigControl
162 VFloatConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
163 ConfigControl(a,b,c) {};
164 VFloatConfigControl( vlc_object_t *a, module_config_t *b ) :
165 ConfigControl(a,b) {};
166 virtual ~VFloatConfigControl() {};
167 virtual float getValue() = 0;
168 virtual int getType() { return 2; }
171 class FloatConfigControl : public VFloatConfigControl
174 FloatConfigControl( vlc_object_t *, module_config_t *, QWidget *,
175 QGridLayout *, int& );
176 FloatConfigControl( vlc_object_t *, module_config_t *,
177 QLabel*, QDoubleSpinBox* );
178 virtual ~FloatConfigControl() {};
179 virtual float getValue();
180 virtual void show() { spin->show(); label->show(); }
181 virtual void hide() { spin->hide(); label->hide(); }
184 QDoubleSpinBox *spin;
191 class FloatRangeConfigControl : public FloatConfigControl
194 FloatRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
195 QGridLayout *, int& );
196 FloatRangeConfigControl( vlc_object_t *, module_config_t *,
197 QLabel*, QDoubleSpinBox* );
202 /*******************************************************
203 * String-based controls
204 *******************************************************/
205 class VStringConfigControl : public ConfigControl
208 VStringConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
209 ConfigControl(a,b,c) {};
210 VStringConfigControl( vlc_object_t *a, module_config_t *b ) :
211 ConfigControl(a,b) {};
212 virtual ~VStringConfigControl() {};
213 virtual QString getValue() = 0;
214 virtual int getType() { return 3; }
217 class StringConfigControl : public VStringConfigControl
220 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *,
221 QGridLayout *, int&, bool pwd );
222 StringConfigControl( vlc_object_t *, module_config_t *, QLabel *,
223 QLineEdit*, bool pwd );
224 virtual ~StringConfigControl() {};
225 virtual QString getValue() { return text->text(); };
226 virtual void show() { text->show(); label->show(); }
227 virtual void hide() { text->hide(); label->hide(); }
234 class ModuleConfigControl : public VStringConfigControl
237 ModuleConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool,
238 QGridLayout*, int& );
239 ModuleConfigControl( vlc_object_t *, module_config_t *, QLabel *,
241 virtual ~ModuleConfigControl() {};
242 virtual QString getValue();
243 virtual void hide() { combo->hide(); label->hide(); }
244 virtual void show() { combo->show(); label->show(); }
251 class ModuleListConfigControl : public VStringConfigControl
255 ModuleListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
256 bool, QGridLayout*, int& );
257 // ModuleListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
258 // QComboBox*, bool );
259 virtual ~ModuleListConfigControl();
260 virtual QString getValue();
264 void wakeUp_TheUserJustClickedOnSomething( int value );
267 QVector<QCheckBox*> modules;
272 class StringListConfigControl : public VStringConfigControl
275 StringListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
276 bool, QGridLayout*, int& );
277 StringListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
279 virtual ~StringListConfigControl() {};
280 virtual QString getValue();
281 virtual void hide() { combo->hide(); label->hide(); }
282 virtual void show() { combo->show(); label->show(); }
289 struct ModuleCheckBox {
294 class ModuleListConfigControl : public ConfigControl
297 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool
299 virtual ~StringConfigControl();
300 virtual QString getValue();
302 std::vector<ModuleCheckBox> checkboxes;