mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-01 11:50:37 +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->shuffleButton, SIGNAL( clicked() ), SLOT( onShuffleClicked() ) );
|
||||
|
||||
connect( ui->artistTrackLabel, SIGNAL( clicked() ), SLOT( onTrackClicked() ) );
|
||||
connect( ui->albumLabel, SIGNAL( clicked() ), SLOT( onAlbumClicked() ) );
|
||||
connect( ui->artistTrackLabel, SIGNAL( clickedArtist() ), SLOT( onArtistClicked() ) );
|
||||
connect( ui->artistTrackLabel, SIGNAL( clickedTrack() ), SLOT( onTrackClicked() ) );
|
||||
connect( ui->albumLabel, SIGNAL( clickedAlbum() ), SLOT( onAlbumClicked() ) );
|
||||
|
||||
// <From AudioEngine>
|
||||
connect( AudioEngine::instance(), SIGNAL( loading( Tomahawk::result_ptr ) ), SLOT( onPlaybackLoading( Tomahawk::result_ptr ) ) );
|
||||
@@ -413,9 +414,9 @@ AudioControls::onShuffleClicked()
|
||||
|
||||
|
||||
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() );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AudioControls::onTrackClicked()
|
||||
{
|
||||
PlaylistManager::instance()->showCurrentTrack();
|
||||
}
|
||||
|
@@ -38,8 +38,10 @@ private slots:
|
||||
|
||||
void onRepeatClicked();
|
||||
void onShuffleClicked();
|
||||
void onTrackClicked();
|
||||
|
||||
void onArtistClicked();
|
||||
void onAlbumClicked();
|
||||
void onTrackClicked();
|
||||
|
||||
void onCoverArtDownloaded();
|
||||
|
||||
|
@@ -53,6 +53,7 @@ QueryLabel::~QueryLabel()
|
||||
void
|
||||
QueryLabel::init()
|
||||
{
|
||||
m_hoverType = None;
|
||||
setContentsMargins( 0, 0, 0, 0 );
|
||||
setMouseTracking( true );
|
||||
|
||||
@@ -247,6 +248,7 @@ void
|
||||
QueryLabel::updateLabel()
|
||||
{
|
||||
m_hoverArea = QRect();
|
||||
m_hoverType = None;
|
||||
|
||||
updateGeometry();
|
||||
update();
|
||||
@@ -298,6 +300,7 @@ QueryLabel::paintEvent( QPaintEvent* event )
|
||||
{
|
||||
m_hoverArea.setLeft( 0 );
|
||||
m_hoverArea.setRight( fontMetrics().width( elidedText ) + contentsMargins().left() * 2 );
|
||||
m_hoverType = Track;
|
||||
}
|
||||
|
||||
p.setPen( palette().mid().color() );
|
||||
@@ -332,7 +335,7 @@ QueryLabel::paintEvent( QPaintEvent* event )
|
||||
p.setBrush( palette().window() );
|
||||
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.setBrush( palette().highlight() );
|
||||
@@ -351,7 +354,7 @@ QueryLabel::paintEvent( QPaintEvent* event )
|
||||
p.drawText( r, align, DASH );
|
||||
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.setBrush( palette().highlight() );
|
||||
@@ -370,7 +373,7 @@ QueryLabel::paintEvent( QPaintEvent* event )
|
||||
p.drawText( r, align, DASH );
|
||||
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.setBrush( palette().highlight() );
|
||||
@@ -417,7 +420,23 @@ QueryLabel::mouseReleaseEvent( QMouseEvent* event )
|
||||
|
||||
m_dragPos = QPoint();
|
||||
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() )
|
||||
{
|
||||
m_hoverArea = QRect();
|
||||
m_hoverType = None;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -464,19 +484,23 @@ QueryLabel::mouseMoveEvent( QMouseEvent* event )
|
||||
}
|
||||
|
||||
QRect hoverArea;
|
||||
m_hoverType = None;
|
||||
if ( m_type & Artist && x < artistX )
|
||||
{
|
||||
m_hoverType = Artist;
|
||||
hoverArea.setLeft( 0 );
|
||||
hoverArea.setRight( artistX + contentsMargins().left() );
|
||||
}
|
||||
else if ( m_type & Album && x < albumX && x > artistX )
|
||||
{
|
||||
m_hoverType = Album;
|
||||
int spacing = ( m_type & Artist ) ? dashX : 0;
|
||||
hoverArea.setLeft( artistX + spacing );
|
||||
hoverArea.setRight( albumX + spacing + contentsMargins().left() );
|
||||
}
|
||||
else if ( m_type & Track && x < trackX && x > albumX )
|
||||
{
|
||||
m_hoverType = Track;
|
||||
int spacing = ( m_type & Album ) ? dashX : 0;
|
||||
hoverArea.setLeft( albumX + spacing );
|
||||
hoverArea.setRight( trackX + contentsMargins().left() );
|
||||
@@ -499,6 +523,7 @@ void
|
||||
QueryLabel::leaveEvent( QEvent* event )
|
||||
{
|
||||
m_hoverArea = QRect();
|
||||
m_hoverType = None;
|
||||
repaint();
|
||||
}
|
||||
|
||||
|
@@ -15,6 +15,7 @@ Q_OBJECT
|
||||
public:
|
||||
enum DisplayType
|
||||
{
|
||||
None = 0,
|
||||
Artist = 1,
|
||||
Album = 2,
|
||||
Track = 4,
|
||||
@@ -60,6 +61,9 @@ public slots:
|
||||
|
||||
signals:
|
||||
void clicked();
|
||||
void clickedArtist();
|
||||
void clickedAlbum();
|
||||
void clickedTrack();
|
||||
|
||||
void textChanged( const QString& text );
|
||||
void resultChanged( const Tomahawk::result_ptr& result );
|
||||
@@ -88,6 +92,7 @@ private:
|
||||
Qt::Alignment align;
|
||||
Qt::TextElideMode mode;
|
||||
|
||||
DisplayType m_hoverType;
|
||||
QRect m_hoverArea;
|
||||
QPoint m_dragPos;
|
||||
QMargins m_textMargins;
|
||||
|
Reference in New Issue
Block a user