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

Mario Speiß 1034-135 at online.de
Mon Jan 7 22:45:24 CET 2013


Assume someone drops a .lnk in VLC, the url is converted with 
toLocalFile() to construct QFileInfo from that file (the .lnk). Then the 
QFileInfo::symLinkTarget() returns a file path to the resolved link. 
Adding the "file:///"+target to the playlist (as the first patch did) 
obviously causes trouble. Thats why another QUrl is constructed using 
fromFile(symLinkTarget) to encode the linked file path correctly before 
being added to the playlist.

The last patch works flawlessly and gets you rid from the error message 
of vlc not knowing how to playback you-name-the-clip.lnk but just plays it.

Regards,
Mario

On 06.01.2013 21:39, Rémi Denis-Courmont wrote:
> Le dimanche 6 janvier 2013 18:52:18, Mario Speiß a écrit :
>> 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 );
>> -        }
>
> I don't see the point in converting the string from file path into an URI and
> then back into a file path...
>
>>        }
>>        event->acceptProposedAction();
>>   }
>



More information about the vlc-devel mailing list