open_panels.hpp 5.74 KB
Newer Older
Clément Stenac's avatar
Clément Stenac committed
1
/*****************************************************************************
Pere Orga's avatar
Pere Orga committed
2
 * open_panels.hpp : Panels for the open dialogs
Clément Stenac's avatar
Clément Stenac committed
3
 ****************************************************************************
4
 * Copyright (C) 2006-2009 the VideoLAN team
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
5 6
 * Copyright (C) 2007 Société des arts technologiques
 * Copyright (C) 2007 Savoir-faire Linux
7
 * $Id$
Clément Stenac's avatar
Clément Stenac committed
8 9
 *
 * Authors: Clément Stenac <zorglub@videolan.org>
Clément Stenac's avatar
Clément Stenac committed
10
 *          Jean-Baptiste Kempf <jb@videolan.org>
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
11
 *          Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com>
Clément Stenac's avatar
Clément Stenac committed
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/

#ifndef _OPENPANELS_H_
#define _OPENPANELS_H_

Christophe Mutricy's avatar
Christophe Mutricy committed
31 32 33 34
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
35
#include "components/preferences_widgets.hpp"
36

37
#include "ui/open_file.h"
38 39
#include "ui/open_disk.h"
#include "ui/open_net.h"
40
#include "ui/open_capture.h"
Clément Stenac's avatar
Clément Stenac committed
41

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
42
#include <QFileDialog>
43

44
#include <limits.h>
45

46 47
#define setSpinBoxFreq( spinbox ){ spinbox->setRange ( 0, INT_MAX ); \
    spinbox->setAccelerated( true ); }
48

49 50
enum
{
51
    V4L2_DEVICE,
52
    PVR_DEVICE,
53
    DTV_DEVICE,
54 55 56 57
    DSHOW_DEVICE,
    SCREEN_DEVICE,
    JACK_DEVICE
};
58

59
class QWidget;
60
class QLineEdit;
61
class QString;
62
class QStringListModel;
63
class QEvent;
64

Clément Stenac's avatar
Clément Stenac committed
65 66
class OpenPanel: public QWidget
{
67
    Q_OBJECT
Clément Stenac's avatar
Clément Stenac committed
68 69 70 71 72
public:
    OpenPanel( QWidget *p, intf_thread_t *_p_intf ) : QWidget( p )
    {
        p_intf = _p_intf;
    }
Clément Stenac's avatar
Clément Stenac committed
73 74
    virtual ~OpenPanel() {};
    virtual void clear() = 0;
75
    virtual void onFocus() {}
76
    virtual void onAccept() {}
Clément Stenac's avatar
Clément Stenac committed
77
protected:
Clément Stenac's avatar
Clément Stenac committed
78 79
    intf_thread_t *p_intf;
public slots:
Clément Stenac's avatar
Clément Stenac committed
80 81
    virtual void updateMRL() = 0;
signals:
82 83
    void mrlUpdated( const QStringList&, const QString& );
    void methodChanged( const QString& method );
Clément Stenac's avatar
Clément Stenac committed
84 85
};

86 87
class FileOpenBox: public QFileDialog
{
88
    Q_OBJECT
89 90 91 92 93 94 95 96 97 98
public:
    FileOpenBox( QWidget *parent, const QString &caption,
                 const QString &directory, const QString &filter ):
                QFileDialog( parent, caption, directory, filter ) {}
public slots:
    void accept(){}
    void reject(){}
};


Clément Stenac's avatar
Clément Stenac committed
99 100
class FileOpenPanel: public OpenPanel
{
101
    Q_OBJECT
Clément Stenac's avatar
Clément Stenac committed
102 103 104
public:
    FileOpenPanel( QWidget *, intf_thread_t * );
    virtual ~FileOpenPanel();
Clément Stenac's avatar
Clément Stenac committed
105
    virtual void clear() ;
106
    virtual void accept() ;
107
protected:
108
    bool eventFilter(QObject *, QEvent *event)
109 110 111 112 113 114 115 116 117
    {
        if( event->type() == QEvent::Hide ||
            event->type() == QEvent::HideToParent )
        {
            event->accept();
            return true;
        }
        return false;
    }
118 119 120 121
    virtual void dropEvent( QDropEvent *);
    virtual void dragEnterEvent( QDragEnterEvent * );
    virtual void dragMoveEvent( QDragMoveEvent * );
    virtual void dragLeaveEvent( QDragLeaveEvent * );
Clément Stenac's avatar
Clément Stenac committed
122
private:
123
    Ui::OpenFile ui;
124 125
    FileOpenBox *dialogBox;
    void BuildOldPanel();
Clément Stenac's avatar
Clément Stenac committed
126
public slots:
Clément Stenac's avatar
Clément Stenac committed
127 128
    virtual void updateMRL();
private slots:
129
    void browseFileSub();
130
    void browseFile();
131 132
    void removeFile();
    void updateButtons();
133
    void toggleSubtitleFrame( bool );
Clément Stenac's avatar
Clément Stenac committed
134 135
};

136 137
class NetOpenPanel: public OpenPanel
{
138
    Q_OBJECT
139 140 141
public:
    NetOpenPanel( QWidget *, intf_thread_t * );
    virtual ~NetOpenPanel();
Clément Stenac's avatar
Clément Stenac committed
142
    virtual void clear() ;
143
    void onFocus();
144
    void onAccept();
145
private:
146
    Ui::OpenNetwork ui;
147
    bool b_recentList;
148
public slots:
Clément Stenac's avatar
Clément Stenac committed
149
    virtual void updateMRL();
150 151
};

152 153 154 155 156 157 158 159 160
class UrlValidator : public QValidator
{
   Q_OBJECT
public:
   UrlValidator( QObject *parent ) : QValidator( parent ) { }
   void fixup( QString& ) const;
   QValidator::State validate( QString&, int& ) const;
};

161
class DiscOpenPanel: public OpenPanel
162
{
163
    Q_OBJECT
164 165 166 167 168
    enum    DiscType
    {
        None,
        Dvd,
        Vcd,
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
169 170
        Cdda,
        BRD
171
    };
172
public:
173 174
    DiscOpenPanel( QWidget *, intf_thread_t * );
    virtual ~DiscOpenPanel();
Clément Stenac's avatar
Clément Stenac committed
175
    virtual void clear() ;
176
    virtual void accept() ;
177
#ifdef WIN32
178
    void onFocus();
179
#endif
180 181
private:
    Ui::OpenDisk ui;
182
    char *psz_dvddiscpath, *psz_vcddiscpath, *psz_cddadiscpath;
183
    DiscType m_discType;
184
public slots:
Clément Stenac's avatar
Clément Stenac committed
185
    virtual void updateMRL() ;
186 187
private slots:
    void browseDevice();
188
    void updateButtons() ;
189
    void eject();
190 191
};

192 193 194

class CaptureOpenPanel: public OpenPanel
{
195
    Q_OBJECT
196 197 198 199 200 201
public:
    CaptureOpenPanel( QWidget *, intf_thread_t * );
    virtual ~CaptureOpenPanel();
    virtual void clear() ;
private:
    Ui::OpenCapture ui;
202 203
    bool isInitialized;

204
    QString advMRL;
205
    QStringList configList;
206
    QDialog *adv;
207
#ifdef WIN32
208 209
    StringListConfigControl *vdevDshowW, *adevDshowW;
    QLineEdit *dshowVSizeLine;
210
#else
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
211
    QSpinBox  *pvrFreq, *pvrBitr;
212
    QComboBox *v4l2VideoDevice, *v4l2AudioDevice;
213
    QLineEdit *pvrDevice, *pvrRadioDevice;
214
    QComboBox *v4l2StdBox, *pvrNormBox;
215
    QSpinBox *jackChannels;
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
216 217
    QCheckBox *jackPace, *jackConnect;
    QLineEdit *jackPortsSelected;
218
#endif
219
    QRadioButton *dvbc, *dvbs, *dvbs2, *dvbt, *dvbt2, *atsc, *cqam;
220
    QLabel *dvbBandLabel, *dvbSrateLabel, *dvbModLabel;
221
    QComboBox *dvbQamBox, *dvbPskBox, *dvbBandBox;
222
    QSpinBox *dvbCard, *dvbFreq, *dvbSrate;
223
    QDoubleSpinBox *screenFPS;
224

225 226
public slots:
    virtual void updateMRL();
227
    void initialize();
228 229
private slots:
    void updateButtons();
230
    void advancedDialog();
231 232
};

Clément Stenac's avatar
Clément Stenac committed
233
#endif