mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-07 14:46:33 +02:00
completed dropmenu in audio controls area
This commit is contained in:
@@ -162,6 +162,7 @@ AudioControls::AudioControls( QWidget* parent )
|
|||||||
connect( &m_dropAreaCollapseTimer, SIGNAL( timeout() ), this, SLOT( collapseDropMenu() ) );
|
connect( &m_dropAreaCollapseTimer, SIGNAL( timeout() ), this, SLOT( collapseDropMenu() ) );
|
||||||
|
|
||||||
connect( ui->metaDataDropArea, SIGNAL( dropReceived( QDropEvent* ) ), this, SLOT( dropReceived( QDropEvent* ) ) );
|
connect( ui->metaDataDropArea, SIGNAL( dropReceived( QDropEvent* ) ), this, SLOT( dropReceived( QDropEvent* ) ) );
|
||||||
|
connect( ui->metaDataDropArea, SIGNAL( mouseLeft() ), &m_dropAreaCollapseTimer, SLOT( start() ) );
|
||||||
|
|
||||||
DropMenuEntry *trackEntry = new DropMenuEntry( QPixmap(":/data/images/drop-song.png" ).scaledToWidth( 32, Qt::SmoothTransformation ),
|
DropMenuEntry *trackEntry = new DropMenuEntry( QPixmap(":/data/images/drop-song.png" ).scaledToWidth( 32, Qt::SmoothTransformation ),
|
||||||
"Track",
|
"Track",
|
||||||
@@ -611,6 +612,21 @@ AudioControls::dragEnterEvent( QDragEnterEvent* e )
|
|||||||
|
|
||||||
m_dropAreaCollapseTimer.stop();
|
m_dropAreaCollapseTimer.stop();
|
||||||
|
|
||||||
|
DropJob::DropFlags flags = DropJob::DropFlagsNone;
|
||||||
|
|
||||||
|
if ( e->mimeData()->hasFormat( "application/tomahawk.query.list" )
|
||||||
|
|| e->mimeData()->hasFormat( "application/tomahawk.result.list" )
|
||||||
|
|| e->mimeData()->hasFormat( "application/tomahawk.result" ) )
|
||||||
|
flags = DropJob::DropFlagsAll;
|
||||||
|
|
||||||
|
if ( e->mimeData()->hasFormat( "application/tomahawk.metadata.album" ) )
|
||||||
|
flags = DropJob::DropFlagAlbum | DropJob::DropFlagArtist | DropJob::DropFlagLocal | DropJob::DropFlagTop10;
|
||||||
|
|
||||||
|
if ( e->mimeData()->hasFormat( "application/tomahawk.metadata.artist" ) )
|
||||||
|
flags = DropJob::DropFlagArtist | DropJob::DropFlagLocal | DropJob::DropFlagTop10;
|
||||||
|
|
||||||
|
ui->metaDataDropArea->setFilter( flags );
|
||||||
|
|
||||||
if( !m_dropAreaExpanded )
|
if( !m_dropAreaExpanded )
|
||||||
{
|
{
|
||||||
m_dragAnimation->stop();
|
m_dragAnimation->stop();
|
||||||
@@ -635,6 +651,7 @@ AudioControls::dragMoveEvent( QDragMoveEvent* /* e */ )
|
|||||||
void
|
void
|
||||||
AudioControls::dragLeaveEvent( QDragLeaveEvent * )
|
AudioControls::dragLeaveEvent( QDragLeaveEvent * )
|
||||||
{
|
{
|
||||||
|
qDebug() << "******************************** dragLeaveEvent" << ui->metaDataDropArea->hovered();
|
||||||
if( !ui->metaDataDropArea->hovered() )
|
if( !ui->metaDataDropArea->hovered() )
|
||||||
m_dropAreaCollapseTimer.start();
|
m_dropAreaCollapseTimer.start();
|
||||||
}
|
}
|
||||||
@@ -643,6 +660,10 @@ AudioControls::dragLeaveEvent( QDragLeaveEvent * )
|
|||||||
void
|
void
|
||||||
AudioControls::collapseDropMenu()
|
AudioControls::collapseDropMenu()
|
||||||
{
|
{
|
||||||
|
// Check if the menu is hovered now...
|
||||||
|
if( ui->metaDataDropArea->hovered() )
|
||||||
|
return;
|
||||||
|
|
||||||
m_dropAreaExpanded = false;
|
m_dropAreaExpanded = false;
|
||||||
|
|
||||||
m_dragAnimation->stop();
|
m_dragAnimation->stop();
|
||||||
|
@@ -32,6 +32,17 @@ DropMenu::addEntry( DropMenuEntry *entry, bool isDefault )
|
|||||||
m_defaultEntry = entry;
|
m_defaultEntry = entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
DropMenu::setFilter(DropJob::DropFlags shownEntries)
|
||||||
|
{
|
||||||
|
foreach( DropMenuEntry *entry, m_entries )
|
||||||
|
{
|
||||||
|
if( ( entry->dropFlags() & shownEntries ) != DropJob::DropFlagsNone )
|
||||||
|
entry->setVisible( true );
|
||||||
|
else
|
||||||
|
entry->setVisible( false );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
DropMenu::hovered() const
|
DropMenu::hovered() const
|
||||||
@@ -67,6 +78,7 @@ DropMenu::entryLeft( DropMenuEntry *entry )
|
|||||||
entry->setActive( false );
|
entry->setActive( false );
|
||||||
m_defaultEntry->setActive( true );
|
m_defaultEntry->setActive( true );
|
||||||
m_activeEntry = m_defaultEntry;
|
m_activeEntry = m_defaultEntry;
|
||||||
|
emit mouseLeft();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -18,6 +18,8 @@ public:
|
|||||||
|
|
||||||
void addEntry( DropMenuEntry *entry, bool isDefault = false );
|
void addEntry( DropMenuEntry *entry, bool isDefault = false );
|
||||||
|
|
||||||
|
void setFilter( DropJob::DropFlags shownEntries );
|
||||||
|
|
||||||
|
|
||||||
/** @brief Returns true if the mouse is somewhere over the contained entries */
|
/** @brief Returns true if the mouse is somewhere over the contained entries */
|
||||||
bool hovered() const;
|
bool hovered() const;
|
||||||
@@ -26,6 +28,7 @@ public:
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
void dropReceived( QDropEvent *event );
|
void dropReceived( QDropEvent *event );
|
||||||
|
void mouseLeft();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void entryHovered( DropMenuEntry* entry );
|
void entryHovered( DropMenuEntry* entry );
|
||||||
|
Reference in New Issue
Block a user