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_
33 #include "ui/input_stats.h"
37 class ConfigControl : public QObject
41 ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf,
42 QWidget *p ) : p_this( _p_this ), p_item( _p_conf )
44 widget = new QWidget( p );
46 ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf ) :
47 p_this (_p_this ), p_item( _p_conf )
51 virtual ~ConfigControl() {};
52 QString getName() { return qfu( p_item->psz_name ); }
53 QWidget *getWidget() { assert( widget ); return widget; }
54 bool isAdvanced() { return p_item->b_advanced; }
55 virtual void hide() { getWidget()->hide(); };
56 virtual void show() { getWidget()->show(); };
58 static ConfigControl * createControl( vlc_object_t*,
59 module_config_t*,QWidget* );
60 static ConfigControl * createControl( vlc_object_t*,
61 module_config_t*,QWidget*,
65 module_config_t *p_item;
73 /*******************************************************
74 * Integer-based controls
75 *******************************************************/
76 class VIntConfigControl : public ConfigControl
79 VIntConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
80 ConfigControl(a,b,c) {};
81 VIntConfigControl( vlc_object_t *a, module_config_t *b ) :
82 ConfigControl(a,b) {};
83 virtual ~VIntConfigControl() {};
84 virtual int getValue() = 0;
87 class IntegerConfigControl : public VIntConfigControl
90 IntegerConfigControl( vlc_object_t *, module_config_t *, QWidget *,
92 IntegerConfigControl( vlc_object_t *, module_config_t *,
94 virtual ~IntegerConfigControl() {};
95 virtual int getValue();
96 virtual void show() { spin->show(); label->show(); }
97 virtual void hide() { spin->hide(); label->hide(); }
104 class IntegerListConfigControl : public VIntConfigControl
107 IntegerListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
108 bool, QGridLayout*, int );
109 IntegerListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
111 virtual ~IntegerListConfigControl() {};
112 virtual int getValue();
113 virtual void hide() { combo->hide(); label->hide(); }
114 virtual void show() { combo->show(); label->show(); }
121 class BoolConfigControl : public VIntConfigControl
124 BoolConfigControl( vlc_object_t *, module_config_t *, QWidget *,
125 QGridLayout *, int );
126 BoolConfigControl( vlc_object_t *, module_config_t *,
127 QLabel *, QCheckBox*, bool );
128 virtual ~BoolConfigControl() {};
129 virtual int getValue();
130 virtual void show() { checkbox->show(); }
131 virtual void hide() { checkbox->hide(); }
137 /*******************************************************
138 * Float-based controls
139 *******************************************************/
140 class VFloatConfigControl : public ConfigControl
143 VFloatConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
144 ConfigControl(a,b,c) {};
145 VFloatConfigControl( vlc_object_t *a, module_config_t *b ) :
146 ConfigControl(a,b) {};
147 virtual ~VFloatConfigControl() {};
148 virtual float getValue() = 0;
152 class FloatConfigControl : public VFloatConfigControl
155 FloatConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
156 ConfigControl(a,b,c) {};
157 virtual ~FloatConfigControl() {};
158 virtual float getValue();
160 QDoubleSpinBox *spin;
164 /*******************************************************
165 * String-based controls
166 *******************************************************/
167 class VStringConfigControl : public ConfigControl
170 VStringConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
171 ConfigControl(a,b,c) {};
172 VStringConfigControl( vlc_object_t *a, module_config_t *b ) :
173 ConfigControl(a,b) {};
174 virtual ~VStringConfigControl() {};
175 virtual QString getValue() = 0;
178 class StringConfigControl : public VStringConfigControl
181 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *,
182 QGridLayout *, int, bool pwd );
183 StringConfigControl( vlc_object_t *, module_config_t *, QLabel *,
184 QLineEdit*, bool pwd );
185 virtual ~StringConfigControl() {};
186 virtual QString getValue() { return text->text(); };
187 virtual void show() { text->show(); label->show(); }
188 virtual void hide() { text->hide(); label->hide(); }
195 class ModuleConfigControl : public VStringConfigControl
198 ModuleConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool,
200 ModuleConfigControl( vlc_object_t *, module_config_t *, QLabel *,
202 virtual ~ModuleConfigControl() {};
203 virtual QString getValue();
204 virtual void hide() { combo->hide(); label->hide(); }
205 virtual void show() { combo->show(); label->show(); }
212 class StringListConfigControl : public VStringConfigControl
215 StringListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
216 bool, QGridLayout*, int );
217 StringListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
219 virtual ~StringListConfigControl() {};
220 virtual QString getValue();
221 virtual void hide() { combo->hide(); label->hide(); }
222 virtual void show() { combo->show(); label->show(); }
229 struct ModuleCheckBox {
234 class ModuleListConfigControl : public ConfigControl
237 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool
239 virtual ~StringConfigControl();
240 virtual QString getValue();
242 std::vector<ModuleCheckBox> checkboxes;