[vlc-devel] [PATCH 2/2] DnD from Internet Explorer to VLC and support of links (*.lnk)

Mario Speiß 1034-135 at online.de
Sun Jan 6 17:52:18 CET 2013


On Windows a Drag and Drop seems to be a Qt::LinkAction. And support for file
system links is added.

Hopefully the encoding of the URL is now correct.

Regards,
Mario
---
 modules/gui/qt4/dialogs/playlist.cpp |   17 +++++++++++++----
 modules/gui/qt4/main_interface.cpp   |   21 +++++++++++++++++----
 2 files changed, 30 insertions(+), 8 deletions(-)

diff --git a/modules/gui/qt4/dialogs/playlist.cpp b/modules/gui/qt4/dialogs/playlist.cpp
index 2f2b724..3a5dc4b
--- a/modules/gui/qt4/dialogs/playlist.cpp
+++ b/modules/gui/qt4/dialogs/playlist.cpp
@@ -33,6 +33,7 @@
 #include <QUrl>
 #include <QMimeData>
 #include <QHBoxLayout>
+#include <QFileInfo>
 
 PlaylistDialog::PlaylistDialog( intf_thread_t *_p_intf )
                 : QVLCMW( _p_intf )
@@ -84,11 +85,19 @@ void PlaylistDialog::dropEvent( QDropEvent *event )
 {
      const QMimeData *mimeData = event->mimeData();
      foreach( const QUrl &url, mimeData->urls() ) {
-        QString s = toNativeSeparators( url.toString() );
-        if( s.length() > 0 ) {
-            playlist_Add( THEPL, qtu(s), NULL,
+         QString mrl = toURI( url.toEncoded().constData() );
+         QVLCFileInfo info( url.toLocalFile() );
+         if( info.exists() && info.isSymLink() )
+         {
+             QString target = info.symLinkTarget();
+             QUrl url;
+             if( QFile::exists( target ) )
+                 url = QUrl::fromLocalFile( target );
+             mrl = toURI( url.toEncoded().constData() );
+         }
+         if( mrl.length() > 0 )
+             playlist_Add( THEPL, qtu(mrl), NULL,
                           PLAYLIST_APPEND, PLAYLIST_END, true, false );
-        }
      }
      event->acceptProposedAction();
 }
diff --git a/modules/gui/qt4/main_interface.cpp b/modules/gui/qt4/main_interface.cpp
index f479e4e..4af6782
--- a/modules/gui/qt4/main_interface.cpp
+++ b/modules/gui/qt4/main_interface.cpp
@@ -59,6 +59,7 @@
 #include <QStatusBar>
 #include <QLabel>
 #include <QStackedWidget>
+#include <QFileInfo>
 
 #include <vlc_keys.h>                       /* Wheel event */
 #include <vlc_vout_display.h>               /* vout_thread_t and VOUT_ events */
@@ -1263,7 +1264,7 @@ void MainInterface::dropEvent(QDropEvent *event)
  */
 void MainInterface::dropEventPlay( QDropEvent *event, bool b_play, bool b_playlist )
 {
-    if( event->possibleActions() & ( Qt::CopyAction | Qt::MoveAction ) )
+    if( event->possibleActions() & ( Qt::CopyAction | Qt::MoveAction | Qt::LinkAction ) )
        event->setDropAction( Qt::CopyAction );
     else
         return;
@@ -1288,11 +1289,23 @@ void MainInterface::dropEventPlay( QDropEvent *event, bool b_play, bool b_playli
         if( url.isValid() )
         {
             QString mrl = toURI( url.toEncoded().constData() );
-            playlist_Add( THEPL, qtu(mrl), NULL,
+            QFileInfo info( url.toLocalFile() );
+            if( info.exists() && info.isSymLink() )
+            {
+                QString target = info.symLinkTarget();
+                QUrl url;
+                if( QFile::exists( target ) )
+                    url = QUrl::fromLocalFile( target );
+                mrl = toURI( url.toEncoded().constData() );
+            }
+            if( mrl.length() > 0 )
+            {
+                playlist_Add( THEPL, qtu(mrl), NULL,
                           PLAYLIST_APPEND | (first ? PLAYLIST_GO: PLAYLIST_PREPARSE),
                           PLAYLIST_END, b_playlist, pl_Unlocked );
-            first = false;
-            RecentsMRL::getInstance( p_intf )->addRecent( mrl );
+                first = false;
+                RecentsMRL::getInstance( p_intf )->addRecent( mrl );
+            }
         }
     }
 
-- 
1.7.5.4




More information about the vlc-devel mailing list