Commit ce7108fe authored by Michael Pyne's avatar Michael Pyne
Browse files

Merge branch 'drag-move-view' into 'master'

Switch to the playlist when dragging tracks to it.

See merge request kde/juk!16
parents f6acade5 b5c46ea0
Pipeline #13278 passed with stage
in 10 minutes and 46 seconds
......@@ -167,6 +167,8 @@ PlaylistBox::PlaylistBox(PlayerManager *player, QWidget *parent, QStackedWidget
this, SLOT(slotSetHistoryPlaylistEnabled(bool)));
m_showTimer = new QTimer(this);
m_showTimer->setSingleShot(true);
m_showTimer->setInterval(500);
connect(m_showTimer, SIGNAL(timeout()), SLOT(slotShowDropTarget()));
// hook up to the D-Bus
......@@ -473,12 +475,7 @@ void PlaylistBox::slotSavePlaylists()
void PlaylistBox::slotShowDropTarget()
{
if(!m_dropItem) {
qCCritical(JUK_LOG) << "Trying to show the playlist of a null item!\n";
return;
}
raise(m_dropItem->playlist());
if(m_dropItem) raise(m_dropItem->playlist());
}
void PlaylistBox::slotAddItem(const QString &tag, unsigned column)
......@@ -543,6 +540,24 @@ void PlaylistBox::setSingleItem(QTreeWidgetItem *item)
setSelectionMode(QAbstractItemView::ExtendedSelection);
}
void PlaylistBox::dragMoveEvent(QDragMoveEvent* event)
{
QTreeWidget::dragMoveEvent(event);
Item* hovered_item = static_cast<Item*>(itemAt(event->pos()));
if(hovered_item != m_dropItem){
m_dropItem = hovered_item;
if(m_dropItem) m_showTimer->start();
else m_showTimer->stop();
};
}
void PlaylistBox::dragLeaveEvent(QDragLeaveEvent* event)
{
QTreeWidget::dragLeaveEvent(event);
m_showTimer->stop();
}
////////////////////////////////////////////////////////////////////////////////
// PlaylistBox private slots
////////////////////////////////////////////////////////////////////////////////
......
......@@ -109,6 +109,8 @@ private:
void setupUpcomingPlaylist();
int viewModeIndex() const { return m_viewModeIndex; }
ViewMode *viewMode() const { return m_viewModes[m_viewModeIndex]; }
void dragMoveEvent(QDragMoveEvent *event) override;
void dragLeaveEvent(QDragLeaveEvent *event) override;
private slots:
/**
......
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