]> git.sesse.net Git - vlc/blob - modules/gui/qt4/dialogs_provider.hpp
Qt: update mouse wheel simple preferences (refs #5883)
[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( "Subtitle 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 class QEvent;
61 class QSignalMapper;
62 class VLCMenuBar;
63
64 class DialogsProvider : public QObject
65 {
66     Q_OBJECT
67     friend class VLCMenuBar;
68
69 public:
70     static DialogsProvider *getInstance()
71     {
72         assert( instance );
73         return instance;
74     }
75     static DialogsProvider *getInstance( intf_thread_t *p_intf )
76     {
77         if( !instance )
78             instance = new DialogsProvider( p_intf );
79         return instance;
80     }
81     static void killInstance()
82     {
83         delete instance;
84         instance = NULL;
85     }
86
87     QStringList showSimpleOpen( const QString& help = QString(),
88                                 int filters = EXT_FILTER_MEDIA |
89                                 EXT_FILTER_VIDEO | EXT_FILTER_AUDIO |
90                                 EXT_FILTER_PLAYLIST,
91                                 const QString& path = QString() );
92     bool isDying() { return b_isDying; }
93     static QString getDirectoryDialog( intf_thread_t *p_intf);
94
95 protected:
96     QSignalMapper *menusMapper;
97     QSignalMapper *menusUpdateMapper;
98     QSignalMapper *SDMapper;
99     void customEvent( QEvent *);
100
101 private:
102     DialogsProvider( intf_thread_t *);
103     virtual ~DialogsProvider();
104     static DialogsProvider *instance;
105
106     intf_thread_t *p_intf;
107
108     QMenu* popupMenu;
109     QMenu* videoPopupMenu;
110     QMenu* audioPopupMenu;
111     QMenu* miscPopupMenu;
112
113     QWidget* root;
114     bool b_isDying;
115
116     void openDialog( int );
117     void addFromSimple( bool, bool );
118     void saveAPlaylist(playlist_t *p_playlist, playlist_item_t *p_node);
119
120 public slots:
121     void playlistDialog();
122     void bookmarksDialog();
123     void mediaInfoDialog();
124     void mediaCodecDialog();
125     void prefsDialog();
126     void extendedDialog();
127     void synchroDialog();
128     void messagesDialog();
129     void sendKey( int key );
130 #ifdef ENABLE_VLM
131     void vlmDialog();
132 #endif
133     void helpDialog();
134 #ifdef UPDATE_CHECK
135     void updateDialog();
136 #endif
137     void aboutDialog();
138     void gotoTimeDialog();
139     void podcastConfigureDialog();
140     void toolbarDialog();
141     void pluginDialog();
142     void epgDialog();
143     void setPopupMenu();
144     void destroyPopupMenu();
145
146     void openFileGenericDialog( intf_dialog_args_t * );
147
148     void simpleOpenDialog();
149
150     void openDialog();
151     void openDiscDialog();
152     void openFileDialog();
153     void openUrlDialog();
154     void openNetDialog();
155     void openCaptureDialog();
156
157     void PLAppendDialog( int tab = OPEN_FILE_TAB );
158     void MLAppendDialog( int tab = OPEN_FILE_TAB );
159
160     void PLOpenDir();
161     void PLAppendDir();
162
163     void streamingDialog( QWidget *parent, const QString& mrl, bool b_stream = true,
164                           QStringList options = QStringList("") );
165     void openAndStreamingDialogs();
166     void openAndTranscodingDialogs();
167
168     void openAPlaylist();
169     void savePlayingToPlaylist();
170     void saveRecentsToPlaylist();
171
172     void loadSubtitlesFile();
173
174     void quit();
175 private slots:
176     void menuAction( QObject *);
177     void menuUpdateAction( QObject * );
178     void SDMenuAction( const QString& );
179 signals:
180     void  toolBarConfUpdated();
181 };
182
183 class DialogEvent : public QEvent
184 {
185 public:
186     static const QEvent::Type DialogEvent_Type;
187     DialogEvent( int _i_dialog, int _i_arg, intf_dialog_args_t *_p_arg ) :
188                  QEvent( DialogEvent_Type )
189     {
190         i_dialog = _i_dialog;
191         i_arg = _i_arg;
192         p_arg = _p_arg;
193     }
194
195     int i_arg, i_dialog;
196     intf_dialog_args_t *p_arg;
197 };
198
199
200 #endif