Commit 597edb00 authored by Edward Wang's avatar Edward Wang Committed by Jean-Baptiste Kempf

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: default avatarJean-Baptiste Kempf <jb@videolan.org>
(cherry picked from commit 06c3e835)
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 9d070085
...@@ -63,8 +63,8 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QWidget *_par ) ...@@ -63,8 +63,8 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QWidget *_par )
leftSplitter = new QSplitter( Qt::Vertical, this ); leftSplitter = new QSplitter( Qt::Vertical, this );
/* Source Selector */ /* Source Selector */
PLSelector *selector = new PLSelector( this, p_intf ); selector = new PLSelector( this, p_intf );
leftSplitter->addWidget( selector); leftSplitter->addWidget( selector );
/* Create a Container for the Art Label /* Create a Container for the Art Label
in order to have a beautiful resizing for the selector above it */ in order to have a beautiful resizing for the selector above it */
...@@ -211,8 +211,12 @@ PlaylistWidget::~PlaylistWidget() ...@@ -211,8 +211,12 @@ PlaylistWidget::~PlaylistWidget()
void PlaylistWidget::dropEvent( QDropEvent *event ) void PlaylistWidget::dropEvent( QDropEvent *event )
{ {
if( !( selector->getCurrentItemCategory() == IS_PL ||
selector->getCurrentItemCategory() == IS_ML ) ) return;
if( p_intf->p_sys->p_mi ) 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 ) void PlaylistWidget::dragEnterEvent( QDragEnterEvent *event )
{ {
......
...@@ -46,6 +46,7 @@ class QSignalMapper; ...@@ -46,6 +46,7 @@ class QSignalMapper;
class SearchLineEdit; class SearchLineEdit;
class QModelIndex; class QModelIndex;
class QStackedWidget; class QStackedWidget;
class PLSelector;
class PlaylistWidget : public QWidget class PlaylistWidget : public QWidget
{ {
...@@ -61,6 +62,7 @@ private: ...@@ -61,6 +62,7 @@ private:
QSplitter *leftSplitter; QSplitter *leftSplitter;
QSplitter *split; QSplitter *split;
StandardPLPanel *mainView; StandardPLPanel *mainView;
PLSelector *selector;
QAction *viewActions[ 4 /* StandardPLPanel::VIEW_COUNT*/ ]; QAction *viewActions[ 4 /* StandardPLPanel::VIEW_COUNT*/ ];
......
...@@ -534,6 +534,11 @@ void PLSelector::getCurrentSelectedItem( int* type, QString *string) ...@@ -534,6 +534,11 @@ void PLSelector::getCurrentSelectedItem( int* type, QString *string)
*string = currentItem()->data( 0, NAME_ROLE ).toString(); *string = currentItem()->data( 0, NAME_ROLE ).toString();
} }
int PLSelector::getCurrentItemCategory()
{
return currentItem()->data( 0, SPECIAL_ROLE ).toInt();
}
void PLSelector::wheelEvent( QWheelEvent *e ) void PLSelector::wheelEvent( QWheelEvent *e )
{ {
// Accept this event in order to prevent unwanted volume up/down changes // Accept this event in order to prevent unwanted volume up/down changes
......
...@@ -117,6 +117,7 @@ public: ...@@ -117,6 +117,7 @@ public:
virtual ~PLSelector(); virtual ~PLSelector();
void getCurrentSelectedItem( int *type, QString *name ); void getCurrentSelectedItem( int *type, QString *name );
int getCurrentItemCategory();
protected: protected:
virtual void drawBranches ( QPainter *, const QRect &, const QModelIndex & ) const; virtual void drawBranches ( QPainter *, const QRect &, const QModelIndex & ) const;
......
...@@ -1192,7 +1192,16 @@ void MainInterface::dropEvent(QDropEvent *event) ...@@ -1192,7 +1192,16 @@ void MainInterface::dropEvent(QDropEvent *event)
dropEventPlay( event, true ); 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 ) ) if( event->possibleActions() & ( Qt::CopyAction | Qt::MoveAction ) )
event->setDropAction( Qt::CopyAction ); event->setDropAction( Qt::CopyAction );
...@@ -1221,7 +1230,7 @@ void MainInterface::dropEventPlay( QDropEvent *event, bool b_play ) ...@@ -1221,7 +1230,7 @@ void MainInterface::dropEventPlay( QDropEvent *event, bool b_play )
QString mrl = toURI( url.toEncoded().constData() ); QString mrl = toURI( url.toEncoded().constData() );
playlist_Add( THEPL, qtu(mrl), NULL, playlist_Add( THEPL, qtu(mrl), NULL,
PLAYLIST_APPEND | (first ? PLAYLIST_GO: PLAYLIST_PREPARSE), PLAYLIST_APPEND | (first ? PLAYLIST_GO: PLAYLIST_PREPARSE),
PLAYLIST_END, true, pl_Unlocked ); PLAYLIST_END, b_playlist, pl_Unlocked );
first = false; first = false;
RecentsMRL::getInstance( p_intf )->addRecent( mrl ); RecentsMRL::getInstance( p_intf )->addRecent( mrl );
} }
...@@ -1236,7 +1245,7 @@ void MainInterface::dropEventPlay( QDropEvent *event, bool b_play ) ...@@ -1236,7 +1245,7 @@ void MainInterface::dropEventPlay( QDropEvent *event, bool b_play )
QString mrl = toURI( mimeData->text() ); QString mrl = toURI( mimeData->text() );
playlist_Add( THEPL, qtu(mrl), NULL, playlist_Add( THEPL, qtu(mrl), NULL,
PLAYLIST_APPEND | (first ? PLAYLIST_GO: PLAYLIST_PREPARSE), PLAYLIST_APPEND | (first ? PLAYLIST_GO: PLAYLIST_PREPARSE),
PLAYLIST_END, true, pl_Unlocked ); PLAYLIST_END, b_playlist, pl_Unlocked );
} }
event->accept(); event->accept();
} }
......
...@@ -88,7 +88,8 @@ public: ...@@ -88,7 +88,8 @@ public:
bool isInterfaceFullScreen() { return b_interfaceFullScreen; } bool isInterfaceFullScreen() { return b_interfaceFullScreen; }
protected: protected:
void dropEventPlay( QDropEvent *, bool); void dropEventPlay( QDropEvent* event, bool b_play ) { dropEventPlay(event, b_play, true); }
void dropEventPlay( QDropEvent *, bool, bool );
#ifdef WIN32 #ifdef WIN32
virtual bool winEvent( MSG *, long * ); virtual bool winEvent( MSG *, long * );
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment