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 virtual int getType() = 0;
54 char * getName() { return p_item->psz_name; }
55 QWidget *getWidget() { assert( widget ); return widget; }
56 bool isAdvanced() { return p_item->b_advanced; }
57 virtual void hide() { getWidget()->hide(); };
58 virtual void show() { getWidget()->show(); };
60 static ConfigControl * createControl( vlc_object_t*,
61 module_config_t*,QWidget* );
62 static ConfigControl * createControl( vlc_object_t*,
63 module_config_t*,QWidget*,
67 module_config_t *p_item;
75 /*******************************************************
76 * Integer-based controls
77 *******************************************************/
78 class VIntConfigControl : public ConfigControl
81 VIntConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
82 ConfigControl(a,b,c) {};
83 VIntConfigControl( vlc_object_t *a, module_config_t *b ) :
84 ConfigControl(a,b) {};
85 virtual ~VIntConfigControl() {};
86 virtual int getValue() = 0;
87 virtual int getType() { return 1; }
90 class IntegerConfigControl : public VIntConfigControl
93 IntegerConfigControl( vlc_object_t *, module_config_t *, QWidget *,
95 IntegerConfigControl( vlc_object_t *, module_config_t *,
97 virtual ~IntegerConfigControl() {};
98 virtual int getValue();
99 virtual void show() { spin->show(); label->show(); }
100 virtual void hide() { spin->hide(); label->hide(); }
110 class IntegerRangeConfigControl : public IntegerConfigControl
113 IntegerRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
114 QGridLayout *, int );
115 IntegerRangeConfigControl( vlc_object_t *, module_config_t *,
116 QLabel*, QSpinBox* );
121 class IntegerListConfigControl : public VIntConfigControl
124 IntegerListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
125 bool, QGridLayout*, int );
126 IntegerListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
128 virtual ~IntegerListConfigControl() {};
129 virtual int getValue();
130 virtual void hide() { combo->hide(); label->hide(); }
131 virtual void show() { combo->show(); label->show(); }
138 class BoolConfigControl : public VIntConfigControl
141 BoolConfigControl( vlc_object_t *, module_config_t *, QWidget *,
142 QGridLayout *, int );
143 BoolConfigControl( vlc_object_t *, module_config_t *,
144 QLabel *, QCheckBox*, bool );
145 virtual ~BoolConfigControl() {};
146 virtual int getValue();
147 virtual void show() { checkbox->show(); }
148 virtual void hide() { checkbox->hide(); }
154 /*******************************************************
155 * Float-based controls
156 *******************************************************/
157 class VFloatConfigControl : public ConfigControl
160 VFloatConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
161 ConfigControl(a,b,c) {};
162 VFloatConfigControl( vlc_object_t *a, module_config_t *b ) :
163 ConfigControl(a,b) {};
164 virtual ~VFloatConfigControl() {};
165 virtual float getValue() = 0;
166 virtual int getType() { return 2; }
169 class FloatConfigControl : public VFloatConfigControl
172 FloatConfigControl( vlc_object_t *, module_config_t *, QWidget *,
173 QGridLayout *, int );
174 FloatConfigControl( vlc_object_t *, module_config_t *,
175 QLabel*, QDoubleSpinBox* );
176 virtual ~FloatConfigControl() {};
177 virtual float getValue();
178 virtual void show() { spin->show(); label->show(); }
179 virtual void hide() { spin->hide(); label->hide(); }
182 QDoubleSpinBox *spin;
189 class FloatRangeConfigControl : public FloatConfigControl
192 FloatRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
193 QGridLayout *, int );
194 FloatRangeConfigControl( vlc_object_t *, module_config_t *,
195 QLabel*, QDoubleSpinBox* );
200 class FloatConfigControl : public VFloatConfigControl
203 FloatConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
204 ConfigControl(a,b,c) {};
205 virtual ~FloatConfigControl() {};
206 virtual float getValue();
208 QDoubleSpinBox *spin;
212 /*******************************************************
213 * String-based controls
214 *******************************************************/
215 class VStringConfigControl : public ConfigControl
218 VStringConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
219 ConfigControl(a,b,c) {};
220 VStringConfigControl( vlc_object_t *a, module_config_t *b ) :
221 ConfigControl(a,b) {};
222 virtual ~VStringConfigControl() {};
223 virtual QString getValue() = 0;
224 virtual int getType() { return 3; }
227 class StringConfigControl : public VStringConfigControl
230 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *,
231 QGridLayout *, int, bool pwd );
232 StringConfigControl( vlc_object_t *, module_config_t *, QLabel *,
233 QLineEdit*, bool pwd );
234 virtual ~StringConfigControl() {};
235 virtual QString getValue() { return text->text(); };
236 virtual void show() { text->show(); label->show(); }
237 virtual void hide() { text->hide(); label->hide(); }
244 class ModuleConfigControl : public VStringConfigControl
247 ModuleConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool,
249 ModuleConfigControl( vlc_object_t *, module_config_t *, QLabel *,
251 virtual ~ModuleConfigControl() {};
252 virtual QString getValue();
253 virtual void hide() { combo->hide(); label->hide(); }
254 virtual void show() { combo->show(); label->show(); }
261 class StringListConfigControl : public VStringConfigControl
264 StringListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
265 bool, QGridLayout*, int );
266 StringListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
268 virtual ~StringListConfigControl() {};
269 virtual QString getValue();
270 virtual void hide() { combo->hide(); label->hide(); }
271 virtual void show() { combo->show(); label->show(); }
278 struct ModuleCheckBox {
283 class ModuleListConfigControl : public ConfigControl
286 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool
288 virtual ~StringConfigControl();
289 virtual QString getValue();
291 std::vector<ModuleCheckBox> checkboxes;