mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-08 15:16:34 +02:00
Open the queue on a drag-hover after a short delay, to allow drag-to-add when it's closed
This commit is contained in:
@@ -33,6 +33,7 @@ using namespace Tomahawk;
|
|||||||
QueueView::QueueView( AnimatedSplitter* parent )
|
QueueView::QueueView( AnimatedSplitter* parent )
|
||||||
: AnimatedWidget( parent )
|
: AnimatedWidget( parent )
|
||||||
, ui( new Ui::QueueView )
|
, ui( new Ui::QueueView )
|
||||||
|
, m_dragTimer( 0 )
|
||||||
{
|
{
|
||||||
ui->setupUi( this );
|
ui->setupUi( this );
|
||||||
TomahawkUtils::unmarginLayout( layout() );
|
TomahawkUtils::unmarginLayout( layout() );
|
||||||
@@ -47,6 +48,8 @@ QueueView::QueueView( AnimatedSplitter* parent )
|
|||||||
ui->queue->overlay()->setEnabled( false );
|
ui->queue->overlay()->setEnabled( false );
|
||||||
|
|
||||||
connect( ui->toggleButton, SIGNAL( clicked() ), SLOT( show() ) );
|
connect( ui->toggleButton, SIGNAL( clicked() ), SLOT( show() ) );
|
||||||
|
|
||||||
|
ui->toggleButton->installEventFilter( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -62,6 +65,33 @@ QueueView::queue() const
|
|||||||
return ui->queue;
|
return ui->queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
QueueView::eventFilter( QObject* obj, QEvent* ev )
|
||||||
|
{
|
||||||
|
if ( obj == ui->toggleButton )
|
||||||
|
{
|
||||||
|
if ( ev->type() == QEvent::DragEnter )
|
||||||
|
{
|
||||||
|
ev->accept();
|
||||||
|
|
||||||
|
if ( m_dragTimer == 0 )
|
||||||
|
{
|
||||||
|
m_dragTimer = new QTimer( this );
|
||||||
|
m_dragTimer->setInterval( 1000 );
|
||||||
|
m_dragTimer->setSingleShot( true );
|
||||||
|
connect( m_dragTimer, SIGNAL( timeout() ), this, SLOT( show() ) );
|
||||||
|
m_dragTimer->start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( ev->type() == QEvent::DragLeave || ev->type() == QEvent::Drop )
|
||||||
|
{
|
||||||
|
delete m_dragTimer;
|
||||||
|
m_dragTimer = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return QObject::eventFilter( obj, ev );
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
QueueView::hide()
|
QueueView::hide()
|
||||||
|
@@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
#include "dllmacro.h"
|
#include "dllmacro.h"
|
||||||
|
|
||||||
|
class QTimer;
|
||||||
class PlaylistView;
|
class PlaylistView;
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui
|
||||||
@@ -44,6 +45,8 @@ public:
|
|||||||
|
|
||||||
QSize sizeHint() const { return QSize( 0, 200 ); }
|
QSize sizeHint() const { return QSize( 0, 200 ); }
|
||||||
|
|
||||||
|
virtual bool eventFilter( QObject* , QEvent* );
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void onShown( QWidget*, bool animated );
|
virtual void onShown( QWidget*, bool animated );
|
||||||
virtual void onHidden( QWidget*, bool animated );
|
virtual void onHidden( QWidget*, bool animated );
|
||||||
@@ -53,6 +56,7 @@ public slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::QueueView* ui;
|
Ui::QueueView* ui;
|
||||||
|
QTimer* m_dragTimer;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // QUEUEVIEW_H
|
#endif // QUEUEVIEW_H
|
||||||
|
@@ -34,6 +34,9 @@
|
|||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="acceptDrops">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Open Queue</string>
|
<string>Open Queue</string>
|
||||||
</property>
|
</property>
|
||||||
|
Reference in New Issue
Block a user