mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 14:16:32 +02:00
* Added new clicked-signals to QueryLabel and hooked them up to AudioControls.
This commit is contained in:
@@ -124,8 +124,9 @@ AudioControls::AudioControls( QWidget* parent )
|
|||||||
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() ) );
|
||||||
|
|
||||||
connect( ui->artistTrackLabel, SIGNAL( clicked() ), SLOT( onTrackClicked() ) );
|
connect( ui->artistTrackLabel, SIGNAL( clickedArtist() ), SLOT( onArtistClicked() ) );
|
||||||
connect( ui->albumLabel, SIGNAL( clicked() ), SLOT( onAlbumClicked() ) );
|
connect( ui->artistTrackLabel, SIGNAL( clickedTrack() ), SLOT( onTrackClicked() ) );
|
||||||
|
connect( ui->albumLabel, SIGNAL( clickedAlbum() ), SLOT( onAlbumClicked() ) );
|
||||||
|
|
||||||
// <From AudioEngine>
|
// <From AudioEngine>
|
||||||
connect( AudioEngine::instance(), SIGNAL( loading( Tomahawk::result_ptr ) ), SLOT( onPlaybackLoading( Tomahawk::result_ptr ) ) );
|
connect( AudioEngine::instance(), SIGNAL( loading( Tomahawk::result_ptr ) ), SLOT( onPlaybackLoading( Tomahawk::result_ptr ) ) );
|
||||||
@@ -413,9 +414,9 @@ AudioControls::onShuffleClicked()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AudioControls::onTrackClicked()
|
AudioControls::onArtistClicked()
|
||||||
{
|
{
|
||||||
PlaylistManager::instance()->showCurrentTrack();
|
PlaylistManager::instance()->show( m_currentTrack->artist() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -424,3 +425,10 @@ AudioControls::onAlbumClicked()
|
|||||||
{
|
{
|
||||||
PlaylistManager::instance()->show( m_currentTrack->album() );
|
PlaylistManager::instance()->show( m_currentTrack->album() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
AudioControls::onTrackClicked()
|
||||||
|
{
|
||||||
|
PlaylistManager::instance()->showCurrentTrack();
|
||||||
|
}
|
||||||
|
@@ -38,8 +38,10 @@ private slots:
|
|||||||
|
|
||||||
void onRepeatClicked();
|
void onRepeatClicked();
|
||||||
void onShuffleClicked();
|
void onShuffleClicked();
|
||||||
void onTrackClicked();
|
|
||||||
|
void onArtistClicked();
|
||||||
void onAlbumClicked();
|
void onAlbumClicked();
|
||||||
|
void onTrackClicked();
|
||||||
|
|
||||||
void onCoverArtDownloaded();
|
void onCoverArtDownloaded();
|
||||||
|
|
||||||
|
@@ -53,6 +53,7 @@ QueryLabel::~QueryLabel()
|
|||||||
void
|
void
|
||||||
QueryLabel::init()
|
QueryLabel::init()
|
||||||
{
|
{
|
||||||
|
m_hoverType = None;
|
||||||
setContentsMargins( 0, 0, 0, 0 );
|
setContentsMargins( 0, 0, 0, 0 );
|
||||||
setMouseTracking( true );
|
setMouseTracking( true );
|
||||||
|
|
||||||
@@ -247,6 +248,7 @@ void
|
|||||||
QueryLabel::updateLabel()
|
QueryLabel::updateLabel()
|
||||||
{
|
{
|
||||||
m_hoverArea = QRect();
|
m_hoverArea = QRect();
|
||||||
|
m_hoverType = None;
|
||||||
|
|
||||||
updateGeometry();
|
updateGeometry();
|
||||||
update();
|
update();
|
||||||
@@ -298,6 +300,7 @@ QueryLabel::paintEvent( QPaintEvent* event )
|
|||||||
{
|
{
|
||||||
m_hoverArea.setLeft( 0 );
|
m_hoverArea.setLeft( 0 );
|
||||||
m_hoverArea.setRight( fontMetrics().width( elidedText ) + contentsMargins().left() * 2 );
|
m_hoverArea.setRight( fontMetrics().width( elidedText ) + contentsMargins().left() * 2 );
|
||||||
|
m_hoverType = Track;
|
||||||
}
|
}
|
||||||
|
|
||||||
p.setPen( palette().mid().color() );
|
p.setPen( palette().mid().color() );
|
||||||
@@ -332,7 +335,7 @@ QueryLabel::paintEvent( QPaintEvent* event )
|
|||||||
p.setBrush( palette().window() );
|
p.setBrush( palette().window() );
|
||||||
p.setPen( palette().color( foregroundRole() ) );
|
p.setPen( palette().color( foregroundRole() ) );
|
||||||
|
|
||||||
if ( m_hoverArea.width() && m_hoverArea.left() + contentsMargins().left() == r.left() )
|
if ( m_hoverType == Artist )
|
||||||
{
|
{
|
||||||
p.setPen( palette().highlightedText().color() );
|
p.setPen( palette().highlightedText().color() );
|
||||||
p.setBrush( palette().highlight() );
|
p.setBrush( palette().highlight() );
|
||||||
@@ -351,7 +354,7 @@ QueryLabel::paintEvent( QPaintEvent* event )
|
|||||||
p.drawText( r, align, DASH );
|
p.drawText( r, align, DASH );
|
||||||
r.adjust( dashX, 0, 0, 0 );
|
r.adjust( dashX, 0, 0, 0 );
|
||||||
}
|
}
|
||||||
if ( m_hoverArea.width() && m_hoverArea.left() + contentsMargins().left() == r.left() )
|
if ( m_hoverType == Album )
|
||||||
{
|
{
|
||||||
p.setPen( palette().highlightedText().color() );
|
p.setPen( palette().highlightedText().color() );
|
||||||
p.setBrush( palette().highlight() );
|
p.setBrush( palette().highlight() );
|
||||||
@@ -370,7 +373,7 @@ QueryLabel::paintEvent( QPaintEvent* event )
|
|||||||
p.drawText( r, align, DASH );
|
p.drawText( r, align, DASH );
|
||||||
r.adjust( dashX, 0, 0, 0 );
|
r.adjust( dashX, 0, 0, 0 );
|
||||||
}
|
}
|
||||||
if ( m_hoverArea.width() && m_hoverArea.left() + contentsMargins().left() == r.left() )
|
if ( m_hoverType == Track )
|
||||||
{
|
{
|
||||||
p.setPen( palette().highlightedText().color() );
|
p.setPen( palette().highlightedText().color() );
|
||||||
p.setBrush( palette().highlight() );
|
p.setBrush( palette().highlight() );
|
||||||
@@ -417,7 +420,23 @@ QueryLabel::mouseReleaseEvent( QMouseEvent* event )
|
|||||||
|
|
||||||
m_dragPos = QPoint();
|
m_dragPos = QPoint();
|
||||||
if ( time.elapsed() < qApp->doubleClickInterval() )
|
if ( time.elapsed() < qApp->doubleClickInterval() )
|
||||||
emit clicked();
|
{
|
||||||
|
switch( m_hoverType )
|
||||||
|
{
|
||||||
|
case Artist:
|
||||||
|
emit clickedArtist();
|
||||||
|
break;
|
||||||
|
case Album:
|
||||||
|
emit clickedAlbum();
|
||||||
|
break;
|
||||||
|
case Track:
|
||||||
|
emit clickedTrack();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
emit clicked();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -438,6 +457,7 @@ QueryLabel::mouseMoveEvent( QMouseEvent* event )
|
|||||||
if ( m_query.isNull() && m_result.isNull() )
|
if ( m_query.isNull() && m_result.isNull() )
|
||||||
{
|
{
|
||||||
m_hoverArea = QRect();
|
m_hoverArea = QRect();
|
||||||
|
m_hoverType = None;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -464,19 +484,23 @@ QueryLabel::mouseMoveEvent( QMouseEvent* event )
|
|||||||
}
|
}
|
||||||
|
|
||||||
QRect hoverArea;
|
QRect hoverArea;
|
||||||
|
m_hoverType = None;
|
||||||
if ( m_type & Artist && x < artistX )
|
if ( m_type & Artist && x < artistX )
|
||||||
{
|
{
|
||||||
|
m_hoverType = Artist;
|
||||||
hoverArea.setLeft( 0 );
|
hoverArea.setLeft( 0 );
|
||||||
hoverArea.setRight( artistX + contentsMargins().left() );
|
hoverArea.setRight( artistX + contentsMargins().left() );
|
||||||
}
|
}
|
||||||
else if ( m_type & Album && x < albumX && x > artistX )
|
else if ( m_type & Album && x < albumX && x > artistX )
|
||||||
{
|
{
|
||||||
|
m_hoverType = Album;
|
||||||
int spacing = ( m_type & Artist ) ? dashX : 0;
|
int spacing = ( m_type & Artist ) ? dashX : 0;
|
||||||
hoverArea.setLeft( artistX + spacing );
|
hoverArea.setLeft( artistX + spacing );
|
||||||
hoverArea.setRight( albumX + spacing + contentsMargins().left() );
|
hoverArea.setRight( albumX + spacing + contentsMargins().left() );
|
||||||
}
|
}
|
||||||
else if ( m_type & Track && x < trackX && x > albumX )
|
else if ( m_type & Track && x < trackX && x > albumX )
|
||||||
{
|
{
|
||||||
|
m_hoverType = Track;
|
||||||
int spacing = ( m_type & Album ) ? dashX : 0;
|
int spacing = ( m_type & Album ) ? dashX : 0;
|
||||||
hoverArea.setLeft( albumX + spacing );
|
hoverArea.setLeft( albumX + spacing );
|
||||||
hoverArea.setRight( trackX + contentsMargins().left() );
|
hoverArea.setRight( trackX + contentsMargins().left() );
|
||||||
@@ -499,6 +523,7 @@ void
|
|||||||
QueryLabel::leaveEvent( QEvent* event )
|
QueryLabel::leaveEvent( QEvent* event )
|
||||||
{
|
{
|
||||||
m_hoverArea = QRect();
|
m_hoverArea = QRect();
|
||||||
|
m_hoverType = None;
|
||||||
repaint();
|
repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -15,6 +15,7 @@ Q_OBJECT
|
|||||||
public:
|
public:
|
||||||
enum DisplayType
|
enum DisplayType
|
||||||
{
|
{
|
||||||
|
None = 0,
|
||||||
Artist = 1,
|
Artist = 1,
|
||||||
Album = 2,
|
Album = 2,
|
||||||
Track = 4,
|
Track = 4,
|
||||||
@@ -60,6 +61,9 @@ public slots:
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
void clicked();
|
void clicked();
|
||||||
|
void clickedArtist();
|
||||||
|
void clickedAlbum();
|
||||||
|
void clickedTrack();
|
||||||
|
|
||||||
void textChanged( const QString& text );
|
void textChanged( const QString& text );
|
||||||
void resultChanged( const Tomahawk::result_ptr& result );
|
void resultChanged( const Tomahawk::result_ptr& result );
|
||||||
@@ -88,6 +92,7 @@ private:
|
|||||||
Qt::Alignment align;
|
Qt::Alignment align;
|
||||||
Qt::TextElideMode mode;
|
Qt::TextElideMode mode;
|
||||||
|
|
||||||
|
DisplayType m_hoverType;
|
||||||
QRect m_hoverArea;
|
QRect m_hoverArea;
|
||||||
QPoint m_dragPos;
|
QPoint m_dragPos;
|
||||||
QMargins m_textMargins;
|
QMargins m_textMargins;
|
||||||
|
Reference in New Issue
Block a user