mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-07-31 11:20:22 +02:00
* Added context menu to PlayableCover.
This commit is contained in:
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "Artist.h"
|
#include "Artist.h"
|
||||||
#include "Album.h"
|
#include "Album.h"
|
||||||
|
#include "ContextMenu.h"
|
||||||
#include "ViewManager.h"
|
#include "ViewManager.h"
|
||||||
#include "audio/AudioEngine.h"
|
#include "audio/AudioEngine.h"
|
||||||
#include "widgets/ImageButton.h"
|
#include "widgets/ImageButton.h"
|
||||||
@@ -28,6 +29,7 @@
|
|||||||
|
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
|
using namespace Tomahawk;
|
||||||
|
|
||||||
PlayableCover::PlayableCover( QWidget* parent )
|
PlayableCover::PlayableCover( QWidget* parent )
|
||||||
: QLabel( parent )
|
: QLabel( parent )
|
||||||
@@ -45,6 +47,9 @@ PlayableCover::PlayableCover( QWidget* parent )
|
|||||||
m_button->hide();
|
m_button->hide();
|
||||||
|
|
||||||
connect( m_button, SIGNAL( clicked( bool ) ), SLOT( onClicked() ) );
|
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
|
void
|
||||||
PlayableCover::setPixmap( const QPixmap& pixmap )
|
PlayableCover::setPixmap( const QPixmap& pixmap )
|
||||||
{
|
{
|
||||||
|
@@ -28,6 +28,11 @@
|
|||||||
|
|
||||||
class ImageButton;
|
class ImageButton;
|
||||||
|
|
||||||
|
namespace Tomahawk
|
||||||
|
{
|
||||||
|
class ContextMenu;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \class PlayableCover
|
* \class PlayableCover
|
||||||
* \brief QLabel which shows a play/pause button on hovering.
|
* \brief QLabel which shows a play/pause button on hovering.
|
||||||
@@ -58,6 +63,8 @@ protected:
|
|||||||
|
|
||||||
virtual void mouseMoveEvent( QMouseEvent* event );
|
virtual void mouseMoveEvent( QMouseEvent* event );
|
||||||
virtual void mouseReleaseEvent( QMouseEvent* event );
|
virtual void mouseReleaseEvent( QMouseEvent* event );
|
||||||
|
|
||||||
|
virtual void contextMenuEvent( QContextMenuEvent* event );
|
||||||
|
|
||||||
void leaveEvent( QEvent* event );
|
void leaveEvent( QEvent* event );
|
||||||
void enterEvent( QEvent* event );
|
void enterEvent( QEvent* event );
|
||||||
@@ -69,6 +76,8 @@ private:
|
|||||||
QPixmap m_pixmap;
|
QPixmap m_pixmap;
|
||||||
|
|
||||||
ImageButton* m_button;
|
ImageButton* m_button;
|
||||||
|
Tomahawk::ContextMenu* m_contextMenu;
|
||||||
|
|
||||||
Tomahawk::artist_ptr m_artist;
|
Tomahawk::artist_ptr m_artist;
|
||||||
Tomahawk::album_ptr m_album;
|
Tomahawk::album_ptr m_album;
|
||||||
Tomahawk::query_ptr m_query;
|
Tomahawk::query_ptr m_query;
|
||||||
|
Reference in New Issue
Block a user