From 06c3e835dc0cd777d2fcf00e8cb68b68fc037d5d Mon Sep 17 00:00:00 2001 From: Edward Wang Date: Fri, 30 Dec 2011 21:58:12 -0500 Subject: [PATCH] Qt4: Make playlist window drag&drop to current selected PLSelItem Will 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 Signed-off-by: Jean-Baptiste Kempf --- modules/gui/qt4/components/playlist/playlist.cpp | 10 +++++++--- modules/gui/qt4/components/playlist/playlist.hpp | 2 ++ modules/gui/qt4/components/playlist/selector.cpp | 5 +++++ modules/gui/qt4/components/playlist/selector.hpp | 1 + modules/gui/qt4/main_interface.cpp | 15 ++++++++++++--- modules/gui/qt4/main_interface.hpp | 3 ++- 6 files changed, 29 insertions(+), 7 deletions(-) diff --git a/modules/gui/qt4/components/playlist/playlist.cpp b/modules/gui/qt4/components/playlist/playlist.cpp index 661f376375..32b0ea9254 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,12 @@ PlaylistWidget::~PlaylistWidget() void PlaylistWidget::dropEvent( QDropEvent *event ) { + if( !( selector->getCurrentItemCategory() == IS_PL || + selector->getCurrentItemCategory() == IS_ML ) ) 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, + (selector->getCurrentItemCategory() == 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 7172f95c90..7d10eb6120 100644 --- a/modules/gui/qt4/components/playlist/playlist.hpp +++ b/modules/gui/qt4/components/playlist/playlist.hpp @@ -46,6 +46,7 @@ class QSignalMapper; class SearchLineEdit; class QModelIndex; class QStackedWidget; +class PLSelector; class PlaylistWidget : public QWidget { @@ -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/components/playlist/selector.cpp b/modules/gui/qt4/components/playlist/selector.cpp index bb643821c9..693d454fd0 100644 --- a/modules/gui/qt4/components/playlist/selector.cpp +++ b/modules/gui/qt4/components/playlist/selector.cpp @@ -534,6 +534,11 @@ void PLSelector::getCurrentSelectedItem( int* type, QString *string) *string = currentItem()->data( 0, NAME_ROLE ).toString(); } +int PLSelector::getCurrentItemCategory() +{ + return currentItem()->data( 0, SPECIAL_ROLE ).toInt(); +} + void PLSelector::wheelEvent( QWheelEvent *e ) { // Accept this event in order to prevent unwanted volume up/down changes diff --git a/modules/gui/qt4/components/playlist/selector.hpp b/modules/gui/qt4/components/playlist/selector.hpp index 7657fa292a..21d2977388 100644 --- a/modules/gui/qt4/components/playlist/selector.hpp +++ b/modules/gui/qt4/components/playlist/selector.hpp @@ -117,6 +117,7 @@ public: virtual ~PLSelector(); void getCurrentSelectedItem( int *type, QString *name ); + int getCurrentItemCategory(); protected: virtual void drawBranches ( QPainter *, const QRect &, const QModelIndex & ) const; diff --git a/modules/gui/qt4/main_interface.cpp b/modules/gui/qt4/main_interface.cpp index 0e882310a8..19c65a8b3a 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 87e04d5a88..142d09252a 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 -- 2.11.4.GIT