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_
29 #include <QTreeWidget>
32 #include <QDoubleSpinBox>
36 #include "ui/input_stats.h"
40 class ConfigControl : public QObject
44 ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf,
45 QWidget *p ) : p_this( _p_this ), p_item( _p_conf )
47 widget = new QWidget( p );
49 ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf ) :
50 p_this (_p_this ), p_item( _p_conf )
54 virtual ~ConfigControl() {};
55 virtual int getType() = 0;
56 char * getName() { return p_item->psz_name; }
57 QWidget *getWidget() { assert( widget ); return widget; }
58 bool isAdvanced() { return p_item->b_advanced; }
59 virtual void hide() { getWidget()->hide(); };
60 virtual void show() { getWidget()->show(); };
62 static ConfigControl * createControl( vlc_object_t*,
63 module_config_t*,QWidget* );
64 static ConfigControl * createControl( vlc_object_t*,
65 module_config_t*,QWidget*,
66 QGridLayout *, int& );
67 void doApply( intf_thread_t *);
70 module_config_t *p_item;
78 /*******************************************************
79 * Integer-based controls
80 *******************************************************/
81 class VIntConfigControl : public ConfigControl
84 VIntConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
85 ConfigControl(a,b,c) {};
86 VIntConfigControl( vlc_object_t *a, module_config_t *b ) :
87 ConfigControl(a,b) {};
88 virtual ~VIntConfigControl() {};
89 virtual int getValue() = 0;
90 virtual int getType() { return 1; }
93 class IntegerConfigControl : public VIntConfigControl
96 IntegerConfigControl( vlc_object_t *, module_config_t *, QWidget *,
97 QGridLayout *, int& );
98 IntegerConfigControl( vlc_object_t *, module_config_t *,
100 virtual ~IntegerConfigControl() {};
101 virtual int getValue();
102 virtual void show() { spin->show(); label->show(); }
103 virtual void hide() { spin->hide(); label->hide(); }
113 class IntegerRangeConfigControl : public IntegerConfigControl
116 IntegerRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
117 QGridLayout *, int& );
118 IntegerRangeConfigControl( vlc_object_t *, module_config_t *,
119 QLabel*, QSpinBox* );
124 class IntegerListConfigControl : public VIntConfigControl
127 IntegerListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
128 bool, QGridLayout*, int& );
129 IntegerListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
131 virtual ~IntegerListConfigControl() {};
132 virtual int getValue();
133 virtual void hide() { combo->hide(); label->hide(); }
134 virtual void show() { combo->show(); label->show(); }
141 class BoolConfigControl : public VIntConfigControl
144 BoolConfigControl( vlc_object_t *, module_config_t *, QWidget *,
145 QGridLayout *, int& );
146 BoolConfigControl( vlc_object_t *, module_config_t *,
147 QLabel *, QCheckBox*, bool );
148 virtual ~BoolConfigControl() {};
149 virtual int getValue();
150 virtual void show() { checkbox->show(); }
151 virtual void hide() { checkbox->hide(); }
157 /*******************************************************
158 * Float-based controls
159 *******************************************************/
160 class VFloatConfigControl : public ConfigControl
163 VFloatConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
164 ConfigControl(a,b,c) {};
165 VFloatConfigControl( vlc_object_t *a, module_config_t *b ) :
166 ConfigControl(a,b) {};
167 virtual ~VFloatConfigControl() {};
168 virtual float getValue() = 0;
169 virtual int getType() { return 2; }
172 class FloatConfigControl : public VFloatConfigControl
175 FloatConfigControl( vlc_object_t *, module_config_t *, QWidget *,
176 QGridLayout *, int& );
177 FloatConfigControl( vlc_object_t *, module_config_t *,
178 QLabel*, QDoubleSpinBox* );
179 virtual ~FloatConfigControl() {};
180 virtual float getValue();
181 virtual void show() { spin->show(); label->show(); }
182 virtual void hide() { spin->hide(); label->hide(); }
185 QDoubleSpinBox *spin;
192 class FloatRangeConfigControl : public FloatConfigControl
195 FloatRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
196 QGridLayout *, int& );
197 FloatRangeConfigControl( vlc_object_t *, module_config_t *,
198 QLabel*, QDoubleSpinBox* );
203 /*******************************************************
204 * String-based controls
205 *******************************************************/
206 class VStringConfigControl : public ConfigControl
209 VStringConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
210 ConfigControl(a,b,c) {};
211 VStringConfigControl( vlc_object_t *a, module_config_t *b ) :
212 ConfigControl(a,b) {};
213 virtual ~VStringConfigControl() {};
214 virtual QString getValue() = 0;
215 virtual int getType() { return 3; }
218 class StringConfigControl : public VStringConfigControl
221 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *,
222 QGridLayout *, int&, bool pwd );
223 StringConfigControl( vlc_object_t *, module_config_t *, QLabel *,
224 QLineEdit*, bool pwd );
225 virtual ~StringConfigControl() {};
226 virtual QString getValue() { return text->text(); };
227 virtual void show() { text->show(); label->show(); }
228 virtual void hide() { text->hide(); label->hide(); }
235 class ModuleConfigControl : public VStringConfigControl
238 ModuleConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool,
239 QGridLayout*, int& );
240 ModuleConfigControl( vlc_object_t *, module_config_t *, QLabel *,
242 virtual ~ModuleConfigControl() {};
243 virtual QString getValue();
244 virtual void hide() { combo->hide(); label->hide(); }
245 virtual void show() { combo->show(); label->show(); }
252 class ModuleListConfigControl : public VStringConfigControl
256 ModuleListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
257 bool, QGridLayout*, int& );
258 // ModuleListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
259 // QComboBox*, bool );
260 virtual ~ModuleListConfigControl();
261 virtual QString getValue();
265 void wakeUp_TheUserJustClickedOnSomething( int value );
268 QVector<QCheckBox*> modules;
273 class StringListConfigControl : public VStringConfigControl
276 StringListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
277 bool, QGridLayout*, int& );
278 StringListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
280 virtual ~StringListConfigControl() {};
281 virtual QString getValue();
282 virtual void hide() { combo->hide(); label->hide(); }
283 virtual void show() { combo->show(); label->show(); }
290 struct ModuleCheckBox {
295 class ModuleListConfigControl : public ConfigControl
298 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool
300 virtual ~StringConfigControl();
301 virtual QString getValue();
303 std::vector<ModuleCheckBox> checkboxes;
310 /**********************************************************************
311 * Key selector widget
312 **********************************************************************/
313 class KeySelectorControl : public ConfigControl
317 KeySelectorControl( vlc_object_t *, module_config_t *, QWidget *,
318 QGridLayout*, int& );
319 virtual int getType() { return 4; }
320 virtual ~KeySelectorControl() {};
321 virtual void hide() { table->hide(); label->hide(); }
322 virtual void show() { table->show(); label->show(); }