1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-02 12:20:45 +02:00

* Put a CaptionLabel above alternative versions in TrackDetailView.

This commit is contained in:
Christian Muehlhaeuser
2014-08-23 17:02:23 +02:00
parent 1025dc3cc2
commit c54fe787b6
2 changed files with 53 additions and 33 deletions

View File

@@ -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,18 +229,16 @@ TrackDetailView::onResultsChanged()
delete child; delete child;
} }
if ( !m_query ) if ( m_query )
return; {
QFont f = font();
f.setPointSize( TomahawkUtils::defaultFontSize() );
foreach ( const Tomahawk::result_ptr& result, m_query->results() ) foreach ( const Tomahawk::result_ptr& result, m_query->results() )
{ {
if ( !result->isOnline() ) if ( !result->isOnline() )
continue; continue;
QFont f = font();
f.setWeight( QFont::DemiBold );
f.setPointSize( 11 );
QLabel* resolverIcon = new QLabel( this ); QLabel* resolverIcon = new QLabel( this );
resolverIcon->setFixedWidth( 12 ); resolverIcon->setFixedWidth( 12 );
resolverIcon->setPixmap( result->sourceIcon( TomahawkUtils::RoundedCorners, QSize( 12, 12 ) ) ); resolverIcon->setPixmap( result->sourceIcon( TomahawkUtils::RoundedCorners, QSize( 12, 12 ) ) );
@@ -254,9 +265,16 @@ TrackDetailView::onResultsChanged()
m_resultsBox->layout()->addWidget( hbox ); 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();
}
} }

View File

@@ -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;