]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/dialogs_provider.cpp
For consistency, remove references to vlc from libvlc
[vlc] / modules / gui / qt4 / dialogs_provider.cpp
index 6fe6c5199ea76ee7dc530f13a617a719921c2850..e35e70a501dddabb5e774d6b5f57169ac345c4f7 100644 (file)
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/
 
-#include "qt4.hpp"
 #include <QEvent>
+#include <QApplication>
+#include <QSignalMapper>
+#include <QFileDialog>
+
+#include "qt4.hpp"
 #include "dialogs_provider.hpp"
+#include "menus.hpp"
+#include <vlc_intf_strings.h>
+
+/* The dialogs */
 #include "dialogs/playlist.hpp"
 #include "dialogs/prefs_dialog.hpp"
 #include "dialogs/streaminfo.hpp"
-#include <QApplication>
-#include <QSignalMapper>
-#include "menus.hpp"
+#include "dialogs/messages.hpp"
 
 DialogsProvider* DialogsProvider::instance = NULL;
 
 DialogsProvider::DialogsProvider( intf_thread_t *_p_intf ) :
                                       QObject( NULL ), p_intf( _p_intf )
 {
-//    idle_timer = new QTimer( this );
-//    idle_timer->start( 0 );
-
     fixed_timer = new QTimer( this );
     fixed_timer->start( 150 /* milliseconds */ );
 
     menusMapper = new QSignalMapper();
-    connect( menusMapper, SIGNAL( mapped(QObject *) ), this,
-            SLOT(menuAction( QObject *)) );
+    CONNECT( menusMapper, mapped(QObject *), this, menuAction( QObject *) );
 
     menusUpdateMapper = new QSignalMapper();
-    connect( menusMapper, SIGNAL( mapped(QObject *) ), this,
-            SLOT(menuUpdateAction( QObject *)) );
+    CONNECT( menusUpdateMapper, mapped(QObject *),
+             this, menuUpdateAction( QObject *) );
 }
 
