d1547b2048bbe659a6d7dce017d3ce663498faa2
[vlc.git] / modules / gui / qt4 / dialogs_provider.hpp
1 /*****************************************************************************
2  * dialogs_provider.hpp : Dialogs provider
3  ****************************************************************************
4  * Copyright (C) 2006-2007 the VideoLAN team
5  * $Id$
6  *
7  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
8  *          Jean-Baptiste Kempf <jb@videolan.org>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 #ifndef _DIALOGS_PROVIDER_H_
26 #define _DIALOGS_PROVIDER_H_
27
28 #ifdef HAVE_CONFIG_H
29 # include "config.h"
30 #endif
31
32 #include <assert.h>
33 #include <vlc_common.h>
34 #include <vlc_interface.h>
35
36 #include "qt4.hpp"
37 #include "dialogs/interaction.hpp"
38 #include "dialogs/open.hpp"
39
40 #include <QObject>
41 #include <QTimer>
42 #include <QApplication>
43
44 #define ADD_FILTER_MEDIA( string )     \
45     string += qtr( "Media Files" );    \
46     string += " ( ";                   \
47     string += EXTENSIONS_MEDIA;        \
48     string += ");;";
49 #define ADD_FILTER_VIDEO( string )     \
50     string += qtr( "Video Files" );    \
51     string += " ( ";                   \
52     string += EXTENSIONS_VIDEO;        \
53     string += ");;";
54 #define ADD_FILTER_AUDIO( string )     \
55     string += qtr( "Audio Files" );    \
56     string += " ( ";                   \
57     string += EXTENSIONS_AUDIO;        \
58     string += ");;";
59 #define ADD_FILTER_PLAYLIST( string )  \
60     string += qtr( "Playlist Files" ); \
61     string += " ( ";                   \
62     string += EXTENSIONS_PLAYLIST;     \
63     string += ");;";
64 #define ADD_FILTER_SUBTITLE( string )  \
65     string += qtr( "Subtitles Files" );\
66     string += " ( ";                   \
67     string += EXTENSIONS_SUBTITLE;     \
68     string += ");;";
69 #define ADD_FILTER_ALL( string )       \
70     string += qtr( "All Files" );      \
71     string += " (*.*)";
72
73 enum {
74     EXT_FILTER_MEDIA     =  0x01,
75     EXT_FILTER_VIDEO     =  0x02,
76     EXT_FILTER_AUDIO     =  0x04,
77     EXT_FILTER_PLAYLIST  =  0x08,
78     EXT_FILTER_SUBTITLE  =  0x10,
79 };
80
81 class QEvent;
82 class QSignalMapper;
83 class QVLCMenu;
84
85 class DialogsProvider : public QObject
86 {
87     Q_OBJECT;
88     friend class QVLCMenu;
89
90 public:
91     static DialogsProvider *getInstance()
92     {
93         assert( instance );
94         return instance;
95     }
96     static DialogsProvider *getInstance( intf_thread_t *p_intf )
97     {
98         if( !instance )
99             instance = new DialogsProvider( p_intf );
100         return instance;
101     }
102     static void killInstance()
103     {
104         if( instance ) delete instance;
105         instance = NULL;
106     }
107     static bool isAlive()
108     {
109         return ( instance != NULL );
110     }
111     virtual ~DialogsProvider();
112     QTimer *fixed_timer;
113
114     QStringList showSimpleOpen( QString help = QString(),
115                                 int filters = EXT_FILTER_MEDIA |
116                                 EXT_FILTER_VIDEO | EXT_FILTER_AUDIO |
117                                 EXT_FILTER_PLAYLIST,
118                                 QString path = QString() );
119 protected:
120     QSignalMapper *menusMapper;
121     QSignalMapper *menusUpdateMapper;
122     QSignalMapper *SDMapper;
123     void customEvent( QEvent *);
124
125 private:
126     DialogsProvider( intf_thread_t *);
127     intf_thread_t *p_intf;
128     static DialogsProvider *instance;
129     void addFromSimple( bool, bool );
130
131 public slots:
132     void doInteraction( intf_dialog_args_t * );
133     void menuAction( QObject *);
134     void menuUpdateAction( QObject * );
135     void SDMenuAction( QString );
136
137     void playlistDialog();
138     void bookmarksDialog();
139     void mediaInfoDialog();
140     void mediaCodecDialog();
141     void prefsDialog();
142     void extendedDialog();
143     void messagesDialog();
144 #ifdef ENABLE_VLM
145     void vlmDialog();
146 #endif
147     void helpDialog();
148 #ifdef UPDATE_CHECK
149     void updateDialog();
150 #endif
151     void aboutDialog();
152     void gotoTimeDialog();
153     void podcastConfigureDialog();
154
155     void simpleOpenDialog();
156     void simplePLAppendDialog();
157     void simpleMLAppendDialog();
158
159     void openDialog();
160     void openDialog( int );
161     void openFileGenericDialog( intf_dialog_args_t * );
162     void openDiscDialog();
163     void openFileDialog();
164     void openNetDialog();
165     void openCaptureDialog();
166
167     void PLAppendDialog();
168     void MLAppendDialog();
169     void PLAppendDir();
170     void MLAppendDir();
171
172     void streamingDialog( QWidget *parent, QString mrl = "",
173             bool b_stream = true );
174     void openThenStreamingDialogs();
175     void openThenTranscodingDialogs();
176
177     void openAPlaylist();
178     void saveAPlaylist();
179
180     void loadSubtitlesFile();
181
182     void quit();
183 };
184
185 #endif