mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-20 07:49:42 +01: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:
parent
d6bf6744d8
commit
0c47327fc4
@ -33,6 +33,7 @@ using namespace Tomahawk;
|
||||
QueueView::QueueView( AnimatedSplitter* parent )
|
||||
: AnimatedWidget( parent )
|
||||
, ui( new Ui::QueueView )
|
||||
, m_dragTimer( 0 )
|
||||
{
|
||||
ui->setupUi( this );
|
||||
TomahawkUtils::unmarginLayout( layout() );
|
||||
@ -47,6 +48,8 @@ QueueView::QueueView( AnimatedSplitter* parent )
|
||||
ui->queue->overlay()->setEnabled( false );
|
||||
|
||||
connect( ui->toggleButton, SIGNAL( clicked() ), SLOT( show() ) );
|
||||
|
||||
ui->toggleButton->installEventFilter( this );
|
||||
}
|
||||
|
||||
|
||||
@ -62,6 +65,33 @@ QueueView::queue() const
|
||||
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
|
||||
QueueView::hide()
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#include "dllmacro.h"
|
||||
|
||||
class QTimer;
|
||||
class PlaylistView;
|
||||
|
||||
namespace Ui
|
||||
@ -44,6 +45,8 @@ public:
|
||||
|
||||
QSize sizeHint() const { return QSize( 0, 200 ); }
|
||||
|
||||
virtual bool eventFilter( QObject* , QEvent* );
|
||||
|
||||
public slots:
|
||||
virtual void onShown( QWidget*, bool animated );
|
||||
virtual void onHidden( QWidget*, bool animated );
|
||||
@ -53,6 +56,7 @@ public slots:
|
||||
|
||||
private:
|
||||
Ui::QueueView* ui;
|
||||
QTimer* m_dragTimer;
|
||||
};
|
||||
|
||||
#endif // QUEUEVIEW_H
|
||||
|
@ -34,6 +34,9 @@
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="acceptDrops">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Open Queue</string>
|
||||
</property>
|
||||
|
Loading…
x
Reference in New Issue
Block a user