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*,
65 void doApply( intf_thread_t *);
68 module_config_t *p_item;
76 /*******************************************************
77 * Integer-based controls
78 *******************************************************/
79 class VIntConfigControl : public ConfigControl
82 VIntConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
83 ConfigControl(a,b,c) {};
84 VIntConfigControl( vlc_object_t *a, module_config_t *b ) :
85 ConfigControl(a,b) {};
86 virtual ~VIntConfigControl() {};
87 virtual int getValue() = 0;
88 virtual int getType() { return 1; }
91 class IntegerConfigControl : public VIntConfigControl
94 IntegerConfigControl( vlc_object_t *, module_config_t *, QWidget *,
96 IntegerConfigControl( vlc_object_t *, module_config_t *,
98 virtual ~IntegerConfigControl() {};
99 virtual int getValue();
100 virtual void show() { spin->show(); label->show(); }
101 virtual void hide() { spin->hide(); label->hide(); }
111 class IntegerRangeConfigControl : public IntegerConfigControl
114 IntegerRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
115 QGridLayout *, int );
116 IntegerRangeConfigControl( vlc_object_t *, module_config_t *,
117 QLabel*, QSpinBox* );
122 class IntegerListConfigControl : public VIntConfigControl
125 IntegerListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
126 bool, QGridLayout*, int );
127 IntegerListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
129 virtual ~IntegerListConfigControl() {};
130 virtual int getValue();
131 virtual void hide() { combo->hide(); label->hide(); }
132 virtual void show() { combo->show(); label->show(); }
139 class BoolConfigControl : public VIntConfigControl
142 BoolConfigControl( vlc_object_t *, module_config_t *, QWidget *,
143 QGridLayout *, int );
144 BoolConfigControl( vlc_object_t *, module_config_t *,
145 QLabel *, QCheckBox*, bool );
146 virtual ~BoolConfigControl() {};
147 virtual int getValue();
148 virtual void show() { checkbox->show(); }
149 virtual void hide() { checkbox->hide(); }
155 /*******************************************************
156 * Float-based controls
157 *******************************************************/
158 class VFloatConfigControl : public ConfigControl
161 VFloatConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
162 ConfigControl(a,b,c) {};
163 VFloatConfigControl( vlc_object_t *a, module_config_t *b ) :
164 ConfigControl(a,b) {};
165 virtual ~VFloatConfigControl() {};
166 virtual float getValue() = 0;
167 virtual int getType() { return 2; }
170 class FloatConfigControl : public VFloatConfigControl
173 FloatConfigControl( vlc_object_t *, module_config_t *, QWidget *,
174 QGridLayout *, int );
175 FloatConfigControl( vlc_object_t *, module_config_t *,
176 QLabel*, QDoubleSpinBox* );
177 virtual ~FloatConfigControl() {};
178 virtual float getValue();
179 virtual void show() { spin->show(); label->show(); }
180 virtual void hide() { spin->hide(); label->hide(); }
183 QDoubleSpinBox *spin;
190 class FloatRangeConfigControl : public FloatConfigControl
193 FloatRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
194 QGridLayout *, int );
195 FloatRangeConfigControl( vlc_object_t *, module_config_t *,
196 QLabel*, QDoubleSpinBox* );
201 /*******************************************************
202 * String-based controls
203 *******************************************************/
204 class VStringConfigControl : public ConfigControl
207 VStringConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
208 ConfigControl(a,b,c) {};
209 VStringConfigControl( vlc_object_t *a, module_config_t *b ) :
210 ConfigControl(a,b) {};
211 virtual ~VStringConfigControl() {};
212 virtual QString getValue() = 0;
213 virtual int getType() { return 3; }
216 class StringConfigControl : public VStringConfigControl
219 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *,
220 QGridLayout *, int, bool pwd );
221 StringConfigControl( vlc_object_t *, module_config_t *, QLabel *,
222 QLineEdit*, bool pwd );
223 virtual ~StringConfigControl() {};
224 virtual QString getValue() { return text->text(); };
225 virtual void show() { text->show(); label->show(); }
226 virtual void hide() { text->hide(); label->hide(); }
233 class ModuleConfigControl : public VStringConfigControl
236 ModuleConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool,
238 ModuleConfigControl( vlc_object_t *, module_config_t *, QLabel *,
240 virtual ~ModuleConfigControl() {};
241 virtual QString getValue();
242 virtual void hide() { combo->hide(); label->hide(); }
243 virtual void show() { combo->show(); label->show(); }
250 class StringListConfigControl : public VStringConfigControl
253 StringListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
254 bool, QGridLayout*, int );
255 StringListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
257 virtual ~StringListConfigControl() {};
258 virtual QString getValue();
259 virtual void hide() { combo->hide(); label->hide(); }
260 virtual void show() { combo->show(); label->show(); }
267 struct ModuleCheckBox {
272 class ModuleListConfigControl : public ConfigControl
275 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool
277 virtual ~StringConfigControl();
278 virtual QString getValue();
280 std::vector<ModuleCheckBox> checkboxes;