[vlc-devel] [PATCH] Qt4: Make playlist window drag&drop to current selected PLSelItem

Edward Wang edward.c.wang at compdigitec.com
Wed Dec 28 16:59:40 CET 2011


Make playlist window drag and drop to current selection (either media library or playlist). This should make it somewhat more user friendly because it drops into where the user expects it to.
Fixes #4873
Thanks,
	Edward Wang

---
 modules/gui/qt4/components/playlist/playlist.cpp |   12 +++++++++---
 modules/gui/qt4/components/playlist/playlist.hpp |    2 ++
 modules/gui/qt4/main_interface.cpp               |   15 ++++++++++++---
 modules/gui/qt4/main_interface.hpp               |    3 ++-
 4 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/modules/gui/qt4/components/playlist/playlist.cpp b/modules/gui/qt4/components/playlist/playlist.cpp
index 661f376..469fc69 100644
--- a/modules/gui/qt4/components/playlist/playlist.cpp
+++ b/modules/gui/qt4/components/playlist/playlist.cpp
@@ -63,8 +63,8 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QWidget *_par )
     leftSplitter = new QSplitter( Qt::Vertical, this );
 
     /* Source Selector */
-    PLSelector *selector = new PLSelector( this, p_intf );
-    leftSplitter->addWidget( selector);
+    selector = new PLSelector( this, p_intf );
+    leftSplitter->addWidget( selector );
 
     /* Create a Container for the Art Label
        in order to have a beautiful resizing for the selector above it */
@@ -211,8 +211,14 @@ PlaylistWidget::~PlaylistWidget()
 
 void PlaylistWidget::dropEvent( QDropEvent *event )
 {
+    bool is_pl;
+    int x = selector->currentItem()->data( 0, SPECIAL_ROLE ).toInt();
+    if( x == IS_PL ) is_pl = true;
+    else if( x == IS_ML ) is_pl = false;
+    else return;
+
     if( p_intf->p_sys->p_mi )
-        p_intf->p_sys->p_mi->dropEventPlay( event, false );
+        p_intf->p_sys->p_mi->dropEventPlay( event, false, is_pl );
 }
 void PlaylistWidget::dragEnterEvent( QDragEnterEvent *event )
 {
diff --git a/modules/gui/qt4/components/playlist/playlist.hpp b/modules/gui/qt4/components/playlist/playlist.hpp
index 7172f95..9709a29 100644
--- a/modules/gui/qt4/components/playlist/playlist.hpp
+++ b/modules/gui/qt4/components/playlist/playlist.hpp
@@ -33,6 +33,7 @@
 #include "qt4.hpp"
 
 //#include <vlc_playlist.h>
+#include "selector.hpp"
 
 #include <QSplitter>
 
@@ -61,6 +62,7 @@ private:
     QSplitter            *leftSplitter;
     QSplitter            *split;
     StandardPLPanel      *mainView;
+    PLSelector           *selector;
 
     QAction *viewActions[ 4 /* StandardPLPanel::VIEW_COUNT*/ ];
 
diff --git a/modules/gui/qt4/main_interface.cpp b/modules/gui/qt4/main_interface.cpp
index 0e88231..19c65a8 100644
--- a/modules/gui/qt4/main_interface.cpp
+++ b/modules/gui/qt4/main_interface.cpp
@@ -1192,7 +1192,16 @@ void MainInterface::dropEvent(QDropEvent *event)
     dropEventPlay( event, true );
 }
 
-void MainInterface::dropEventPlay( QDropEvent *event, bool b_play )
+/**
+ * dropEventPlay
+ *
+ * Event called if something is dropped onto a VLC window
+ * \param event the event in question
+ * \param b_play whether to play the file immediately
+ * \param b_playlist true to add to playlist, false to add to media library
+ * \return nothing
+ */
+void MainInterface::dropEventPlay( QDropEvent *event, bool b_play, bool b_playlist )
 {
     if( event->possibleActions() & ( Qt::CopyAction | Qt::MoveAction ) )
        event->setDropAction( Qt::CopyAction );
@@ -1221,7 +1230,7 @@ void MainInterface::dropEventPlay( QDropEvent *event, bool b_play )
             QString mrl = toURI( url.toEncoded().constData() );
             playlist_Add( THEPL, qtu(mrl), NULL,
                           PLAYLIST_APPEND | (first ? PLAYLIST_GO: PLAYLIST_PREPARSE),
-                          PLAYLIST_END, true, pl_Unlocked );
+                          PLAYLIST_END, b_playlist, pl_Unlocked );
             first = false;
             RecentsMRL::getInstance( p_intf )->addRecent( mrl );
         }
@@ -1236,7 +1245,7 @@ void MainInterface::dropEventPlay( QDropEvent *event, bool b_play )
         QString mrl = toURI( mimeData->text() );
         playlist_Add( THEPL, qtu(mrl), NULL,
                       PLAYLIST_APPEND | (first ? PLAYLIST_GO: PLAYLIST_PREPARSE),
-                      PLAYLIST_END, true, pl_Unlocked );
+                      PLAYLIST_END, b_playlist, pl_Unlocked );
     }
     event->accept();
 }
diff --git a/modules/gui/qt4/main_interface.hpp b/modules/gui/qt4/main_interface.hpp
index 87e04d5..142d092 100644
--- a/modules/gui/qt4/main_interface.hpp
+++ b/modules/gui/qt4/main_interface.hpp
@@ -88,7 +88,8 @@ public:
     bool isInterfaceFullScreen() { return b_interfaceFullScreen; }
 
 protected:
-    void dropEventPlay( QDropEvent *, bool);
+    void dropEventPlay( QDropEvent* event, bool b_play ) { dropEventPlay(event, b_play, true); }
+    void dropEventPlay( QDropEvent *, bool, bool );
 #ifdef WIN32
     virtual bool winEvent( MSG *, long * );
 #endif
-- 
1.7.5.4




More information about the vlc-devel mailing list