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