]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/open_panels.hpp
qt4: allow dnd to file-input on convert-dialog
[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     V4L_DEVICE,
52     V4L2_DEVICE,
53     PVR_DEVICE,
54     DVB_DEVICE,
55     BDA_DEVICE,
56     DSHOW_DEVICE,
57     SCREEN_DEVICE,
58     JACK_DEVICE
59 };
60
61 class QWidget;
62 class QLineEdit;
63 class QString;
64 class QStringListModel;
65 class QEvent;
66
67 class OpenPanel: public QWidget
68 {
69     Q_OBJECT
70 public:
71     OpenPanel( QWidget *p, intf_thread_t *_p_intf ) : QWidget( p )
72     {
73         p_intf = _p_intf;
74     }
75     virtual ~OpenPanel() {};
76     virtual void clear() = 0;
77 protected:
78     intf_thread_t *p_intf;
79 public slots:
80     virtual void updateMRL() = 0;
81 signals:
82     void mrlUpdated( const QStringList&, const QString& );
83     void methodChanged( const QString& method );
84 };
85
86 class FileOpenBox: public QFileDialog
87 {
88     Q_OBJECT
89 public:
90     FileOpenBox( QWidget *parent, const QString &caption,
91                  const QString &directory, const QString &filter ):
92                 QFileDialog( parent, caption, directory, filter ) {}
93 public slots:
94     void accept(){}
95     void reject(){}
96 };
97
98
99 class FileOpenPanel: public OpenPanel
100 {
101     Q_OBJECT
102 public:
103     FileOpenPanel( QWidget *, intf_thread_t * );
104     virtual ~FileOpenPanel();
105     virtual void clear() ;
106     virtual void accept() ;
107 protected:
108     bool eventFilter(QObject *obj, QEvent *event)
109     {
110         if( event->type() == QEvent::Hide ||
111             event->type() == QEvent::HideToParent )
112         {
113             event->accept();
114             return true;
115         }
116         return false;
117     }
118     virtual void dropEvent( QDropEvent *);
119     virtual void dragEnterEvent( QDragEnterEvent * );
120     virtual void dragMoveEvent( QDragMoveEvent * );
121     virtual void dragLeaveEvent( QDragLeaveEvent * );
122 private:
123     Ui::OpenFile ui;
124     FileOpenBox *dialogBox;
125     void BuildOldPanel();
126 public slots:
127     virtual void updateMRL();
128 private slots:
129     void browseFileSub();
130     void browseFile();
131     void removeFile();
132     void updateButtons();
133     void toggleSubtitleFrame( bool );
134 };
135
136 class NetOpenPanel: public OpenPanel
137 {
138     Q_OBJECT
139 public:
140     NetOpenPanel( QWidget *, intf_thread_t * );
141     virtual ~NetOpenPanel();
142     virtual void clear() ;
143 private:
144     Ui::OpenNetwork ui;
145     QStringListModel *mrlList;
146 public slots:
147     virtual void updateMRL();
148 private slots:
149     void updateCompleter();
150 };
151
152 class DiscOpenPanel: public OpenPanel
153 {
154     Q_OBJECT
155 public:
156     DiscOpenPanel( QWidget *, intf_thread_t * );
157     virtual ~DiscOpenPanel();
158     virtual void clear() ;
159     virtual void accept() ;
160 private:
161     Ui::OpenDisk ui;
162     char *psz_dvddiscpath, *psz_vcddiscpath, *psz_cddadiscpath;
163     bool b_firstdvd, b_firstvcd, b_firstcdda;
164 public slots:
165     virtual void updateMRL() ;
166 private slots:
167     void browseDevice();
168     void updateButtons() ;
169     void eject();
170 };
171
172
173 class CaptureOpenPanel: public OpenPanel
174 {
175     Q_OBJECT
176 public:
177     CaptureOpenPanel( QWidget *, intf_thread_t * );
178     virtual ~CaptureOpenPanel();
179     virtual void clear() ;
180 private:
181     Ui::OpenCapture ui;
182     bool isInitialized;
183
184     QString advMRL;
185     QDialog *adv;
186 #ifdef WIN32
187     QRadioButton *bdas, *bdat, *bdac, *bdaa;
188     QSpinBox *bdaCard, *bdaFreq, *bdaSrate;
189     QLabel *bdaSrateLabel, *bdaBandLabel;
190     QComboBox *bdaBandBox;
191     StringListConfigControl *vdevDshowW, *adevDshowW;
192     QLineEdit *dshowVSizeLine;
193 #else
194     QRadioButton *dvbs, *dvbt, *dvbc;
195     QLabel *dvbBandLabel, *dvbSrateLabel;
196     QSpinBox  *v4lFreq, *pvrFreq, *pvrBitr;
197     QLineEdit *v4lVideoDevice, *v4lAudioDevice;
198     QLineEdit *v4l2VideoDevice, *v4l2AudioDevice;
199     QLineEdit *pvrDevice, *pvrRadioDevice;
200     QComboBox *v4lNormBox, *v4l2StdBox, *pvrNormBox, *dvbBandBox;
201     QSpinBox *dvbCard, *dvbFreq, *dvbSrate;
202     QSpinBox *jackChannels, *jackCaching;
203     QCheckBox *jackPace, *jackConnect;
204     QLineEdit *jackPortsSelected;
205 #endif
206     QDoubleSpinBox *screenFPS;
207
208 public slots:
209     virtual void updateMRL();
210     void initialize();
211 private slots:
212     void updateButtons();
213     void advancedDialog();
214 };
215
216 #endif