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>
34 #include "ui/input_stats.h"
38 class ConfigControl : public QObject
42 ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf,
43 QWidget *p ) : p_this( _p_this ), p_item( _p_conf )
45 widget = new QWidget( p );
47 ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf ) :
48 p_this (_p_this ), p_item( _p_conf )
52 virtual ~ConfigControl() {};
53 QString getName() { return qfu( p_item->psz_name ); }
54 QWidget *getWidget() { assert( widget ); return widget; }
55 bool isAdvanced() { return p_item->b_advanced; }
56 virtual void hide() { getWidget()->hide(); };
57 virtual void show() { getWidget()->show(); };
59 static ConfigControl * createControl( vlc_object_t*,
60 module_config_t*,QWidget* );
61 static ConfigControl * createControl( vlc_object_t*,
62 module_config_t*,QWidget*,
66 module_config_t *p_item;
74 /*******************************************************
75 * Integer-based controls
76 *******************************************************/
77 class VIntConfigControl : public ConfigControl
80 VIntConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
81 ConfigControl(a,b,c) {};
82 VIntConfigControl( vlc_object_t *a, module_config_t *b ) :
83 ConfigControl(a,b) {};
84 virtual ~VIntConfigControl() {};
85 virtual int getValue() = 0;
88 class IntegerConfigControl : public VIntConfigControl
91 IntegerConfigControl( vlc_object_t *, module_config_t *, QWidget *,
93 IntegerConfigControl( vlc_object_t *, module_config_t *,
95 virtual ~IntegerConfigControl() {};
96 virtual int getValue();
97 virtual void show() { spin->show(); label->show(); }
98 virtual void hide() { spin->hide(); label->hide(); }
108 class IntegerRangeConfigControl : public IntegerConfigControl
111 IntegerRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
112 QGridLayout *, int );
113 IntegerRangeConfigControl( vlc_object_t *, module_config_t *,
114 QLabel*, QSpinBox* );
119 class IntegerListConfigControl : public VIntConfigControl
122 IntegerListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
123 bool, QGridLayout*, int );
124 IntegerListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
126 virtual ~IntegerListConfigControl() {};
127 virtual int getValue();
128 virtual void hide() { combo->hide(); label->hide(); }
129 virtual void show() { combo->show(); label->show(); }
136 class BoolConfigControl : public VIntConfigControl
139 BoolConfigControl( vlc_object_t *, module_config_t *, QWidget *,
140 QGridLayout *, int );
141 BoolConfigControl( vlc_object_t *, module_config_t *,
142 QLabel *, QCheckBox*, bool );
143 virtual ~BoolConfigControl() {};
144 virtual int getValue();
145 virtual void show() { checkbox->show(); }
146 virtual void hide() { checkbox->hide(); }
152 /*******************************************************
153 * Float-based controls
154 *******************************************************/
155 class VFloatConfigControl : public ConfigControl
158 VFloatConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
159 ConfigControl(a,b,c) {};
160 VFloatConfigControl( vlc_object_t *a, module_config_t *b ) :
161 ConfigControl(a,b) {};
162 virtual ~VFloatConfigControl() {};
163 virtual float getValue() = 0;
166 class FloatConfigControl : public VFloatConfigControl
169 FloatConfigControl( vlc_object_t *, module_config_t *, QWidget *,
170 QGridLayout *, int );
171 FloatConfigControl( vlc_object_t *, module_config_t *,
172 QLabel*, QDoubleSpinBox* );
173 virtual ~FloatConfigControl() {};
174 virtual float getValue();
175 virtual void show() { spin->show(); label->show(); }
176 virtual void hide() { spin->hide(); label->hide(); }
179 QDoubleSpinBox *spin;
186 class FloatRangeConfigControl : public FloatConfigControl
189 FloatRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
190 QGridLayout *, int );
191 FloatRangeConfigControl( vlc_object_t *, module_config_t *,
192 QLabel*, QDoubleSpinBox* );
197 class FloatConfigControl : public VFloatConfigControl
200 FloatConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
201 ConfigControl(a,b,c) {};
202 virtual ~FloatConfigControl() {};
203 virtual float getValue();
205 QDoubleSpinBox *spin;
209 /*******************************************************
210 * String-based controls
211 *******************************************************/
212 class VStringConfigControl : public ConfigControl
215 VStringConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
216 ConfigControl(a,b,c) {};
217 VStringConfigControl( vlc_object_t *a, module_config_t *b ) :
218 ConfigControl(a,b) {};
219 virtual ~VStringConfigControl() {};
220 virtual QString getValue() = 0;
223 class StringConfigControl : public VStringConfigControl
226 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *,
227 QGridLayout *, int, bool pwd );
228 StringConfigControl( vlc_object_t *, module_config_t *, QLabel *,
229 QLineEdit*, bool pwd );
230 virtual ~StringConfigControl() {};
231 virtual QString getValue() { return text->text(); };
232 virtual void show() { text->show(); label->show(); }
233 virtual void hide() { text->hide(); label->hide(); }
240 class ModuleConfigControl : public VStringConfigControl
243 ModuleConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool,
245 ModuleConfigControl( vlc_object_t *, module_config_t *, QLabel *,
247 virtual ~ModuleConfigControl() {};
248 virtual QString getValue();
249 virtual void hide() { combo->hide(); label->hide(); }
250 virtual void show() { combo->show(); label->show(); }
257 class StringListConfigControl : public VStringConfigControl
260 StringListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
261 bool, QGridLayout*, int );
262 StringListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
264 virtual ~StringListConfigControl() {};
265 virtual QString getValue();
266 virtual void hide() { combo->hide(); label->hide(); }
267 virtual void show() { combo->show(); label->show(); }
274 struct ModuleCheckBox {
279 class ModuleListConfigControl : public ConfigControl
282 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool
284 virtual ~StringConfigControl();
285 virtual QString getValue();
287 std::vector<ModuleCheckBox> checkboxes;