[vlc-devel] [PATCH 1/2] Qt: Implement handling of QFileOpenEvent to play/enqueue files.
Juho Vähä-Herttua
juhovh at iki.fi
Sun Aug 1 16:01:37 CEST 2010
According to Qt4.6 docs this is currently supported for Mac OS X
only, but should work for others too if support is added later.
---
modules/gui/qt4/dialogs_provider.cpp | 19 +++++++++++++++++++
modules/gui/qt4/dialogs_provider.hpp | 1 +
modules/gui/qt4/qt4.cpp | 6 ++++++
modules/gui/qt4/util/qvlcapp.hpp | 13 +++++++++++++
4 files changed, 39 insertions(+), 0 deletions(-)
diff --git a/modules/gui/qt4/dialogs_provider.cpp b/modules/gui/qt4/dialogs_provider.cpp
index d3343bd..356e676 100644
--- a/modules/gui/qt4/dialogs_provider.cpp
+++ b/modules/gui/qt4/dialogs_provider.cpp
@@ -735,3 +735,22 @@ void DialogsProvider::playMRL( const QString &mrl )
RecentsMRL::getInstance( p_intf )->addRecent( mrl );
}
+
+/**
+ * Queue the MRL received from the QFileOpenEvent, if the playlist
+ * is empty, acts the same way as playMRL above.
+ **/
+void DialogsProvider::enqueueMRL( const QString &mrl )
+{
+ playlist_Lock( THEPL );
+
+ bool first = playlist_IsEmpty( THEPL );
+ char* psz_uri = make_URI( qtu(mrl), NULL );
+ playlist_Add( THEPL, psz_uri, NULL,
+ PLAYLIST_APPEND | (first ? PLAYLIST_GO : PLAYLIST_PREPARSE),
+ PLAYLIST_END, true, true );
+ free( psz_uri );
+
+ playlist_Unlock( THEPL );
+ RecentsMRL::getInstance( p_intf )->addRecent( mrl );
+}
diff --git a/modules/gui/qt4/dialogs_provider.hpp b/modules/gui/qt4/dialogs_provider.hpp
index 75f5e59..e774bb5 100644
--- a/modules/gui/qt4/dialogs_provider.hpp
+++ b/modules/gui/qt4/dialogs_provider.hpp
@@ -138,6 +138,7 @@ private:
public slots:
void playMRL( const QString & );
+ void enqueueMRL( const QString & );
void playlistDialog();
void bookmarksDialog();
diff --git a/modules/gui/qt4/qt4.cpp b/modules/gui/qt4/qt4.cpp
index 0e9ab8e..cbd622c 100644
--- a/modules/gui/qt4/qt4.cpp
+++ b/modules/gui/qt4/qt4.cpp
@@ -458,6 +458,12 @@ static void *Thread( void *obj )
/* Initialize timers and the Dialog Provider */
DialogsProvider::getInstance( p_intf );
+ /* Receive QFileOpenEvents to play/enqueue files */
+ QObject::connect( &app,
+ SIGNAL( fileOpenEvent( const QString & ) ),
+ DialogsProvider::getInstance( p_intf ),
+ SLOT( enqueueMRL( const QString & ) ) );
+
/* Detect screensize for small screens like TV or EEEpc*/
p_intf->p_sys->i_screenHeight =
app.QApplication::desktop()->availableGeometry().height();
diff --git a/modules/gui/qt4/util/qvlcapp.hpp b/modules/gui/qt4/util/qvlcapp.hpp
index bfd8a90..5df0e43 100644
--- a/modules/gui/qt4/util/qvlcapp.hpp
+++ b/modules/gui/qt4/util/qvlcapp.hpp
@@ -27,6 +27,7 @@
#include <QApplication>
#include <QEvent>
+#include <QFileOpenEvent>
#if defined(Q_WS_WIN)
# include <windows.h>
@@ -61,8 +62,20 @@ public:
}
#endif
+ bool event( QEvent *event )
+ {
+ if( event->type() == QEvent::FileOpen )
+ {
+ QFileOpenEvent *foe = static_cast<QFileOpenEvent*>(event);
+ emit fileOpenEvent( foe->file() );
+ return true;
+ }
+ return QApplication::event( event );
+ }
+
signals:
void quitSignal();
+ void fileOpenEvent( const QString & );
};
--
1.6.5.7
More information about the vlc-devel
mailing list