dialogs_provider.hpp 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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. #ifndef QVLC_DIALOGS_PROVIDER_H_
  25. #define QVLC_DIALOGS_PROVIDER_H_
  26. #ifdef HAVE_CONFIG_H
  27. # include "config.h"
  28. #endif
  29. #include <assert.h>
  30. #include "qt.hpp"
  31. #include "dialogs/open.hpp"
  32. #include <QObject>
  33. #include <QStringList>
  34. #define TITLE_EXTENSIONS_MEDIA qtr( "Media Files" )
  35. #define TITLE_EXTENSIONS_VIDEO qtr( "Video Files" )
  36. #define TITLE_EXTENSIONS_AUDIO qtr( "Audio Files" )
  37. #define TITLE_EXTENSIONS_PLAYLIST qtr( "Playlist Files" )
  38. #define TITLE_EXTENSIONS_SUBTITLE qtr( "Subtitle Files" )
  39. #define TITLE_EXTENSIONS_ALL qtr( "All Files" )
  40. #define EXTENSIONS_ALL "*"
  41. #define ADD_EXT_FILTER( string, type ) \
  42. string = string + QString("%1 ( %2 );;") \
  43. .arg( TITLE_##type ) \
  44. .arg( QString( type ) );
  45. enum {
  46. EXT_FILTER_MEDIA = 0x01,
  47. EXT_FILTER_VIDEO = 0x02,
  48. EXT_FILTER_AUDIO = 0x04,
  49. EXT_FILTER_PLAYLIST = 0x08,
  50. EXT_FILTER_SUBTITLE = 0x10,
  51. };
  52. class QEvent;
  53. class QSignalMapper;
  54. class VLCMenuBar;
  55. class DialogsProvider : public QObject
  56. {
  57. Q_OBJECT
  58. friend class VLCMenuBar;
  59. public:
  60. static DialogsProvider *getInstance()
  61. {
  62. assert( instance );
  63. return instance;
  64. }
  65. static DialogsProvider *getInstance( intf_thread_t *p_intf )
  66. {
  67. if( !instance )
  68. instance = new DialogsProvider( p_intf );
  69. return instance;
  70. }
  71. static void killInstance()
  72. {
  73. delete instance;
  74. instance = NULL;
  75. }
  76. QStringList showSimpleOpen( const QString& help = QString(),
  77. int filters = EXT_FILTER_MEDIA |
  78. EXT_FILTER_VIDEO | EXT_FILTER_AUDIO |
  79. EXT_FILTER_PLAYLIST,
  80. const QString& path = QString() );
  81. bool isDying() { return b_isDying; }
  82. static QString getDirectoryDialog( intf_thread_t *p_intf);
  83. protected:
  84. QSignalMapper *menusMapper;
  85. QSignalMapper *menusUpdateMapper;
  86. QSignalMapper *SDMapper;
  87. void customEvent( QEvent *);
  88. private:
  89. DialogsProvider( intf_thread_t *);
  90. virtual ~DialogsProvider();
  91. static DialogsProvider *instance;
  92. intf_thread_t *p_intf;
  93. QMenu* popupMenu;
  94. QMenu* videoPopupMenu;
  95. QMenu* audioPopupMenu;
  96. QMenu* miscPopupMenu;
  97. QWidget* root;
  98. bool b_isDying;
  99. void openDialog( int );
  100. void addFromSimple( bool, bool );
  101. void saveAPlaylist(playlist_t *p_playlist, playlist_item_t *p_node);
  102. public slots:
  103. void playlistDialog();
  104. void bookmarksDialog();
  105. void mediaInfoDialog();
  106. void mediaCodecDialog();
  107. void prefsDialog();
  108. void extendedDialog();
  109. #if defined(ENABLE_SOUT)
  110. void rendererDialog();
  111. #endif
  112. void synchroDialog();
  113. void messagesDialog();
  114. void sendKey( int key );
  115. #ifdef ENABLE_VLM
  116. void vlmDialog();
  117. #endif
  118. void helpDialog();
  119. #ifdef UPDATE_CHECK
  120. void updateDialog();
  121. #endif
  122. void aboutDialog();
  123. void gotoTimeDialog();
  124. void podcastConfigureDialog();
  125. void toolbarDialog();
  126. void pluginDialog();
  127. void epgDialog();
  128. void setPopupMenu();
  129. void destroyPopupMenu();
  130. void openFileGenericDialog( intf_dialog_args_t * );
  131. void simpleOpenDialog();
  132. void openDialog();
  133. void openDiscDialog();
  134. void openFileDialog();
  135. void openUrlDialog();
  136. void openNetDialog();
  137. void openCaptureDialog();
  138. void PLAppendDialog( int tab = OPEN_FILE_TAB );
  139. void MLAppendDialog( int tab = OPEN_FILE_TAB );
  140. void PLOpenDir();
  141. void PLAppendDir();
  142. void streamingDialog( QWidget *parent, const QStringList& mrls, bool b_stream = true,
  143. QStringList options = QStringList("") );
  144. void openAndStreamingDialogs();
  145. void openAndTranscodingDialogs();
  146. void openAPlaylist();
  147. void savePlayingToPlaylist();
  148. void saveRecentsToPlaylist();
  149. void loadSubtitlesFile();
  150. void quit();
  151. private slots:
  152. void menuAction( QObject *);
  153. void menuUpdateAction( QObject * );
  154. void SDMenuAction( const QString& );
  155. signals:
  156. void toolBarConfUpdated();
  157. };
  158. class DialogEvent : public QEvent
  159. {
  160. public:
  161. static const QEvent::Type DialogEvent_Type;
  162. DialogEvent( int _i_dialog, int _i_arg, intf_dialog_args_t *_p_arg ) :
  163. QEvent( DialogEvent_Type )
  164. {
  165. i_dialog = _i_dialog;
  166. i_arg = _i_arg;
  167. p_arg = _p_arg;
  168. }
  169. int i_arg, i_dialog;
  170. intf_dialog_args_t *p_arg;
  171. };
  172. #endif