1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-19 15:29:42 +01:00

* Fixed TWK-418: Context menu for now playing track.

This commit is contained in:
Christian Muehlhaeuser 2011-12-01 07:21:53 +01:00
parent 8fb15633d3
commit 793babcd12
8 changed files with 54 additions and 18 deletions

View File

@ -111,8 +111,8 @@ AudioControls::AudioControls( QWidget* parent )
connect( ui->volumeLowButton, SIGNAL( clicked() ), AudioEngine::instance(), SLOT( lowerVolume() ) );
connect( ui->volumeHighButton, SIGNAL( clicked() ), AudioEngine::instance(), SLOT( raiseVolume() ) );
connect( ui->playPauseButton, SIGNAL( clicked() ), this, SIGNAL( playPressed() ) );
connect( ui->pauseButton, SIGNAL( clicked() ), this, SIGNAL( pausePressed() ) );
connect( ui->playPauseButton, SIGNAL( clicked() ), SIGNAL( playPressed() ) );
connect( ui->pauseButton, SIGNAL( clicked() ), SIGNAL( pausePressed() ) );
connect( ui->repeatButton, SIGNAL( clicked() ), SLOT( onRepeatClicked() ) );
connect( ui->shuffleButton, SIGNAL( clicked() ), SLOT( onShuffleClicked() ) );
@ -208,11 +208,11 @@ AudioControls::onPlaybackStarted( const Tomahawk::result_ptr& result )
m_sliderTimeLine.setFrameRange( 0, duration );
m_sliderTimeLine.setCurrentTime( 0 );
m_seekMsecs = -1;
ui->seekSlider->setVisible( true );
m_noTimeChange = false;
Tomahawk::InfoSystem::InfoStringHash trackInfo;
trackInfo["artist"] = result->artist()->name();
trackInfo["album"] = result->album()->name();
@ -291,9 +291,10 @@ AudioControls::onPlaybackLoading( const Tomahawk::result_ptr& result )
result->loadSocialActions();
connect( result.data(), SIGNAL( socialActionsLoaded() ), this, SLOT( socialActionsLoaded() ) );
connect( result.data(), SIGNAL( socialActionsLoaded() ), SLOT( socialActionsLoaded() ) );
}
void
AudioControls::socialActionsLoaded()
{
@ -324,6 +325,7 @@ AudioControls::onPlaybackPaused()
m_sliderTimeLine.setPaused( true );
}
void
AudioControls::onPlaybackResumed()
{

View File

@ -39,8 +39,11 @@ ContextMenu::ContextMenu( QWidget* parent )
m_supportedActions = ActionPlay | ActionQueue | ActionCopyLink;
}
ContextMenu::~ContextMenu()
{}
{
}
void
ContextMenu::clear()
@ -50,23 +53,22 @@ ContextMenu::clear()
m_queries.clear();
m_albums.clear();
m_artists.clear();
}
unsigned int
ContextMenu::itemCount() const
{
return m_queries.count() + m_artists.count() + m_albums.count();
}
void
ContextMenu::setQueries( const QList<Tomahawk::query_ptr>& queries )
{
if ( queries.isEmpty() )
return;
QMenu::clear();
m_queries.clear();
m_queries << queries;
@ -87,11 +89,8 @@ ContextMenu::setQueries( const QList<Tomahawk::query_ptr>& queries )
if ( m_supportedActions & ActionDelete )
m_sigmap->setMapping( addAction( queries.count() > 1 ? tr( "&Delete Items" ) : tr( "&Delete Item" ) ), ActionDelete );
foreach ( QAction* action, actions() )
{
connect( action, SIGNAL( triggered() ), m_sigmap, SLOT( map() ) );
}
}
@ -107,7 +106,6 @@ ContextMenu::setQuery( const Tomahawk::query_ptr& query )
}
void
ContextMenu::setAlbums( const QList<Tomahawk::album_ptr>& albums )
{
@ -185,6 +183,7 @@ ContextMenu::setArtist( const Tomahawk::artist_ptr& artist )
setArtists( artists );
}
void
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 )
{

View File

@ -39,7 +39,6 @@ public:
ActionQueue = 2,
ActionDelete = 4,
ActionCopyLink = 8
};
explicit ContextMenu( QWidget* parent = 0 );

View File

@ -28,6 +28,7 @@
#include "dynamic/widgets/LoadingSpinner.h"
#include "widgets/overlaywidget.h"
#include "contextmenu.h"
#include "tomahawksettings.h"
#include "treeheader.h"
#include "treeitemdelegate.h"

View File

@ -23,12 +23,16 @@
#include <QTreeView>
#include <QTimer>
#include "contextmenu.h"
#include "treeproxymodel.h"
#include "viewpage.h"
#include "dllmacro.h"
namespace Tomahawk
{
class ContextMenu;
};
class TreeHeader;
class LoadingSpinner;
class OverlayWidget;

View File

@ -149,7 +149,7 @@ PlaylistModel::append( const Tomahawk::album_ptr& album )
return;
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 )
{
@ -169,7 +169,7 @@ PlaylistModel::append( const Tomahawk::artist_ptr& artist )
return;
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 )
{

View File

@ -27,12 +27,15 @@
#include "artist.h"
#include "album.h"
#include "query.h"
#include "contextmenu.h"
#include "utils/tomahawkutilsgui.h"
#include "utils/logger.h"
#define BOXMARGIN 2
#define DASH " - "
using namespace Tomahawk;
QueryLabel::QueryLabel( QWidget* parent, Qt::WindowFlags flags )
: QFrame( parent, flags )
@ -76,6 +79,9 @@ QueryLabel::~QueryLabel()
void
QueryLabel::init()
{
m_contextMenu = new ContextMenu( this );
m_contextMenu->setSupportedActions( ContextMenu::ActionQueue | ContextMenu::ActionCopyLink );
m_hoverType = None;
setContentsMargins( 0, 0, 0, 0 );
setMouseTracking( true );
@ -250,6 +256,7 @@ QueryLabel::setAlignment( Qt::Alignment alignment )
}
}
void
QueryLabel::setTextPen( const QPen & pen )
{
@ -257,12 +264,14 @@ QueryLabel::setTextPen( const QPen & pen )
m_textPen = pen;
}
QPen
QueryLabel::textPen() const
{
return m_textPen;
}
Qt::TextElideMode
QueryLabel::elideMode() const
{
@ -280,12 +289,14 @@ QueryLabel::setElideMode( Qt::TextElideMode mode )
}
}
QFont
QueryLabel::font() const
{
return m_font;
}
void
QueryLabel::setFont( const QFont& font )
{
@ -304,6 +315,7 @@ QueryLabel::updateLabel()
update();
}
void
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
QueryLabel::mousePressEvent( QMouseEvent* event )
{

View File

@ -28,6 +28,11 @@
#include "typedefs.h"
#include "dllmacro.h"
namespace Tomahawk
{
class ContextMenu;
};
class DLLEXPORT QueryLabel : public QFrame
{
Q_OBJECT
@ -98,6 +103,8 @@ signals:
void queryChanged( const Tomahawk::query_ptr& query );
protected:
virtual void contextMenuEvent( QContextMenuEvent* event );
virtual void mousePressEvent( QMouseEvent* event );
virtual void mouseReleaseEvent( QMouseEvent* event );
virtual void mouseMoveEvent( QMouseEvent* event );
@ -117,6 +124,8 @@ private:
Tomahawk::result_ptr m_result;
Tomahawk::query_ptr m_query;
Tomahawk::ContextMenu* m_contextMenu;
Qt::Alignment m_align;
Qt::TextElideMode m_mode;