mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-24 09:49:42 +01:00
* Added context menu to PlayableCover.
This commit is contained in:
parent
41da9c8a4e
commit
8ff04a8341
@ -20,6 +20,7 @@
|
||||
|
||||
#include "Artist.h"
|
||||
#include "Album.h"
|
||||
#include "ContextMenu.h"
|
||||
#include "ViewManager.h"
|
||||
#include "audio/AudioEngine.h"
|
||||
#include "widgets/ImageButton.h"
|
||||
@ -28,6 +29,7 @@
|
||||
|
||||
#include <QPainter>
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
PlayableCover::PlayableCover( QWidget* parent )
|
||||
: QLabel( parent )
|
||||
@ -45,6 +47,9 @@ PlayableCover::PlayableCover( QWidget* parent )
|
||||
m_button->hide();
|
||||
|
||||
connect( m_button, SIGNAL( clicked( bool ) ), SLOT( onClicked() ) );
|
||||
|
||||
m_contextMenu = new ContextMenu( this );
|
||||
m_contextMenu->setSupportedActions( ContextMenu::ActionQueue | ContextMenu::ActionCopyLink | ContextMenu::ActionStopAfter | ContextMenu::ActionLove | ContextMenu::ActionPage );
|
||||
}
|
||||
|
||||
|
||||
@ -129,6 +134,22 @@ PlayableCover::mouseReleaseEvent( QMouseEvent* event )
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PlayableCover::contextMenuEvent( QContextMenuEvent* event )
|
||||
{
|
||||
m_contextMenu->clear();
|
||||
|
||||
if ( m_artist )
|
||||
m_contextMenu->setArtist( m_artist );
|
||||
else if ( m_album )
|
||||
m_contextMenu->setAlbum( m_album );
|
||||
else
|
||||
m_contextMenu->setQuery( m_query );
|
||||
|
||||
m_contextMenu->exec( event->globalPos() );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PlayableCover::setPixmap( const QPixmap& pixmap )
|
||||
{
|
||||
|
@ -28,6 +28,11 @@
|
||||
|
||||
class ImageButton;
|
||||
|
||||
namespace Tomahawk
|
||||
{
|
||||
class ContextMenu;
|
||||
};
|
||||
|
||||
/**
|
||||
* \class PlayableCover
|
||||
* \brief QLabel which shows a play/pause button on hovering.
|
||||
@ -58,6 +63,8 @@ protected:
|
||||
|
||||
virtual void mouseMoveEvent( QMouseEvent* event );
|
||||
virtual void mouseReleaseEvent( QMouseEvent* event );
|
||||
|
||||
virtual void contextMenuEvent( QContextMenuEvent* event );
|
||||
|
||||
void leaveEvent( QEvent* event );
|
||||
void enterEvent( QEvent* event );
|
||||
@ -69,6 +76,8 @@ private:
|
||||
QPixmap m_pixmap;
|
||||
|
||||
ImageButton* m_button;
|
||||
Tomahawk::ContextMenu* m_contextMenu;
|
||||
|
||||
Tomahawk::artist_ptr m_artist;
|
||||
Tomahawk::album_ptr m_album;
|
||||
Tomahawk::query_ptr m_query;
|
||||
|
Loading…
x
Reference in New Issue
Block a user