]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/open_panels.hpp
UI open_file menus and layout fixes
[vlc] / modules / gui / qt4 / components / open_panels.hpp
1 /*****************************************************************************
2  * open.hpp : Panels for the open dialogs
3  ****************************************************************************
4  * Copyright (C) 2006-2009 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 "components/preferences_widgets.hpp"
36
37 #include "ui/open_file.h"
38 #include "ui/open_disk.h"
39 #include "ui/open_net.h"
40 #include "ui/open_capture.h"
41
42 #include <QFileDialog>
43
44 #include <limits.h>
45
46 #define setSpinBoxFreq( spinbox ){ spinbox->setRange ( 0, INT_MAX ); \
47     spinbox->setAccelerated( true ); }
48
49 enum
50 {
51     NO_PROTO,
52     HTTP_PROTO,
53     HTTPS_PROTO,
54     MMS_PROTO,
55     FTP_PROTO,
56     RTSP_PROTO,
57     RTP_PROTO,
58     UDP_PROTO,
59     RTMP_PROTO
60 };
61
62 enum
63 {
64     V4L_DEVICE,
65     V4L2_DEVICE,
66     PVR_DEVICE,
67     DVB_DEVICE,
68     BDA_DEVICE,
69     DSHOW_DEVICE,
70     SCREEN_DEVICE,
71     JACK_DEVICE
72 };
73
74 class QWidget;
75 class QLineEdit;
76 class QString;
77 class QStringListModel;
78
79 class OpenPanel: public QWidget
80 {
81     Q_OBJECT;
82 public:
83     OpenPanel( QWidget *p, intf_thread_t *_p_intf ) : QWidget( p )
84     {
85         p_intf = _p_intf;
86     }
87     virtual ~OpenPanel() {};
88     virtual void clear() = 0;
89 protected:
90     intf_thread_t *p_intf;
91 public slots:
92     virtual void updateMRL() = 0;
93 signals:
94     void mrlUpdated( const QStringList&, const QString& );
95     void methodChanged( const QString& method );
96 };
97
98 class FileOpenBox: public QFileDialog
99 {
100     Q_OBJECT;
101 public:
102     FileOpenBox( QWidget *parent, const QString &caption,
103                  const QString &directory, const QString &filter ):
104                 QFileDialog( parent, caption, directory, filter ) {}
105 public slots:
106     void accept(){}
107     void reject(){}
108 };
109
110
111 class FileOpenPanel: public OpenPanel
112 {
113     Q_OBJECT;
114 public:
115     FileOpenPanel( QWidget *, intf_thread_t * );
116     virtual ~FileOpenPanel();
117     virtual void clear() ;
118     virtual void accept() ;
119 protected:
120     bool eventFilter(QObject *obj, QEvent *event)
121     {
122         if( event->type() == QEvent::Hide ||
123             event->type() == QEvent::HideToParent )
124         {
125             msg_Warn( p_intf, "here" );
126             event->accept();
127             return true;
128         }
129         return false;
130     }
131 private:
132     Ui::OpenFile ui;
133     FileOpenBox *dialogBox;
134     void BuildOldPanel();
135 public slots:
136     virtual void updateMRL();
137 private slots:
138     void browseFileSub();
139     void browseFile();
140     void removeFile();
141     void updateButtons();
142     void toggleSubtitleFrame( bool );
143 };
144
145 class NetOpenPanel: public OpenPanel
146 {
147     Q_OBJECT;
148 public:
149     NetOpenPanel( QWidget *, intf_thread_t * );
150     virtual ~NetOpenPanel();
151     virtual void clear() ;
152 private:
153     Ui::OpenNetwork ui;
154     QStringListModel *mrlList;
155 public slots:
156     virtual void updateMRL();
157 private slots:
158     void updateProtocol( int );
159     void updateCompleter();
160 };
161
162 class DiscOpenPanel: public OpenPanel
163 {
164     Q_OBJECT;
165 public:
166     DiscOpenPanel( QWidget *, intf_thread_t * );
167     virtual ~DiscOpenPanel();
168     virtual void clear() ;
169     virtual void accept() ;
170 private:
171     Ui::OpenDisk ui;
172     char *psz_dvddiscpath, *psz_vcddiscpath, *psz_cddadiscpath;
173     bool b_firstdvd, b_firstvcd, b_firstcdda;
174 public slots:
175     virtual void updateMRL() ;
176 private slots:
177     void browseDevice();
178     void updateButtons() ;
179     void eject();
180 };
181
182
183 class CaptureOpenPanel: public OpenPanel
184 {
185     Q_OBJECT;
186 public:
187     CaptureOpenPanel( QWidget *, intf_thread_t * );
188     virtual ~CaptureOpenPanel();
189     virtual void clear() ;
190 private:
191     Ui::OpenCapture ui;
192     bool isInitialized;
193
194     QString advMRL;
195     QDialog *adv;
196 #ifdef WIN32
197     QRadioButton *bdas, *bdat, *bdac, *bdaa;
198     QSpinBox *bdaCard, *bdaFreq, *bdaSrate;
199     QLabel *bdaSrateLabel, *bdaBandLabel;
200     QComboBox *bdaBandBox;
201     StringListConfigControl *vdevDshowW, *adevDshowW;
202     QLineEdit *dshowVSizeLine;
203 #else
204     QRadioButton *dvbs, *dvbt, *dvbc;
205     QLabel *dvbBandLabel, *dvbSrateLabel;
206     QSpinBox  *v4lFreq, *pvrFreq, *pvrBitr;
207     QLineEdit *v4lVideoDevice, *v4lAudioDevice;
208     QLineEdit *v4l2VideoDevice, *v4l2AudioDevice;
209     QLineEdit *pvrDevice, *pvrRadioDevice;
210     QComboBox *v4lNormBox, *v4l2StdBox, *pvrNormBox, *dvbBandBox;
211     QSpinBox *dvbCard, *dvbFreq, *dvbSrate;
212     QSpinBox *jackChannels, *jackCaching;
213     QCheckBox *jackPace, *jackConnect;
214     QLineEdit *jackPortsSelected;
215 #endif
216     QSpinBox *screenFPS;
217
218 public slots:
219     virtual void updateMRL();
220     void initialize();
221 private slots:
222     void updateButtons();
223     void advancedDialog();
224 };
225
226 #endif