]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/preferences_widgets.hpp
Improved layout for preferences
[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  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 #ifndef _INFOPANELS_H_
25 #define _INFOPANELS_H_
26 #include <vlc/vlc.h>
27 #include <QWidget>
28 #include <QLineEdit>
29 #include <QSpinBox>
30 #include <QComboBox>
31 #include "ui/input_stats.h"
32 #include "qt4.hpp"
33 #include <assert.h>
34
35 class QSpinBox;
36 class QString;
37 class QComboBox;
38 class QCheckBox;
39
40 class ConfigControl : public QObject
41 {
42     Q_OBJECT;
43 public:
44     ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf,
45                    QWidget *p ) : p_this( _p_this ), p_item( _p_conf )
46     {
47         widget = new QWidget( p );
48     }
49     ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf ) :
50                             p_this (_p_this ), p_item( _p_conf )
51     {
52         widget = NULL;
53     }
54     virtual ~ConfigControl() {};
55     QString getName() { return qfu( p_item->psz_name ); }
56     QWidget *getWidget() { assert( widget ); return widget; }
57     bool isAdvanced() { return p_item->b_advanced; }
58     virtual void hide() { getWidget()->hide(); };
59     virtual void show() { getWidget()->show(); };
60
61     static ConfigControl * createControl( vlc_object_t*,
62                                           module_config_t*,QWidget* );
63     static ConfigControl * createControl( vlc_object_t*,
64                                           module_config_t*,QWidget*,
65                                           QGridLayout *, int);
66 protected:
67     vlc_object_t *p_this;
68     module_config_t *p_item;
69     QString _name;
70     QWidget *widget;
71     bool _advanced;
72 signals:
73     void Updated();
74 };
75
76 /*******************************************************
77  * Integer-based controls
78  *******************************************************/
79 class VIntConfigControl : public ConfigControl
80 {
81 public:
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 };
89
90 class IntegerConfigControl : public VIntConfigControl
91 {
92 public:
93     IntegerConfigControl( vlc_object_t *, module_config_t *, QWidget *,
94                           QGridLayout *, int );
95     IntegerConfigControl( vlc_object_t *, module_config_t *,
96                           QLabel*, QSpinBox* );
97     virtual ~IntegerConfigControl() {};
98     virtual int getValue();
99     virtual void show() { spin->show(); label->show(); }
100     virtual void hide() { spin->hide(); label->hide(); }
101 private:
102     QSpinBox *spin;
103     QLabel *label;
104     void finish();
105 };
106
107 #if 0
108 class BoolConfigControl : public VIntConfigControl
109 {
110 public:
111     IntConfigControl( vlc_object_t *, module_config_t *, QWidget * );
112     virtual ~IntConfigControl();
113     virtual int getValue();
114 private:
115     wxCheckBox *checkbox;
116 };
117 #endif
118
119 /*******************************************************
120  * Float-based controls
121  *******************************************************/
122 class VFloatConfigControl : public ConfigControl
123 {
124 public:
125     VFloatConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
126                 ConfigControl(a,b,c) {};
127     VFloatConfigControl( vlc_object_t *a, module_config_t *b ) :
128                 ConfigControl(a,b) {};
129     virtual ~VFloatConfigControl() {};
130     virtual float getValue() = 0;
131 };
132
133 #if 0
134 class FloatConfigControl : public VFloatConfigControl
135 {
136 public:
137     FloatConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
138                 ConfigControl(a,b,c) {};
139     virtual ~FloatConfigControl() {};
140     virtual float getValue();
141 private:
142     QDoubleSpinBox *spin;
143 };
144 #endif
145
146 /*******************************************************
147  * String-based controls
148  *******************************************************/
149 class VStringConfigControl : public ConfigControl
150 {
151 public:
152     VStringConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
153                 ConfigControl(a,b,c) {};
154     VStringConfigControl( vlc_object_t *a, module_config_t *b ) :
155                 ConfigControl(a,b) {};
156     virtual ~VStringConfigControl() {};
157     virtual QString getValue() = 0;
158 };
159
160 class StringConfigControl : public VStringConfigControl
161 {
162 public:
163     StringConfigControl( vlc_object_t *, module_config_t *, QWidget *,
164                          QGridLayout *, int,  bool pwd );
165     StringConfigControl( vlc_object_t *, module_config_t *, QLabel *,
166                          QLineEdit*,  bool pwd );
167     virtual ~StringConfigControl() {};
168     virtual QString getValue() { return text->text(); };
169     virtual void show() { text->show(); label->show(); }
170     virtual void hide() { text->hide(); label->hide(); }
171 private:
172     void finish();
173     QLineEdit *text;
174     QLabel *label;
175 };
176
177 class ModuleConfigControl : public VStringConfigControl
178 {
179 public:
180     ModuleConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool,
181                          QGridLayout*, int );
182     ModuleConfigControl( vlc_object_t *, module_config_t *, QLabel *,
183                          QComboBox*, bool );
184     virtual ~ModuleConfigControl() {};
185     virtual QString getValue();
186     virtual void hide() { combo->hide(); label->hide(); }
187     virtual void show() { combo->show(); label->show(); }
188 private:
189     void finish( bool );
190     QLabel *label;
191     QComboBox *combo;
192 };
193 #if 0
194 struct ModuleCheckBox {
195     QCheckBox *checkbox;
196     QString module;
197 };
198
199 class ModuleListConfigControl : public ConfigControl
200 {
201 public:
202     StringConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool
203                          bycat );
204     virtual ~StringConfigControl();
205     virtual QString getValue();
206 private:
207     std::vector<ModuleCheckBox> checkboxes;
208     QLineEdit *text;
209 private slot:
210     void OnUpdate();
211 };
212 #endif
213
214 #endif