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