dialogs_provider.hpp 5.38 KB
Newer Older
Clément Stenac's avatar
Clément Stenac committed
1 2 3
/*****************************************************************************
 * dialogs_provider.hpp : Dialogs provider
 ****************************************************************************
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
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"
Christophe Mutricy's avatar
Christophe Mutricy committed
30 31
#endif

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

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
34
#include "qt.hpp"
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
35

36
#include "dialogs/open.hpp"
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
37
#include <QObject>
38
#include <QStringList>
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
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
{
François Cartegnie's avatar
François Cartegnie committed
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

Rémi Duraffort's avatar
Rémi Duraffort committed
87
    QStringList showSimpleOpen( const QString& help = QString(),
88 89
                                int filters = EXT_FILTER_MEDIA |
                                EXT_FILTER_VIDEO | EXT_FILTER_AUDIO |
90
                                EXT_FILTER_PLAYLIST,
Rémi Duraffort's avatar
Rémi Duraffort committed
91
                                const QString& path = QString() );
92
    bool isDying() { return b_isDying; }
93 94
    static QString getDirectoryDialog( intf_thread_t *p_intf);

Clément Stenac's avatar
Clément Stenac committed
95
protected:
96
    QSignalMapper *menusMapper;
97
    QSignalMapper *menusUpdateMapper;
Clément Stenac's avatar
Clément Stenac committed
98
    QSignalMapper *SDMapper;
Clément Stenac's avatar
Clément Stenac committed
99
    void customEvent( QEvent *);
100

Clément Stenac's avatar
Clément Stenac committed
101
private:
102
    DialogsProvider( intf_thread_t *);
103
    virtual ~DialogsProvider();
Clément Stenac's avatar
Clément Stenac committed
104
    static DialogsProvider *instance;
105 106

    intf_thread_t *p_intf;
107 108 109 110 111 112

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

113
    QWidget* root;
114
    bool b_isDying;
Clément Stenac's avatar
Clément Stenac committed
115

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
116 117
    void openDialog( int );
    void addFromSimple( bool, bool );
118
    void saveAPlaylist(playlist_t *p_playlist, playlist_item_t *p_node);
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
119

Clément Stenac's avatar
Clément Stenac committed
120 121
public slots:
    void playlistDialog();
Clément Stenac's avatar
Clément Stenac committed
122
    void bookmarksDialog();
123
    void mediaInfoDialog();
124
    void mediaCodecDialog();
Clément Stenac's avatar
Clément Stenac committed
125
    void prefsDialog();
126
    void extendedDialog();
127
    void synchroDialog();
Clément Stenac's avatar
Clément Stenac committed
128
    void messagesDialog();
129
    void sendKey( int key );
130
#ifdef ENABLE_VLM
131
    void vlmDialog();
132
#endif
133
    void helpDialog();
Rafaël Carré's avatar
Rafaël Carré committed
134
#ifdef UPDATE_CHECK
135
    void updateDialog();
Rafaël Carré's avatar
Rafaël Carré committed
136
#endif
137 138
    void aboutDialog();
    void gotoTimeDialog();
139
    void podcastConfigureDialog();
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
140
    void toolbarDialog();
141
    void pluginDialog();
142
    void epgDialog();
143 144
    void setPopupMenu();
    void destroyPopupMenu();
145

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
146 147
    void openFileGenericDialog( intf_dialog_args_t * );

148 149
    void simpleOpenDialog();

150
    void openDialog();
151
    void openDiscDialog();
152
    void openFileDialog();
153
    void openUrlDialog();
154
    void openNetDialog();
155
    void openCaptureDialog();
156

157 158
    void PLAppendDialog( int tab = OPEN_FILE_TAB );
    void MLAppendDialog( int tab = OPEN_FILE_TAB );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
159

160
    void PLOpenDir();
161 162
    void PLAppendDir();

163
    void streamingDialog( QWidget *parent, const QStringList& mrls, bool b_stream = true,
164
                          QStringList options = QStringList("") );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
165 166
    void openAndStreamingDialogs();
    void openAndTranscodingDialogs();
167

168
    void openAPlaylist();
169 170
    void savePlayingToPlaylist();
    void saveRecentsToPlaylist();
171

172 173
    void loadSubtitlesFile();

174
    void quit();
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
175 176 177
private slots:
    void menuAction( QObject *);
    void menuUpdateAction( QObject * );
Rémi Duraffort's avatar
Rémi Duraffort committed
178
    void SDMenuAction( const QString& );
179 180
signals:
    void  toolBarConfUpdated();
Clément Stenac's avatar
Clément Stenac committed
181 182
};

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
183 184 185
class DialogEvent : public QEvent
{
public:
186
    static const QEvent::Type DialogEvent_Type;
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
187
    DialogEvent( int _i_dialog, int _i_arg, intf_dialog_args_t *_p_arg ) :
188
                 QEvent( DialogEvent_Type )
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
189 190 191 192
    {
        i_dialog = _i_dialog;
        i_arg = _i_arg;
        p_arg = _p_arg;
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
193
    }
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
194 195 196 197 198 199

    int i_arg, i_dialog;
    intf_dialog_args_t *p_arg;
};


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