]> git.sesse.net Git - vlc/blob - modules/gui/qt4/dialogs_provider.hpp
75f5e595d702b5a3b9d6afa3442a7481752a77d4
[vlc] / modules / gui / qt4 / dialogs_provider.hpp
1 /*****************************************************************************
2  * dialogs_provider.hpp : Dialogs provider
3  ****************************************************************************
4  * Copyright (C) 2006-2008 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 QVLC_DIALOGS_PROVIDER_H_
26 #define QVLC_DIALOGS_PROVIDER_H_
27
28 #ifdef HAVE_CONFIG_H
29 # include "config.h"
30 #endif
31
32 #include <assert.h>
33
34 #include "qt4.hpp"
35
36 #include "dialogs/open.hpp"
37 #include <QObject>
38 #include <QStringList>
39
40 #define ADD_FILTER_MEDIA( string )     \
41     string += qtr( "Media Files" );    \
42     string += " ( ";                   \
43     string += EXTENSIONS_MEDIA;        \
44     string += ");;";
45 #define ADD_FILTER_VIDEO( string )     \
46     string += qtr( "Video Files" );    \
47     string += " ( ";                   \
48     string += EXTENSIONS_VIDEO;        \
49     string += ");;";
50 #define ADD_FILTER_AUDIO( string )     \
51     string += qtr( "Audio Files" );    \
52     string += " ( ";                   \
53     string += EXTENSIONS_AUDIO;        \
54     string += ");;";
55 #define ADD_FILTER_PLAYLIST( string )  \
56     string += qtr( "Playlist Files" ); \
57     string += " ( ";                   \
58     string += EXTENSIONS_PLAYLIST;     \
59     string += ");;";
60 #define ADD_FILTER_SUBTITLE( string )  \
61     string += qtr( "Subtitles Files" );\
62     string += " ( ";                   \
63     string += EXTENSIONS_SUBTITLE;     \
64     string += ");;";
65 #define ADD_FILTER_ALL( string )       \
66     string += qtr( "All Files" );      \
67     string += " (*)";
68
69 enum {
70     EXT_FILTER_MEDIA     =  0x01,
71     EXT_FILTER_VIDEO     =  0x02,
72     EXT_FILTER_AUDIO     =  0x04,
73     EXT_FILTER_PLAYLIST  =  0x08,
74     EXT_FILTER_SUBTITLE  =  0x10,
75 };
76
77 enum {
78     DialogEvent_Type = QEvent::User + DialogEventType + 1,
79     //PLUndockEvent_Type = QEvent::User + DialogEventType + 2;
80     //PLDockEvent_Type = QEvent::User + DialogEventType + 3;
81     SetVideoOnTopEvent_Type = QEvent::User + DialogEventType + 4,
82 };
83
84 class QEvent;
85 class QSignalMapper;
86 class QVLCMenu;
87
88 class DialogsProvider : public QObject
89 {
90     Q_OBJECT
91     friend class QVLCMenu;
92
93 public:
94     static DialogsProvider *getInstance()
95     {
96         assert( instance );
97         return instance;
98     }
99     static DialogsProvider *getInstance( intf_thread_t *p_intf )
100     {
101         if( !instance )
102             instance = new DialogsProvider( p_intf );
103         return instance;
104     }
105     static void killInstance()
106     {
107         delete instance;
108         instance = NULL;
109     }
110     static bool isAlive()
111     {
112         return ( instance != NULL );
113     }
114
115     QStringList showSimpleOpen( const QString& help = QString(),
116                                 int filters = EXT_FILTER_MEDIA |
117                                 EXT_FILTER_VIDEO | EXT_FILTER_AUDIO |
118                                 EXT_FILTER_PLAYLIST,
119                                 const QString& path = QString() );
120     bool isDying() { return b_isDying; }
121 protected:
122     QSignalMapper *menusMapper;
123     QSignalMapper *menusUpdateMapper;
124     QSignalMapper *SDMapper;
125     void customEvent( QEvent *);
126
127 private:
128     DialogsProvider( intf_thread_t *);
129     virtual ~DialogsProvider();
130     static DialogsProvider *instance;
131
132     intf_thread_t *p_intf;
133     QWidget* root;
134     bool b_isDying;
135
136     void openDialog( int );
137     void addFromSimple( bool, bool );
138
139 public slots:
140     void playMRL( const QString & );
141
142     void playlistDialog();
143     void bookmarksDialog();
144     void mediaInfoDialog();
145     void mediaCodecDialog();
146     void prefsDialog();
147     void extendedDialog();
148     void synchroDialog();
149     void messagesDialog();
150 #ifdef ENABLE_VLM
151     void vlmDialog();
152 #endif
153     void helpDialog();
154 #ifdef UPDATE_CHECK
155     void updateDialog();
156 #endif
157     void aboutDialog();
158     void gotoTimeDialog();
159     void podcastConfigureDialog();
160     void toolbarDialog();
161     void pluginDialog();
162     void epgDialog();
163
164     void openFileGenericDialog( intf_dialog_args_t * );
165
166     void simpleOpenDialog();
167     void simplePLAppendDialog();
168     void simpleMLAppendDialog();
169
170     void openDialog();
171     void openDiscDialog();
172     void openFileDialog();
173     void openUrlDialog();
174     void openNetDialog();
175     void openCaptureDialog();
176
177     void PLAppendDialog( int tab = OPEN_FILE_TAB );
178     void MLAppendDialog( int tab = OPEN_FILE_TAB );
179
180     void PLOpenDir();
181     void PLAppendDir();
182     void MLAppendDir();
183
184     void streamingDialog( QWidget *parent, const QString& mrl, bool b_stream = true,
185                           QStringList options = QStringList("") );
186     void openAndStreamingDialogs();
187     void openAndTranscodingDialogs();
188
189     void openAPlaylist();
190     void saveAPlaylist();
191
192     void loadSubtitlesFile();
193
194     void quit();
195 private slots:
196     void menuAction( QObject *);
197     void menuUpdateAction( QObject * );
198     void SDMenuAction( const QString& );
199 signals:
200     void  toolBarConfUpdated();
201 };
202
203 class DialogEvent : public QEvent
204 {
205 public:
206     DialogEvent( int _i_dialog, int _i_arg, intf_dialog_args_t *_p_arg ) :
207                  QEvent( (QEvent::Type)(DialogEvent_Type) )
208     {
209         i_dialog = _i_dialog;
210         i_arg = _i_arg;
211         p_arg = _p_arg;
212     };
213     virtual ~DialogEvent() { };
214
215     int i_arg, i_dialog;
216     intf_dialog_args_t *p_arg;
217 };
218
219
220 #endif