-DialogsProvider::~DialogsProvider()
-{
-}
 void DialogsProvider::customEvent( QEvent *event )
 {
     if( event->type() == DialogEvent_Type )
     {
-        DialogEvent *de = dynamic_cast<DialogEvent*>(event);
+        DialogEvent *de = static_cast<DialogEvent*>(event);
         switch( de->i_dialog )
         {
             case INTF_DIALOG_FILE:
@@ -82,6 +81,7 @@ void DialogsProvider::customEvent( QEvent *event )
                doInteraction( de->p_arg ); break;
             case INTF_DIALOG_VLM:
             case INTF_DIALOG_BOOKMARKS:
+               bookmarksDialog(); break;
             case INTF_DIALOG_WIZARD:
             default:
                msg_Warn( p_intf, "unimplemented dialog\n" );
@@ -98,6 +98,12 @@ void DialogsProvider::openDialog()
 {
     openDialog( 0 );
 }
+void DialogsProvider::PLAppendDialog()
+{
+}
+void DialogsProvider::MLAppendDialog()
+{
+}
 void DialogsProvider::openDialog( int i_dialog )
 {
 }
@@ -111,12 +117,13 @@ void DialogsProvider::doInteraction( intf_dialog_args_t *p_arg )
     case INTERACT_NEW:
         qdialog = new InteractionDialog( p_intf, p_dialog );
         p_dialog->p_private = (void*)qdialog;
-        qdialog->show();
+        if( !(p_dialog->i_status == ANSWERED_DIALOG) )
+            qdialog->show();
         break;
     case INTERACT_UPDATE:
         qdialog = (InteractionDialog*)(p_dialog->p_private);
         if( qdialog)
-            qdialog->Update();
+            qdialog->update();
         break;
     case INTERACT_HIDE:
         qdialog = (InteractionDialog*)(p_dialog->p_private);
@@ -126,12 +133,19 @@ void DialogsProvider::doInteraction( intf_dialog_args_t *p_arg )
         break;
     case INTERACT_DESTROY:
         qdialog = (InteractionDialog*)(p_dialog->p_private);
-        delete qdialog; 
+        if( !p_dialog->i_flags & DIALOG_NONBLOCKING_ERROR )
+            delete qdialog;
         p_dialog->i_status = DESTROYED_DIALOG;
         break;
     }
 }
 
+void DialogsProvider::quit()
+{
+    p_intf->b_die = VLC_TRUE;
+    QApplication::quit();
+}
+
 void DialogsProvider::streaminfoDialog()
 {
     StreamInfoDialog::getInstance( p_intf, true )->toggleVisible();
@@ -148,6 +162,7 @@ void DialogsProvider::prefsDialog()
 
 void DialogsProvider::messagesDialog()
 {
+    MessagesDialog::getInstance( p_intf )->toggleVisible();
 }
 
 void DialogsProvider::menuAction( QObject *data )
@@ -161,7 +176,95 @@ void DialogsProvider::menuUpdateAction( QObject *data )
     f->doFunc( p_intf );
 }
 
+void DialogsProvider::simplePLAppendDialog()
+{
+    QStringList files = showSimpleOpen();
+    QString file;
+    foreach( file, files )
+    {
+        const char * psz_utf8 = qtu( file );
+        playlist_PlaylistAdd( THEPL, psz_utf8, psz_utf8,
+                     PLAYLIST_APPEND | PLAYLIST_PREPARSE, PLAYLIST_END );
+    }
+}
+
+void DialogsProvider::simpleMLAppendDialog()
+{
+    QStringList files = showSimpleOpen();
+    QString file;
+    foreach( file, files )
+    {
+        const char * psz_utf8 =  qtu( file );
+        playlist_MLAdd( THEPL, psz_utf8, psz_utf8,
+                        PLAYLIST_APPEND | PLAYLIST_PREPARSE, PLAYLIST_END );
+    }
+}
+
 void DialogsProvider::simpleOpenDialog()
+{
+    QStringList files = showSimpleOpen();
+    QString file;
+    for( size_t i = 0 ; i< files.size(); i++ )
+    {
+        const char * psz_utf8 = qtu( files[i] );
+        /* Play the first one, parse and enqueue the other ones */
+        playlist_PlaylistAdd( THEPL, psz_utf8, psz_utf8,
+                     PLAYLIST_APPEND | (i ? 0 : PLAYLIST_GO) |
+                     ( i ? PLAYLIST_PREPARSE : 0 ),
+                     PLAYLIST_END );
+    }
+}
+
+void DialogsProvider::openPlaylist()
+{
+    QStringList files = showSimpleOpen();
+    QString file;
+    for( size_t i = 0 ; i< files.size(); i++ )
+    {
+        const char * psz_utf8 = qtu( files[i] );
+        /* Play the first one, parse and enqueue the other ones */
+        playlist_Import( THEPL, psz_utf8, THEPL->p_root_category, VLC_FALSE );
+    }
+}
+
+void DialogsProvider::openDirectory()
+{
+    QString dir = QFileDialog::getExistingDirectory ( 0,
+                                                     _("Open directory") );
+    const char *psz_utf8 = qtu( dir );
+    input_item_t *p_input = input_ItemNewExt( THEPL, psz_utf8, psz_utf8,
+                                               0, NULL, -1 );
+    playlist_PlaylistAddInput( THEPL, p_input,
+                               PLAYLIST_APPEND, PLAYLIST_END );
+    input_Read( THEPL, p_input, VLC_FALSE );
+}
+void DialogsProvider::openMLDirectory()
+{
+    QString dir = QFileDialog::getExistingDirectory ( 0,
+                                                     _("Open directory") );
+    const char *psz_utf8 = qtu( dir );
+    input_item_t *p_input = input_ItemNewExt( THEPL, psz_utf8, psz_utf8,
+                                               0, NULL, -1 );
+    playlist_MLAddInput( THEPL, p_input, PLAYLIST_APPEND, PLAYLIST_END );
+    input_Read( THEPL, p_input, VLC_FALSE );
+}
+
+QStringList DialogsProvider::showSimpleOpen()
+{
+    QString FileTypes;
+    FileTypes = "Video Files ( ";
+    FileTypes += EXTENSIONS_VIDEO;
+    FileTypes += ");; Sound Files ( ";
+    FileTypes += EXTENSIONS_AUDIO;
+    FileTypes += ");; PlayList Files ( ";
+    FileTypes += EXTENSIONS_PLAYLIST;
+    FileTypes += ");; All Files (*.*)" ;
+    FileTypes.replace(QString(";*"), QString(" *"));
+    return QFileDialog::getOpenFileNames( NULL, qfu(I_POP_SEL_FILES ),
+                    p_intf->p_libvlc->psz_homedir, FileTypes );
+}
+
+void DialogsProvider::bookmarksDialog()
 {
 }