mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-14 01:54:07 +02:00
* Fixed TWK-418: Context menu for now playing track.
This commit is contained in:
@@ -111,8 +111,8 @@ AudioControls::AudioControls( QWidget* parent )
|
|||||||
connect( ui->volumeLowButton, SIGNAL( clicked() ), AudioEngine::instance(), SLOT( lowerVolume() ) );
|
connect( ui->volumeLowButton, SIGNAL( clicked() ), AudioEngine::instance(), SLOT( lowerVolume() ) );
|
||||||
connect( ui->volumeHighButton, SIGNAL( clicked() ), AudioEngine::instance(), SLOT( raiseVolume() ) );
|
connect( ui->volumeHighButton, SIGNAL( clicked() ), AudioEngine::instance(), SLOT( raiseVolume() ) );
|
||||||
|
|
||||||
connect( ui->playPauseButton, SIGNAL( clicked() ), this, SIGNAL( playPressed() ) );
|
connect( ui->playPauseButton, SIGNAL( clicked() ), SIGNAL( playPressed() ) );
|
||||||
connect( ui->pauseButton, SIGNAL( clicked() ), this, SIGNAL( pausePressed() ) );
|
connect( ui->pauseButton, SIGNAL( clicked() ), SIGNAL( pausePressed() ) );
|
||||||
|
|
||||||
connect( ui->repeatButton, SIGNAL( clicked() ), SLOT( onRepeatClicked() ) );
|
connect( ui->repeatButton, SIGNAL( clicked() ), SLOT( onRepeatClicked() ) );
|
||||||
connect( ui->shuffleButton, SIGNAL( clicked() ), SLOT( onShuffleClicked() ) );
|
connect( ui->shuffleButton, SIGNAL( clicked() ), SLOT( onShuffleClicked() ) );
|
||||||
@@ -291,9 +291,10 @@ AudioControls::onPlaybackLoading( const Tomahawk::result_ptr& result )
|
|||||||
|
|
||||||
result->loadSocialActions();
|
result->loadSocialActions();
|
||||||
|
|
||||||
connect( result.data(), SIGNAL( socialActionsLoaded() ), this, SLOT( socialActionsLoaded() ) );
|
connect( result.data(), SIGNAL( socialActionsLoaded() ), SLOT( socialActionsLoaded() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AudioControls::socialActionsLoaded()
|
AudioControls::socialActionsLoaded()
|
||||||
{
|
{
|
||||||
@@ -324,6 +325,7 @@ AudioControls::onPlaybackPaused()
|
|||||||
m_sliderTimeLine.setPaused( true );
|
m_sliderTimeLine.setPaused( true );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AudioControls::onPlaybackResumed()
|
AudioControls::onPlaybackResumed()
|
||||||
{
|
{
|
||||||
|
@@ -39,8 +39,11 @@ ContextMenu::ContextMenu( QWidget* parent )
|
|||||||
m_supportedActions = ActionPlay | ActionQueue | ActionCopyLink;
|
m_supportedActions = ActionPlay | ActionQueue | ActionCopyLink;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ContextMenu::~ContextMenu()
|
ContextMenu::~ContextMenu()
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ContextMenu::clear()
|
ContextMenu::clear()
|
||||||
@@ -50,23 +53,22 @@ ContextMenu::clear()
|
|||||||
m_queries.clear();
|
m_queries.clear();
|
||||||
m_albums.clear();
|
m_albums.clear();
|
||||||
m_artists.clear();
|
m_artists.clear();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
unsigned int
|
unsigned int
|
||||||
ContextMenu::itemCount() const
|
ContextMenu::itemCount() const
|
||||||
{
|
{
|
||||||
return m_queries.count() + m_artists.count() + m_albums.count();
|
return m_queries.count() + m_artists.count() + m_albums.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ContextMenu::setQueries( const QList<Tomahawk::query_ptr>& queries )
|
ContextMenu::setQueries( const QList<Tomahawk::query_ptr>& queries )
|
||||||
{
|
{
|
||||||
|
|
||||||
if ( queries.isEmpty() )
|
if ( queries.isEmpty() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
QMenu::clear();
|
QMenu::clear();
|
||||||
m_queries.clear();
|
m_queries.clear();
|
||||||
m_queries << queries;
|
m_queries << queries;
|
||||||
@@ -87,11 +89,8 @@ ContextMenu::setQueries( const QList<Tomahawk::query_ptr>& queries )
|
|||||||
if ( m_supportedActions & ActionDelete )
|
if ( m_supportedActions & ActionDelete )
|
||||||
m_sigmap->setMapping( addAction( queries.count() > 1 ? tr( "&Delete Items" ) : tr( "&Delete Item" ) ), ActionDelete );
|
m_sigmap->setMapping( addAction( queries.count() > 1 ? tr( "&Delete Items" ) : tr( "&Delete Item" ) ), ActionDelete );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
foreach ( QAction* action, actions() )
|
foreach ( QAction* action, actions() )
|
||||||
{
|
{
|
||||||
|
|
||||||
connect( action, SIGNAL( triggered() ), m_sigmap, SLOT( map() ) );
|
connect( action, SIGNAL( triggered() ), m_sigmap, SLOT( map() ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -107,7 +106,6 @@ ContextMenu::setQuery( const Tomahawk::query_ptr& query )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ContextMenu::setAlbums( const QList<Tomahawk::album_ptr>& albums )
|
ContextMenu::setAlbums( const QList<Tomahawk::album_ptr>& albums )
|
||||||
{
|
{
|
||||||
@@ -185,6 +183,7 @@ ContextMenu::setArtist( const Tomahawk::artist_ptr& artist )
|
|||||||
setArtists( artists );
|
setArtists( artists );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ContextMenu::onTriggered( int action )
|
ContextMenu::onTriggered( int action )
|
||||||
{
|
{
|
||||||
@@ -205,7 +204,8 @@ ContextMenu::onTriggered( int action )
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ContextMenu::addToQueue()
|
void
|
||||||
|
ContextMenu::addToQueue()
|
||||||
{
|
{
|
||||||
foreach ( const query_ptr& query, m_queries )
|
foreach ( const query_ptr& query, m_queries )
|
||||||
{
|
{
|
||||||
|
@@ -39,7 +39,6 @@ public:
|
|||||||
ActionQueue = 2,
|
ActionQueue = 2,
|
||||||
ActionDelete = 4,
|
ActionDelete = 4,
|
||||||
ActionCopyLink = 8
|
ActionCopyLink = 8
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit ContextMenu( QWidget* parent = 0 );
|
explicit ContextMenu( QWidget* parent = 0 );
|
||||||
|
@@ -28,6 +28,7 @@
|
|||||||
#include "dynamic/widgets/LoadingSpinner.h"
|
#include "dynamic/widgets/LoadingSpinner.h"
|
||||||
#include "widgets/overlaywidget.h"
|
#include "widgets/overlaywidget.h"
|
||||||
|
|
||||||
|
#include "contextmenu.h"
|
||||||
#include "tomahawksettings.h"
|
#include "tomahawksettings.h"
|
||||||
#include "treeheader.h"
|
#include "treeheader.h"
|
||||||
#include "treeitemdelegate.h"
|
#include "treeitemdelegate.h"
|
||||||
|
@@ -23,12 +23,16 @@
|
|||||||
#include <QTreeView>
|
#include <QTreeView>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
#include "contextmenu.h"
|
|
||||||
#include "treeproxymodel.h"
|
#include "treeproxymodel.h"
|
||||||
#include "viewpage.h"
|
#include "viewpage.h"
|
||||||
|
|
||||||
#include "dllmacro.h"
|
#include "dllmacro.h"
|
||||||
|
|
||||||
|
namespace Tomahawk
|
||||||
|
{
|
||||||
|
class ContextMenu;
|
||||||
|
};
|
||||||
|
|
||||||
class TreeHeader;
|
class TreeHeader;
|
||||||
class LoadingSpinner;
|
class LoadingSpinner;
|
||||||
class OverlayWidget;
|
class OverlayWidget;
|
||||||
|
@@ -149,7 +149,7 @@ PlaylistModel::append( const Tomahawk::album_ptr& album )
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
connect( album.data(), SIGNAL( tracksAdded( QList<Tomahawk::query_ptr> ) ),
|
connect( album.data(), SIGNAL( tracksAdded( QList<Tomahawk::query_ptr> ) ),
|
||||||
SLOT( onTracksAdded( QList<Tomahawk::query_ptr> ) ) );
|
SLOT( append( QList<Tomahawk::query_ptr> ) ) );
|
||||||
|
|
||||||
if ( rowCount( QModelIndex() ) == 0 )
|
if ( rowCount( QModelIndex() ) == 0 )
|
||||||
{
|
{
|
||||||
@@ -169,7 +169,7 @@ PlaylistModel::append( const Tomahawk::artist_ptr& artist )
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
connect( artist.data(), SIGNAL( tracksAdded( QList<Tomahawk::query_ptr> ) ),
|
connect( artist.data(), SIGNAL( tracksAdded( QList<Tomahawk::query_ptr> ) ),
|
||||||
SLOT( onTracksAdded( QList<Tomahawk::query_ptr> ) ) );
|
SLOT( append( QList<Tomahawk::query_ptr> ) ) );
|
||||||
|
|
||||||
if ( rowCount( QModelIndex() ) == 0 )
|
if ( rowCount( QModelIndex() ) == 0 )
|
||||||
{
|
{
|
||||||
|
@@ -27,12 +27,15 @@
|
|||||||
#include "artist.h"
|
#include "artist.h"
|
||||||
#include "album.h"
|
#include "album.h"
|
||||||
#include "query.h"
|
#include "query.h"
|
||||||
|
#include "contextmenu.h"
|
||||||
#include "utils/tomahawkutilsgui.h"
|
#include "utils/tomahawkutilsgui.h"
|
||||||
#include "utils/logger.h"
|
#include "utils/logger.h"
|
||||||
|
|
||||||
#define BOXMARGIN 2
|
#define BOXMARGIN 2
|
||||||
#define DASH " - "
|
#define DASH " - "
|
||||||
|
|
||||||
|
using namespace Tomahawk;
|
||||||
|
|
||||||
|
|
||||||
QueryLabel::QueryLabel( QWidget* parent, Qt::WindowFlags flags )
|
QueryLabel::QueryLabel( QWidget* parent, Qt::WindowFlags flags )
|
||||||
: QFrame( parent, flags )
|
: QFrame( parent, flags )
|
||||||
@@ -76,6 +79,9 @@ QueryLabel::~QueryLabel()
|
|||||||
void
|
void
|
||||||
QueryLabel::init()
|
QueryLabel::init()
|
||||||
{
|
{
|
||||||
|
m_contextMenu = new ContextMenu( this );
|
||||||
|
m_contextMenu->setSupportedActions( ContextMenu::ActionQueue | ContextMenu::ActionCopyLink );
|
||||||
|
|
||||||
m_hoverType = None;
|
m_hoverType = None;
|
||||||
setContentsMargins( 0, 0, 0, 0 );
|
setContentsMargins( 0, 0, 0, 0 );
|
||||||
setMouseTracking( true );
|
setMouseTracking( true );
|
||||||
@@ -250,6 +256,7 @@ QueryLabel::setAlignment( Qt::Alignment alignment )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
QueryLabel::setTextPen( const QPen & pen )
|
QueryLabel::setTextPen( const QPen & pen )
|
||||||
{
|
{
|
||||||
@@ -257,12 +264,14 @@ QueryLabel::setTextPen( const QPen & pen )
|
|||||||
m_textPen = pen;
|
m_textPen = pen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QPen
|
QPen
|
||||||
QueryLabel::textPen() const
|
QueryLabel::textPen() const
|
||||||
{
|
{
|
||||||
return m_textPen;
|
return m_textPen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Qt::TextElideMode
|
Qt::TextElideMode
|
||||||
QueryLabel::elideMode() const
|
QueryLabel::elideMode() const
|
||||||
{
|
{
|
||||||
@@ -280,12 +289,14 @@ QueryLabel::setElideMode( Qt::TextElideMode mode )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QFont
|
QFont
|
||||||
QueryLabel::font() const
|
QueryLabel::font() const
|
||||||
{
|
{
|
||||||
return m_font;
|
return m_font;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
QueryLabel::setFont( const QFont& font )
|
QueryLabel::setFont( const QFont& font )
|
||||||
{
|
{
|
||||||
@@ -304,6 +315,7 @@ QueryLabel::updateLabel()
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
QueryLabel::setExtraContentsMargins( int left, int top, int right, int bottom )
|
QueryLabel::setExtraContentsMargins( int left, int top, int right, int bottom )
|
||||||
{
|
{
|
||||||
@@ -476,6 +488,15 @@ QueryLabel::changeEvent( QEvent* event )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
QueryLabel::contextMenuEvent( QContextMenuEvent* event )
|
||||||
|
{
|
||||||
|
m_contextMenu->clear();
|
||||||
|
m_contextMenu->setQuery( m_query );
|
||||||
|
m_contextMenu->exec( event->globalPos() );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
QueryLabel::mousePressEvent( QMouseEvent* event )
|
QueryLabel::mousePressEvent( QMouseEvent* event )
|
||||||
{
|
{
|
||||||
|
@@ -28,6 +28,11 @@
|
|||||||
#include "typedefs.h"
|
#include "typedefs.h"
|
||||||
#include "dllmacro.h"
|
#include "dllmacro.h"
|
||||||
|
|
||||||
|
namespace Tomahawk
|
||||||
|
{
|
||||||
|
class ContextMenu;
|
||||||
|
};
|
||||||
|
|
||||||
class DLLEXPORT QueryLabel : public QFrame
|
class DLLEXPORT QueryLabel : public QFrame
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -98,6 +103,8 @@ signals:
|
|||||||
void queryChanged( const Tomahawk::query_ptr& query );
|
void queryChanged( const Tomahawk::query_ptr& query );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
virtual void contextMenuEvent( QContextMenuEvent* event );
|
||||||
|
|
||||||
virtual void mousePressEvent( QMouseEvent* event );
|
virtual void mousePressEvent( QMouseEvent* event );
|
||||||
virtual void mouseReleaseEvent( QMouseEvent* event );
|
virtual void mouseReleaseEvent( QMouseEvent* event );
|
||||||
virtual void mouseMoveEvent( QMouseEvent* event );
|
virtual void mouseMoveEvent( QMouseEvent* event );
|
||||||
@@ -117,6 +124,8 @@ private:
|
|||||||
Tomahawk::result_ptr m_result;
|
Tomahawk::result_ptr m_result;
|
||||||
Tomahawk::query_ptr m_query;
|
Tomahawk::query_ptr m_query;
|
||||||
|
|
||||||
|
Tomahawk::ContextMenu* m_contextMenu;
|
||||||
|
|
||||||
Qt::Alignment m_align;
|
Qt::Alignment m_align;
|
||||||
Qt::TextElideMode m_mode;
|
Qt::TextElideMode m_mode;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user