]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/open_panels.hpp
[Qt] Implement a kind of rememberance in Open Network Dialog.
[vlc] / modules / gui / qt4 / components / open_panels.hpp
1 /*****************************************************************************
2  * open.hpp : Panels for the open dialogs
3  ****************************************************************************
4  * Copyright (C) 2006-2007 the VideoLAN team
5  * Copyright (C) 2007 Société des arts technologiques
6  * Copyright (C) 2007 Savoir-faire Linux
7  * $Id$
8  *
9  * Authors: Clément Stenac <zorglub@videolan.org>
10  *          Jean-Baptiste Kempf <jb@videolan.org>
11  *          Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com>
12  *
13  * This program is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 2 of the License, or
16  * (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software
25  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
26  *****************************************************************************/
27
28 #ifndef _OPENPANELS_H_
29 #define _OPENPANELS_H_
30
31 #ifdef HAVE_CONFIG_H
32 # include "config.h"
33 #endif
34
35 #include <vlc_common.h>
36
37 #include <QFileDialog>
38
39 #include "ui/open_file.h"
40 #include "ui/open_disk.h"
41 #include "ui/open_net.h"
42 #include "ui/open_capture.h"
43
44 #include "components/preferences_widgets.hpp"
45
46 #include <limits.h>
47
48 #define setSpinBoxFreq( spinbox ){ spinbox->setRange ( 0, INT_MAX ); \
49     spinbox->setAccelerated( true ); }
50
51 enum
52 {
53     NO_PROTO,
54     HTTP_PROTO,
55     HTTPS_PROTO,
56     MMS_PROTO,
57     FTP_PROTO,
58     RTSP_PROTO,
59     RTP_PROTO,
60     UDP_PROTO,
61     RTMP_PROTO
62 };
63
64
65 enum
66 {
67     V4L_DEVICE,
68     V4L2_DEVICE,
69     PVR_DEVICE,
70     DVB_DEVICE,
71     BDA_DEVICE,
72     DSHOW_DEVICE,
73     SCREEN_DEVICE,
74     JACK_DEVICE
75 };
76
77 static const char *psz_devModule[] = { "v4l", "v4l2", "pvr", "dvb", "bda",
78                                        "dshow", "screen", "jack" };
79
80
81 class QWidget;
82 class QLineEdit;
83 class QString;
84 class QStringListModel;
85
86 class OpenPanel: public QWidget
87 {
88     Q_OBJECT;
89 public:
90     OpenPanel( QWidget *p, intf_thread_t *_p_intf ) : QWidget( p )
91     {
92         p_intf = _p_intf;
93     }
94     virtual ~OpenPanel() {};
95     virtual void clear() = 0;
96 protected:
97     intf_thread_t *p_intf;
98 public slots:
99     virtual void updateMRL() = 0;
100 signals:
101     void mrlUpdated( QString );
102     void methodChanged( QString method );
103 };
104
105 class FileOpenBox: public QFileDialog
106 {
107     Q_OBJECT;
108 public:
109     FileOpenBox( QWidget *parent, const QString &caption,
110         const QString &directory, const QString &filter ):
111         QFileDialog( parent, caption, directory, filter ) {}
112 public slots:
113     void accept();
114     void reject();
115 };
116
117 class FileOpenPanel: public OpenPanel
118 {
119     Q_OBJECT;
120 public:
121     FileOpenPanel( QWidget *, intf_thread_t * );
122     virtual ~FileOpenPanel();
123     virtual void clear() ;
124     virtual void accept() ;
125 private:
126     Ui::OpenFile ui;
127     QStringList browse( QString );
128     FileOpenBox *dialogBox;
129     QLineEdit *lineFileEdit;
130     QStringList fileCompleteList ;
131 public slots:
132     virtual void updateMRL();
133 private slots:
134     void browseFileSub();
135     void toggleSubtitleFrame();
136 };
137
138 class NetOpenPanel: public OpenPanel
139 {
140     Q_OBJECT;
141 public:
142     NetOpenPanel( QWidget *, intf_thread_t * );
143     virtual ~NetOpenPanel();
144     virtual void clear() ;
145 private:
146     Ui::OpenNetwork ui;
147     QStringListModel *mrlList;
148 public slots:
149     virtual void updateMRL();
150 private slots:
151     void updateProtocol( int );
152     void updateCompleter();
153 };
154
155 class DiscOpenPanel: public OpenPanel
156 {
157     Q_OBJECT;
158 public:
159     DiscOpenPanel( QWidget *, intf_thread_t * );
160     virtual ~DiscOpenPanel();
161     virtual void clear() ;
162     virtual void accept() ;
163 private:
164     Ui::OpenDisk ui;
165     char *psz_dvddiscpath, *psz_vcddiscpath, *psz_cddadiscpath;
166     bool b_firstdvd, b_firstvcd, b_firstcdda;
167 public slots:
168     virtual void updateMRL() ;
169 private slots:
170     void browseDevice();
171     void updateButtons() ;
172     void eject();
173 };
174
175
176 class CaptureOpenPanel: public OpenPanel
177 {
178     Q_OBJECT;
179 public:
180     CaptureOpenPanel( QWidget *, intf_thread_t * );
181     virtual ~CaptureOpenPanel();
182     virtual void clear() ;
183 private:
184     Ui::OpenCapture ui;
185     bool isInitialized;
186
187     QString advMRL;
188     QDialog *adv;
189 #ifdef WIN32
190     QRadioButton *bdas, *bdat, *bdac;
191     QSpinBox *bdaCard, *bdaFreq, *bdaSrate;
192     QLabel *bdaSrateLabel, *bdaBandLabel;
193     QComboBox *bdaBandBox;
194     StringListConfigControl *vdevDshowW, *adevDshowW;
195     QLineEdit *dshowVSizeLine;
196 #else
197     QRadioButton *dvbs, *dvbt, *dvbc;
198     QSpinBox  *v4lFreq, *pvrFreq, *pvrBitr;
199     QLineEdit *v4lVideoDevice, *v4lAudioDevice;
200     QLineEdit *v4l2VideoDevice, *v4l2AudioDevice;
201     QLineEdit *pvrDevice, *pvrRadioDevice;
202     QComboBox *v4lNormBox, *v4l2StdBox, *pvrNormBox;
203     QSpinBox *dvbCard, *dvbFreq, *dvbSrate;
204     QSpinBox *jackChannels, *jackCaching;
205     QCheckBox *jackPace, *jackConnect;
206     QLineEdit *jackPortsSelected;
207 #endif
208     QSpinBox *screenFPS;
209
210 public slots:
211     virtual void updateMRL();
212     void initialize();
213 private slots:
214     void updateButtons();
215     void advancedDialog();
216 };
217
218 #endif