Commit b5c46ea0 authored by Abdel-Rahman Abdel-Rahman's avatar Abdel-Rahman Abdel-Rahman
Browse files

Add timeout to switching playlists during drag and drop of tracks

parent 221b1068
......@@ -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)
......@@ -547,11 +544,19 @@ void PlaylistBox::dragMoveEvent(QDragMoveEvent* event)
{
QTreeWidget::dragMoveEvent(event);
QTreeWidgetItem* hovered_item = itemAt(event->pos());
if(hovered_item)
raise(static_cast<Item *>(hovered_item)->playlist());
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
......
......@@ -110,6 +110,7 @@ private:
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