[vlc-commits] commit: qt4: make dnd to accepts network-urls (Ilkka Ollakka )
git at videolan.org
git at videolan.org
Thu Jun 10 21:11:06 CEST 2010
vlc | branch: master | Ilkka Ollakka <ileoo at videolan.org> | Thu Jun 10 22:03:59 2010 +0300| [eeb1cf539937c797bcfe87807bc0e5b3a7a034b3] | committer: Ilkka Ollakka
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 ).
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=eeb1cf539937c797bcfe87807bc0e5b3a7a034b3
---
modules/gui/qt4/main_interface.cpp | 27 ++++++++++++++++++++-------
1 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/modules/gui/qt4/main_interface.cpp b/modules/gui/qt4/main_interface.cpp
index 93588b4..1a86e34 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)
More information about the vlc-commits
mailing list