From eeb1cf539937c797bcfe87807bc0e5b3a7a034b3 Mon Sep 17 00:00:00 2001 From: Ilkka Ollakka Date: Thu, 10 Jun 2010 22:03:59 +0300 Subject: [PATCH] qt4: make dnd to accepts network-urls drop toNativeSeparators-usage (shoudln't break win32, but then again this could be my application for the 'stupid win32 breakage of the year' ;). This allows for example drag youtube links to vlc playlist directly. Parse also dropper text if it has valid url if we don't have urls on drop ( from browser addressbar for example you get text ). --- modules/gui/qt4/main_interface.cpp | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/modules/gui/qt4/main_interface.cpp b/modules/gui/qt4/main_interface.cpp index 93588b4fac..1a86e34780 100644 --- a/modules/gui/qt4/main_interface.cpp +++ b/modules/gui/qt4/main_interface.cpp @@ -1040,8 +1040,9 @@ void MainInterface::dropEvent(QDropEvent *event) void MainInterface::dropEventPlay( QDropEvent *event, bool b_play ) { - event->setDropAction( Qt::CopyAction ); - if( !event->possibleActions() & Qt::CopyAction ) + if( event->possibleActions() & Qt::CopyAction ) + event->setDropAction( Qt::CopyAction ); + else return; const QMimeData *mimeData = event->mimeData(); @@ -1061,18 +1062,30 @@ void MainInterface::dropEventPlay( QDropEvent *event, bool b_play ) bool first = b_play; foreach( const QUrl &url, mimeData->urls() ) { - QString s = toNativeSeparators( url.toLocalFile() ); - - if( s.length() > 0 ) { - char* psz_uri = make_URI( qtu(s) ); + if( url.isValid() ) + { + char* psz_uri = make_URI( qtu( url.toString() ) ); playlist_Add( THEPL, psz_uri, NULL, PLAYLIST_APPEND | (first ? PLAYLIST_GO: PLAYLIST_PREPARSE), PLAYLIST_END, true, pl_Unlocked ); free( psz_uri ); first = false; - RecentsMRL::getInstance( p_intf )->addRecent( s ); + RecentsMRL::getInstance( p_intf )->addRecent( url.toString() ); } } + + /* Browsers give content as text if you dnd the addressbar, + so check if mimedata has valid url in text and use it + if we didn't get any normal Urls()*/ + if( !mimeData->hasUrls() && mimeData->hasText() && + QUrl(mimeData->text()).isValid() ) + { + char *psz_uri = make_URI( qtu( mimeData->text() ) ); + playlist_Add( THEPL, psz_uri, NULL, + PLAYLIST_APPEND | (first ? PLAYLIST_GO: PLAYLIST_PREPARSE), + PLAYLIST_END, true, pl_Unlocked ); + free( psz_uri ); + } event->accept(); } void MainInterface::dragEnterEvent(QDragEnterEvent *event) -- 2.39.5