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>
38 #include "ui/input_stats.h"
42 class ConfigControl : public QObject
46 ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf,
47 QWidget *p ) : p_this( _p_this ), p_item( _p_conf )
49 widget = new QWidget( p );
51 ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf ) :
52 p_this (_p_this ), p_item( _p_conf )
56 virtual ~ConfigControl() {};
57 virtual int getType() = 0;
58 const char * getName() { return p_item->psz_name; }
59 QWidget *getWidget() { assert( widget ); return widget; }
60 bool isAdvanced() { return p_item->b_advanced; }
61 virtual void hide() { getWidget()->hide(); };
62 virtual void show() { getWidget()->show(); };
64 static ConfigControl * createControl( vlc_object_t*,
65 module_config_t*,QWidget* );
66 static ConfigControl * createControl( vlc_object_t*,
67 module_config_t*,QWidget*,
68 QGridLayout *, int& );
69 void doApply( intf_thread_t *);
72 module_config_t *p_item;
80 /*******************************************************
81 * Integer-based controls
82 *******************************************************/
83 class VIntConfigControl : public ConfigControl
86 VIntConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
87 ConfigControl(a,b,c) {};
88 VIntConfigControl( vlc_object_t *a, module_config_t *b ) :
89 ConfigControl(a,b) {};
90 virtual ~VIntConfigControl() {};
91 virtual int getValue() = 0;
92 virtual int getType() { return 1; }
95 class IntegerConfigControl : public VIntConfigControl
98 IntegerConfigControl( vlc_object_t *, module_config_t *, QWidget *,
99 QGridLayout *, int& );
100 IntegerConfigControl( vlc_object_t *, module_config_t *,
101 QLabel*, QSpinBox* );
102 virtual ~IntegerConfigControl() {};
103 virtual int getValue();
104 virtual void show() { spin->show(); label->show(); }
105 virtual void hide() { spin->hide(); label->hide(); }
115 class IntegerRangeConfigControl : public IntegerConfigControl
118 IntegerRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
119 QGridLayout *, int& );
120 IntegerRangeConfigControl( vlc_object_t *, module_config_t *,
121 QLabel*, QSpinBox* );
126 class IntegerListConfigControl : public VIntConfigControl
129 IntegerListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
130 bool, QGridLayout*, int& );
131 IntegerListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
133 virtual ~IntegerListConfigControl() {};
134 virtual int getValue();
135 virtual void hide() { combo->hide(); label->hide(); }
136 virtual void show() { combo->show(); label->show(); }
143 class BoolConfigControl : public VIntConfigControl
146 BoolConfigControl( vlc_object_t *, module_config_t *, QWidget *,
147 QGridLayout *, int& );
148 BoolConfigControl( vlc_object_t *, module_config_t *,
149 QLabel *, QCheckBox*, bool );
150 virtual ~BoolConfigControl() {};
151 virtual int getValue();
152 virtual void show() { checkbox->show(); }
153 virtual void hide() { checkbox->hide(); }
159 /*******************************************************
160 * Float-based controls
161 *******************************************************/
162 class VFloatConfigControl : public ConfigControl
165 VFloatConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
166 ConfigControl(a,b,c) {};
167 VFloatConfigControl( vlc_object_t *a, module_config_t *b ) :
168 ConfigControl(a,b) {};
169 virtual ~VFloatConfigControl() {};
170 virtual float getValue() = 0;
171 virtual int getType() { return 2; }
174 class FloatConfigControl : public VFloatConfigControl
177 FloatConfigControl( vlc_object_t *, module_config_t *, QWidget *,
178 QGridLayout *, int& );
179 FloatConfigControl( vlc_object_t *, module_config_t *,
180 QLabel*, QDoubleSpinBox* );
181 virtual ~FloatConfigControl() {};
182 virtual float getValue();
183 virtual void show() { spin->show(); label->show(); }
184 virtual void hide() { spin->hide(); label->hide(); }
187 QDoubleSpinBox *spin;
194 class FloatRangeConfigControl : public FloatConfigControl
197 FloatRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
198 QGridLayout *, int& );
199 FloatRangeConfigControl( vlc_object_t *, module_config_t *,
200 QLabel*, QDoubleSpinBox* );
205 /*******************************************************
206 * String-based controls
207 *******************************************************/
208 class VStringConfigControl : public ConfigControl
211 VStringConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
212 ConfigControl(a,b,c) {};
213 VStringConfigControl( vlc_object_t *a, module_config_t *b ) :
214 ConfigControl(a,b) {};
215 virtual ~VStringConfigControl() {};
216 virtual QString getValue() = 0;
217 virtual int getType() { return 3; }
220 class StringConfigControl : public VStringConfigControl
223 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *,
224 QGridLayout *, int&, bool pwd );
225 StringConfigControl( vlc_object_t *, module_config_t *, QLabel *,
226 QLineEdit*, bool pwd );
227 virtual ~StringConfigControl() {};
228 virtual QString getValue() { return text->text(); };
229 virtual void show() { text->show(); label->show(); }
230 virtual void hide() { text->hide(); label->hide(); }
237 class ModuleConfigControl : public VStringConfigControl
240 ModuleConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool,
241 QGridLayout*, int& );
242 ModuleConfigControl( vlc_object_t *, module_config_t *, QLabel *,
244 virtual ~ModuleConfigControl() {};
245 virtual QString getValue();
246 virtual void hide() { combo->hide(); label->hide(); }
247 virtual void show() { combo->show(); label->show(); }
254 class ModuleListConfigControl : public VStringConfigControl
258 ModuleListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
259 bool, QGridLayout*, int& );
260 // ModuleListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
261 // QComboBox*, bool );
262 virtual ~ModuleListConfigControl();
263 virtual QString getValue();
267 void wakeUp_TheUserJustClickedOnSomething( int value );
270 QVector<QCheckBox*> modules;
275 class StringListConfigControl : public VStringConfigControl
278 StringListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
279 bool, QGridLayout*, int& );
280 StringListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
282 virtual ~StringListConfigControl() {};
283 virtual QString getValue();
284 virtual void hide() { combo->hide(); label->hide(); }
285 virtual void show() { combo->show(); label->show(); }
292 struct ModuleCheckBox {
297 class ModuleListConfigControl : public ConfigControl
300 StringConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool
302 virtual ~StringConfigControl();
303 virtual QString getValue();
305 std::vector<ModuleCheckBox> checkboxes;
312 /**********************************************************************
313 * Key selector widget
314 **********************************************************************/
315 class KeyInputDialog : public QDialog
318 KeyInputDialog( QList<module_config_t *> &, const char * );
322 void keyPressEvent( QKeyEvent *);
325 const char * keyToChange;
326 QList<module_config_t*> values;
329 class KeySelectorControl : public ConfigControl
333 KeySelectorControl( vlc_object_t *, module_config_t *, QWidget *,
334 QGridLayout*, int& );
335 virtual int getType() { return 4; }
336 virtual ~KeySelectorControl() {};
337 virtual void hide() { table->hide(); label->hide(); }
338 virtual void show() { table->show(); label->show(); }
344 QList<module_config_t *> values;
346 void selectKey( QTreeWidgetItem *);