]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/preferences_widgets.hpp
Skeleton for simple prefs
[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 "ui/input_stats.h"
30 #include "qt4.hpp"
31 #include <assert.h>
32
33 class QSpinBox;
34 class QString;
35 class QComboBox;
36 class QCheckBox;
37
38 class ConfigControl : public QObject
39 {
40     Q_OBJECT;
41 public:
42     ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf,
43                    QWidget *p ) : p_this( _p_this ), p_item( _p_conf )
44     {
45         widget = new QWidget( p );
46     }
47     ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf ) :
48                             p_this (_p_this ), p_item( _p_conf )
49     {
50         widget = NULL;
51     }
52     virtual ~ConfigControl() {};
53     QString getName() { return qfu( p_item->psz_name ); }
54     QWidget *getWidget() { assert( widget ); return widget; }
55     bool isAdvanced() { return p_item->b_advanced; }
56
57     static ConfigControl * createControl( vlc_object_t*,
58                                           module_config_t*,QWidget* );
59 protected:
60     vlc_object_t *p_this;
61     module_config_t *p_item;
62     QString _name;
63     QWidget *widget;
64     bool _advanced;
65 signals:
66     void Updated();
67 };
68
69 /*******************************************************
70  * Integer-based controls
71  *******************************************************/
72 class VIntConfigControl : public ConfigControl
73 {
74 public:
75     VIntConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
76             ConfigControl(a,b,c) {};
77     virtual ~VIntConfigControl() {};
78     virtual int getValue() = 0;
79 };
80
81 #if 0
82 class IntegerConfigControl : public VIntConfigControl
83 {
84 public:
85     IntegerConfigControl( vlc_object_t *, module_config_t *, QWidget * );
86     virtual ~IntegerConfigControl();
87     virtual int getValue();
88 private:
89     QSpinBox *spin;
90 };
91
92 class BoolConfigControl : public VIntConfigControl
93 {
94 public:
95     IntConfigControl( vlc_object_t *, module_config_t *, QWidget * );
96     virtual ~IntConfigControl();
97     virtual int getValue();
98 private:
99     wxCheckBox *checkbox;
100 };
101 #endif
102
103 /*******************************************************
104  * Float-based controls
105  *******************************************************/
106 class VFloatConfigControl : public ConfigControl
107 {
108 public:
109     VFloatConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
110                 ConfigControl(a,b,c) {};
111     virtual ~VFloatConfigControl() {};
112     virtual float getValue() = 0;
113 };
114
115 #if 0
116 class FloatConfigControl : public VFloatConfigControl
117 {
118 public:
119     FloatConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
120                 ConfigControl(a,b,c) {};
121     virtual ~FloatConfigControl() {};
122     virtual float getValue();
123 private:
124     QDoubleSpinBox *spin;
125 };
126 #endif
127
128 /*******************************************************
129  * String-based controls
130  *******************************************************/
131 class VStringConfigControl : public ConfigControl
132 {
133 public:
134     VStringConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
135                 ConfigControl(a,b,c) {};
136     VStringConfigControl( vlc_object_t *a, module_config_t *b ) :
137                 ConfigControl(a,b) {};
138     virtual ~VStringConfigControl() {};
139     virtual QString getValue() = 0;
140 };
141
142 class StringConfigControl : public VStringConfigControl
143 {
144 public:
145     StringConfigControl( vlc_object_t *, module_config_t *, QWidget *,
146                          bool pwd );
147     StringConfigControl( vlc_object_t *, module_config_t *, QLabel *,
148                          QLineEdit*,  bool pwd );
149     virtual ~StringConfigControl() {};
150     virtual QString getValue() { return text->text(); };
151 private:
152     void finish( QLabel * );
153     QLineEdit *text;
154 };
155
156 class ModuleConfigControl : public VStringConfigControl
157 {
158 public:
159     ModuleConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool
160                          bycat );
161     ModuleConfigControl( vlc_object_t *, module_config_t *, QLabel *,
162                          QComboBox*, bool );
163     virtual ~ModuleConfigControl();
164     virtual QString getValue();
165 private:
166     void finish( QLabel *, bool );
167     QComboBox *combo;
168 };
169 #if 0
170 struct ModuleCheckBox {
171     QCheckBox *checkbox;
172     QString module;
173 };
174
175 class ModuleListConfigControl : public ConfigControl
176 {
177 public:
178     StringConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool
179                          bycat );
180     virtual ~StringConfigControl();
181     virtual QString getValue();
182 private:
183     std::vector<ModuleCheckBox> checkboxes;
184     QLineEdit *text;
185 private slot:
186     void OnUpdate();
187 };
188 #endif
189
190 #endif