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 06c3e835dc0cd777d2fcf00e8cb68b68fc037d5d)
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 )
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 )
{
......
......@@ -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*/ ];
......
......@@ -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
......
......@@ -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;
......
......@@ -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();
}
......
......@@ -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
......
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