dialogs_provider.hpp 5.9 KB
Newer Older
Clément Stenac's avatar
Clément Stenac committed
1 2 3
/*****************************************************************************
 * dialogs_provider.hpp : Dialogs provider
 ****************************************************************************
4
 * Copyright (C) 2006-2008 the VideoLAN team
5
 * $Id$
Clément Stenac's avatar
Clément Stenac committed
6 7
 *
 * Authors: Clément Stenac <zorglub@videolan.org>
8
 *          Jean-Baptiste Kempf <jb@videolan.org>
Clément Stenac's avatar
Clément Stenac committed
9 10 11 12 13 14 15 16 17 18 19 20 21
 *
 * 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
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
22
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23
 *****************************************************************************/
Clément Stenac's avatar
Clément Stenac committed
24

25 26
#ifndef QVLC_DIALOGS_PROVIDER_H_
#define QVLC_DIALOGS_PROVIDER_H_
Clément Stenac's avatar
Clément Stenac committed
27

28 29
#ifdef HAVE_CONFIG_H
# include "config.h"
30 31
#endif

32
#include <assert.h>
Clément Stenac's avatar
Clément Stenac committed
33

34
#include "qt.hpp"
35

36
#include "dialogs/open.hpp"
37
#include <QObject>
38
#include <QStringList>
39

40 41 42 43
#define TITLE_EXTENSIONS_MEDIA qtr( "Media Files" )
#define TITLE_EXTENSIONS_VIDEO qtr( "Video Files" )
#define TITLE_EXTENSIONS_AUDIO qtr( "Audio Files" )
#define TITLE_EXTENSIONS_PLAYLIST qtr( "Playlist Files" )
44
#define TITLE_EXTENSIONS_SUBTITLE qtr( "Subtitle Files" )
45 46 47 48 49 50
#define TITLE_EXTENSIONS_ALL qtr( "All Files" )
#define EXTENSIONS_ALL "*"
#define ADD_EXT_FILTER( string, type ) \
    string = string + QString("%1 ( %2 );;") \
            .arg( TITLE_##type ) \
            .arg( QString( type ) );
51

52 53 54 55 56 57 58
enum {
    EXT_FILTER_MEDIA     =  0x01,
    EXT_FILTER_VIDEO     =  0x02,
    EXT_FILTER_AUDIO     =  0x04,
    EXT_FILTER_PLAYLIST  =  0x08,
    EXT_FILTER_SUBTITLE  =  0x10,
};
59

Clément Stenac's avatar
Clément Stenac committed
60
class QEvent;
61
class QSignalMapper;
62
class VLCMenuBar;
Clément Stenac's avatar
Clément Stenac committed
63 64 65

class DialogsProvider : public QObject
{
66
    Q_OBJECT
67
    friend class VLCMenuBar;
68

Clément Stenac's avatar
Clément Stenac committed
69
public:
70
    static DialogsProvider *getInstance()
71 72 73 74
    {
        assert( instance );
        return instance;
    }
Clément Stenac's avatar
Clément Stenac committed
75 76
    static DialogsProvider *getInstance( intf_thread_t *p_intf )
    {
77 78
        if( !instance )
            instance = new DialogsProvider( p_intf );
Clément Stenac's avatar
Clément Stenac committed
79 80
        return instance;
    }
Clément Stenac's avatar
Clément Stenac committed
81 82
    static void killInstance()
    {
83
        delete instance;
84
        instance = NULL;
Clément Stenac's avatar
Clément Stenac committed
85
    }
86

87
    QStringList showSimpleOpen( const QString& help = QString(),
88 89
                                int filters = EXT_FILTER_MEDIA |
                                EXT_FILTER_VIDEO | EXT_FILTER_AUDIO |
90
                                EXT_FILTER_PLAYLIST,
91
                                const QString& path = QString() );
92
    bool isDying() { return b_isDying; }
93
    static QString getDirectoryDialog( intf_thread_t *p_intf);
94
    static QStringList getOpenURL(QWidget *parent = NULL,
Filip Roséen's avatar
Filip Roséen committed
95 96 97
                                  const QString &caption = QString(),
                                  const QString &dir = QString(),
                                  const QString &filter = QString(),
98 99
                                  QString *selectedFilter = NULL );
    static QString getSaveFileName( QWidget *parent = NULL,
100 101 102
                                    const QString &caption = QString(),
                                    const QString &dir = QString(),
                                    const QString &filter = QString(),
103
                                    QString *selectedFilter = NULL );
104

Clément Stenac's avatar
Clément Stenac committed
105
protected:
106
    QSignalMapper *menusMapper;
107
    QSignalMapper *menusUpdateMapper;
Clément Stenac's avatar
Clément Stenac committed
108
    void customEvent( QEvent *);
109

Clément Stenac's avatar
Clément Stenac committed
110
private:
111
    DialogsProvider( intf_thread_t *);
112
    virtual ~DialogsProvider();
Clément Stenac's avatar
Clément Stenac committed
113
    static DialogsProvider *instance;
114 115

    intf_thread_t *p_intf;
116 117 118 119 120 121

    QMenu* popupMenu;
    QMenu* videoPopupMenu;
    QMenu* audioPopupMenu;
    QMenu* miscPopupMenu;

122
    QWidget* root;
123
    bool b_isDying;
Clément Stenac's avatar
Clément Stenac committed
124

125 126 127
    void openDialog( int );
    void addFromSimple( bool, bool );

Clément Stenac's avatar
Clément Stenac committed
128 129
public slots:
    void playlistDialog();
Clément Stenac's avatar
Clément Stenac committed
130
    void bookmarksDialog();
131
    void mediaInfoDialog();
132
    void mediaCodecDialog();
Clément Stenac's avatar
Clément Stenac committed
133
    void prefsDialog();
134
    void extendedDialog();
135
    void synchroDialog();
Clément Stenac's avatar
Clément Stenac committed
136
    void messagesDialog();
137
    void sendKey( int key );
138
#ifdef ENABLE_VLM
139
    void vlmDialog();
140
#endif
141
    void helpDialog();
Rafaël Carré's avatar
Rafaël Carré committed
142
#ifdef UPDATE_CHECK
143
    void updateDialog();
Rafaël Carré's avatar
Rafaël Carré committed
144
#endif
145 146
    void aboutDialog();
    void gotoTimeDialog();
147
    void podcastConfigureDialog();
148
    void toolbarDialog();
149
    void pluginDialog();
150
    void epgDialog();
151 152
    void setPopupMenu();
    void destroyPopupMenu();
153

154 155
    void openFileGenericDialog( intf_dialog_args_t * );

156 157
    void simpleOpenDialog();

158
    void openDialog();
159
    void openDiscDialog();
160
    void openFileDialog();
161
    void openUrlDialog();
162
    void openNetDialog();
163
    void openCaptureDialog();
164

165 166
    void PLAppendDialog( int tab = OPEN_FILE_TAB );
    void MLAppendDialog( int tab = OPEN_FILE_TAB );
167

168
    void PLOpenDir();
169 170
    void PLAppendDir();

171
    void streamingDialog( QWidget *parent, const QStringList& mrls, bool b_stream = true,
172
                          QStringList options = QStringList("") );
173 174
    void openAndStreamingDialogs();
    void openAndTranscodingDialogs();
175

176
    void openAPlaylist();
177
    void savePlayingToPlaylist();
178

179 180
    void loadSubtitlesFile();

181
    void quit();
182 183 184
private slots:
    void menuAction( QObject *);
    void menuUpdateAction( QObject * );
185 186
signals:
    void  toolBarConfUpdated();
187
    void releaseMouseEvents();
Clément Stenac's avatar
Clément Stenac committed
188 189
};

190 191 192
class DialogEvent : public QEvent
{
public:
193
    static const QEvent::Type DialogEvent_Type;
194
    DialogEvent( int _i_dialog, int _i_arg, intf_dialog_args_t *_p_arg ) :
195
                 QEvent( DialogEvent_Type )
196 197 198 199
    {
        i_dialog = _i_dialog;
        i_arg = _i_arg;
        p_arg = _p_arg;
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
200
    }
201 202 203 204 205 206

    int i_arg, i_dialog;
    intf_dialog_args_t *p_arg;
};


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