]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/preferences_widgets.hpp
Some more prefs fun:
[vlc] / modules / gui / qt4 / components / preferences_widgets.hpp
1 /*****************************************************************************
2  * preferences_widgets.hpp : Widgets for preferences panels
3  ****************************************************************************
4  * Copyright (C) 2006 the VideoLAN team
5  * $Id$
6  *
7  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
8  *          Antoine Cellerier <dionoea@videolan.org>
9  *
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.
14  *
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.
19  *
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  *****************************************************************************/
24
25 #ifndef _INFOPANELS_H_
26 #define _INFOPANELS_H_
27 #include <vlc/vlc.h>
28 #include <QWidget>
29 #include <QLineEdit>
30 #include <QSpinBox>
31 #include <QComboBox>
32 #include "ui/input_stats.h"
33 #include "qt4.hpp"
34 #include <assert.h>
35
36 class QSpinBox;
37 class QString;
38 class QComboBox;
39 class QCheckBox;
40
41 class ConfigControl : public QObject
42 {
43     Q_OBJECT;
44 public:
45     ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf,
46                    QWidget *p ) : p_this( _p_this ), p_item( _p_conf )
47     {
48         widget = new QWidget( p );
49     }
50     ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf ) :
51                             p_this (_p_this ), p_item( _p_conf )
52     {
53         widget = NULL;
54     }
55     virtual ~ConfigControl() {};
56     QString getName() { return qfu( 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(); };
61
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 protected:
68     vlc_object_t *p_this;
69     module_config_t *p_item;
70     QString _name;
71     QWidget *widget;
72     bool _advanced;
73 signals:
74     void Updated();
75 };
76
77 /*******************************************************
78  * Integer-based controls
79  *******************************************************/
80 class VIntConfigControl : public ConfigControl
81 {
82 public:
83     VIntConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
84             ConfigControl(a,b,c) {};
85     VIntConfigControl( vlc_object_t *a, module_config_t *b ) :
86                 ConfigControl(a,b) {};
87     virtual ~VIntConfigControl() {};
88     virtual int getValue() = 0;
89 };
90
91 class IntegerConfigControl : public VIntConfigControl
92 {
93 public:
94     IntegerConfigControl( vlc_object_t *, module_config_t *, QWidget *,
95                           QGridLayout *, int );
96     IntegerConfigControl( vlc_object_t *, module_config_t *,
97                           QLabel*, QSpinBox* );
98     virtual ~IntegerConfigControl() {};
99     virtual int getValue();
100     virtual void show() { spin->show(); label->show(); }
101     virtual void hide() { spin->hide(); label->hide(); }
102 private:
103     QSpinBox *spin;
104     QLabel *label;
105     void finish();
106 };
107
108 class IntegerListConfigControl : public VIntConfigControl
109 {
110 public:
111     IntegerListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
112                               bool, QGridLayout*, int );
113     IntegerListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
114                               QComboBox*, bool );
115     virtual ~IntegerListConfigControl() {};
116     virtual int getValue();
117     virtual void hide() { combo->hide(); label->hide(); }
118     virtual void show() { combo->show(); label->show(); }
119 private:
120     void finish( bool );
121     QLabel *label;
122     QComboBox *combo;
123 };
124
125 #if 0
126 class BoolConfigControl : public VIntConfigControl
127 {
128 public:
129     IntConfigControl( vlc_object_t *, module_config_t *, QWidget * );
130     virtual ~IntConfigControl();
131     virtual int getValue();
132 private:
133     wxCheckBox *checkbox;
134 };
135 #endif
136
137 /*******************************************************
138  * Float-based controls
139  *******************************************************/
140 class VFloatConfigControl : public ConfigControl
141 {
142 public:
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;
149 };
150
151 #if 0
152 class FloatConfigControl : public VFloatConfigControl
153 {
154 public:
155     FloatConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
156                 ConfigControl(a,b,c) {};
157     virtual ~FloatConfigControl() {};
158     virtual float getValue();
159 private:
160     QDoubleSpinBox *spin;
161 };
162 #endif
163
164 /*******************************************************
165  * String-based controls
166  *******************************************************/
167 class VStringConfigControl : public ConfigControl
168 {
169 public:
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;
176 };
177
178 class StringConfigControl : public VStringConfigControl
179 {
180 public:
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(); }
189 private:
190     void finish();
191     QLineEdit *text;
192     QLabel *label;
193 };
194
195 class ModuleConfigControl : public VStringConfigControl
196 {
197 public:
198     ModuleConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool,
199                          QGridLayout*, int );
200     ModuleConfigControl( vlc_object_t *, module_config_t *, QLabel *,
201                          QComboBox*, bool );
202     virtual ~ModuleConfigControl() {};
203     virtual QString getValue();
204     virtual void hide() { combo->hide(); label->hide(); }
205     virtual void show() { combo->show(); label->show(); }
206 private:
207     void finish( bool );
208     QLabel *label;
209     QComboBox *combo;
210 };
211
212 class StringListConfigControl : public VStringConfigControl
213 {
214 public:
215     StringListConfigControl( vlc_object_t *, module_config_t *, QWidget *,
216                              bool, QGridLayout*, int );
217     StringListConfigControl( vlc_object_t *, module_config_t *, QLabel *,
218                              QComboBox*, bool );
219     virtual ~StringListConfigControl() {};
220     virtual QString getValue();
221     virtual void hide() { combo->hide(); label->hide(); }
222     virtual void show() { combo->show(); label->show(); }
223 private:
224     void finish( bool );
225     QLabel *label;
226     QComboBox *combo;
227 };
228 #if 0
229 struct ModuleCheckBox {
230     QCheckBox *checkbox;
231     QString module;
232 };
233
234 class ModuleListConfigControl : public ConfigControl
235 {
236 public:
237     StringConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool
238                          bycat );
239     virtual ~StringConfigControl();
240     virtual QString getValue();
241 private:
242     std::vector<ModuleCheckBox> checkboxes;
243     QLineEdit *text;
244 private slot:
245     void OnUpdate();
246 };
247 #endif
248
249 #endif