mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-02 20:28:14 +02:00
* Put a CaptionLabel above alternative versions in TrackDetailView.
This commit is contained in:
@@ -29,6 +29,7 @@
|
|||||||
#include "widgets/PlayableCover.h"
|
#include "widgets/PlayableCover.h"
|
||||||
#include "widgets/QueryLabel.h"
|
#include "widgets/QueryLabel.h"
|
||||||
#include "widgets/ClickableLabel.h"
|
#include "widgets/ClickableLabel.h"
|
||||||
|
#include "widgets/CaptionLabel.h"
|
||||||
#include "PlaylistInterface.h"
|
#include "PlaylistInterface.h"
|
||||||
#include "utils/ImageRegistry.h"
|
#include "utils/ImageRegistry.h"
|
||||||
#include "utils/TomahawkUtilsGui.h"
|
#include "utils/TomahawkUtilsGui.h"
|
||||||
@@ -84,6 +85,17 @@ TrackDetailView::TrackDetailView( QWidget* parent )
|
|||||||
m_infoBox->setLayout( hboxl );
|
m_infoBox->setLayout( hboxl );
|
||||||
m_infoBox->hide();
|
m_infoBox->hide();
|
||||||
|
|
||||||
|
f.setWeight( QFont::Normal );
|
||||||
|
f.setPointSize( TomahawkUtils::defaultFontSize() - 1 );
|
||||||
|
|
||||||
|
m_resultsBoxLabel = new CaptionLabel( this );
|
||||||
|
m_resultsBoxLabel->setFont( f );
|
||||||
|
m_resultsBoxLabel->setStyleSheet( "QLabel { color: rgba( 0, 0, 0, 50% ) }" );
|
||||||
|
m_resultsBoxLabel->setText( tr( "Alternative versions:" ) );
|
||||||
|
m_resultsBoxLabel->setFixedWidth( width() - 4 );
|
||||||
|
m_resultsBoxLabel->setFixedHeight( m_resultsBoxLabel->sizeHint().height() * 0.8 );
|
||||||
|
m_resultsBoxLabel->hide();
|
||||||
|
|
||||||
m_resultsBox = new QWidget;
|
m_resultsBox = new QWidget;
|
||||||
QVBoxLayout* resultsLayout = new QVBoxLayout;
|
QVBoxLayout* resultsLayout = new QVBoxLayout;
|
||||||
TomahawkUtils::unmarginLayout( resultsLayout );
|
TomahawkUtils::unmarginLayout( resultsLayout );
|
||||||
@@ -109,8 +121,9 @@ TrackDetailView::TrackDetailView( QWidget* parent )
|
|||||||
layout->addWidget( m_dateLabel );
|
layout->addWidget( m_dateLabel );
|
||||||
layout->addWidget( m_infoBox );
|
layout->addWidget( m_infoBox );
|
||||||
layout->addSpacerItem( new QSpacerItem( 0, 32, QSizePolicy::Minimum, QSizePolicy::Fixed ) );
|
layout->addSpacerItem( new QSpacerItem( 0, 32, QSizePolicy::Minimum, QSizePolicy::Fixed ) );
|
||||||
|
layout->addWidget( m_resultsBoxLabel );
|
||||||
|
layout->addSpacerItem( new QSpacerItem( 0, 8, QSizePolicy::Minimum, QSizePolicy::Fixed ) );
|
||||||
layout->addWidget( resultsScrollArea );
|
layout->addWidget( resultsScrollArea );
|
||||||
layout->addSpacerItem( new QSpacerItem( 0, 32, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding ) );
|
|
||||||
layout->setStretchFactor( resultsScrollArea, 1 );
|
layout->setStretchFactor( resultsScrollArea, 1 );
|
||||||
|
|
||||||
setLayout( layout );
|
setLayout( layout );
|
||||||
@@ -216,47 +229,52 @@ TrackDetailView::onResultsChanged()
|
|||||||
delete child;
|
delete child;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !m_query )
|
if ( m_query )
|
||||||
return;
|
|
||||||
|
|
||||||
foreach ( const Tomahawk::result_ptr& result, m_query->results() )
|
|
||||||
{
|
{
|
||||||
if ( !result->isOnline() )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
QFont f = font();
|
QFont f = font();
|
||||||
f.setWeight( QFont::DemiBold );
|
f.setPointSize( TomahawkUtils::defaultFontSize() );
|
||||||
f.setPointSize( 11 );
|
|
||||||
|
|
||||||
QLabel* resolverIcon = new QLabel( this );
|
foreach ( const Tomahawk::result_ptr& result, m_query->results() )
|
||||||
resolverIcon->setFixedWidth( 12 );
|
{
|
||||||
resolverIcon->setPixmap( result->sourceIcon( TomahawkUtils::RoundedCorners, QSize( 12, 12 ) ) );
|
if ( !result->isOnline() )
|
||||||
|
continue;
|
||||||
|
|
||||||
QLabel* resolverLabel = new ClickableLabel( this );
|
QLabel* resolverIcon = new QLabel( this );
|
||||||
resolverLabel->setFont( f );
|
resolverIcon->setFixedWidth( 12 );
|
||||||
resolverLabel->setStyleSheet( "QLabel { color: rgba( 0, 0, 0, 50% ) }" );
|
resolverIcon->setPixmap( result->sourceIcon( TomahawkUtils::RoundedCorners, QSize( 12, 12 ) ) );
|
||||||
resolverLabel->setText( QString( "%1 - %2" ).arg( result->track()->track() ).arg( result->track()->artist() ) );
|
|
||||||
resolverLabel->setToolTip( QString( "%1 by %2%3" ).arg( result->track()->track() ).arg( result->track()->artist() )
|
|
||||||
.arg( !result->track()->album().isEmpty() ? QString( " " ) + tr( "on %1" ).arg( result->track()->album() ) : QString() ) );
|
|
||||||
resolverLabel->setFixedWidth( width() - 32 - 4 );
|
|
||||||
|
|
||||||
NewClosure( resolverLabel, SIGNAL( clicked() ), const_cast< AudioEngine* >( AudioEngine::instance() ),
|
QLabel* resolverLabel = new ClickableLabel( this );
|
||||||
SLOT( playItem( Tomahawk::playlistinterface_ptr, Tomahawk::result_ptr, Tomahawk::query_ptr ) ),
|
resolverLabel->setFont( f );
|
||||||
Tomahawk::playlistinterface_ptr(), result, m_query )->setAutoDelete( false );
|
resolverLabel->setStyleSheet( "QLabel { color: rgba( 0, 0, 0, 50% ) }" );
|
||||||
|
resolverLabel->setText( QString( "%1 - %2" ).arg( result->track()->track() ).arg( result->track()->artist() ) );
|
||||||
|
resolverLabel->setToolTip( QString( "%1 by %2%3" ).arg( result->track()->track() ).arg( result->track()->artist() )
|
||||||
|
.arg( !result->track()->album().isEmpty() ? QString( " " ) + tr( "on %1" ).arg( result->track()->album() ) : QString() ) );
|
||||||
|
resolverLabel->setFixedWidth( width() - 32 - 4 );
|
||||||
|
|
||||||
QWidget* hbox = new QWidget;
|
NewClosure( resolverLabel, SIGNAL( clicked() ), const_cast< AudioEngine* >( AudioEngine::instance() ),
|
||||||
QHBoxLayout* hboxl = new QHBoxLayout;
|
SLOT( playItem( Tomahawk::playlistinterface_ptr, Tomahawk::result_ptr, Tomahawk::query_ptr ) ),
|
||||||
TomahawkUtils::unmarginLayout( hboxl );
|
Tomahawk::playlistinterface_ptr(), result, m_query )->setAutoDelete( false );
|
||||||
hboxl->setSpacing( 8 );
|
|
||||||
hboxl->addWidget( resolverIcon );
|
|
||||||
hboxl->addWidget( resolverLabel );
|
|
||||||
hbox->setLayout( hboxl );
|
|
||||||
|
|
||||||
m_resultsBox->layout()->addWidget( hbox );
|
QWidget* hbox = new QWidget;
|
||||||
|
QHBoxLayout* hboxl = new QHBoxLayout;
|
||||||
|
TomahawkUtils::unmarginLayout( hboxl );
|
||||||
|
hboxl->setSpacing( 8 );
|
||||||
|
hboxl->addWidget( resolverIcon );
|
||||||
|
hboxl->addWidget( resolverLabel );
|
||||||
|
hbox->setLayout( hboxl );
|
||||||
|
|
||||||
|
m_resultsBox->layout()->addWidget( hbox );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( m_query->numResults() > 1 )
|
if ( m_query && m_query->numResults() > 1 )
|
||||||
|
{
|
||||||
|
m_resultsBoxLabel->show();
|
||||||
m_resultsBox->show();
|
m_resultsBox->show();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
m_resultsBoxLabel->hide();
|
||||||
m_resultsBox->hide();
|
m_resultsBox->hide();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -25,8 +25,9 @@
|
|||||||
#include "DllMacro.h"
|
#include "DllMacro.h"
|
||||||
|
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QueryLabel;
|
class CaptionLabel;
|
||||||
class PlayableCover;
|
class PlayableCover;
|
||||||
|
class QueryLabel;
|
||||||
|
|
||||||
class DLLEXPORT TrackDetailView : public QWidget
|
class DLLEXPORT TrackDetailView : public QWidget
|
||||||
{
|
{
|
||||||
@@ -58,6 +59,7 @@ private:
|
|||||||
QLabel* m_dateLabel;
|
QLabel* m_dateLabel;
|
||||||
QLabel* m_lovedIcon;
|
QLabel* m_lovedIcon;
|
||||||
QLabel* m_lovedLabel;
|
QLabel* m_lovedLabel;
|
||||||
|
CaptionLabel* m_resultsBoxLabel;
|
||||||
|
|
||||||
QWidget* m_infoBox;
|
QWidget* m_infoBox;
|
||||||
QWidget* m_resultsBox;
|
QWidget* m_resultsBox;
|
||||||
|
Reference in New Issue
Block a user