1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-20 07:49:42 +01:00

* New design for track page.

This commit is contained in:
Christian Muehlhaeuser 2014-10-06 10:00:53 +02:00
parent a33a25cc46
commit 41748b080e
3 changed files with 79 additions and 455 deletions

View File

@ -1,6 +1,6 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2010-2014, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2010-2012, Jeff Mitchell <jeff@tomahawk-player.org>
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
*
@ -28,7 +28,7 @@
#include "SourceList.h"
#include "playlist/PlayableModel.h"
#include "audio/AudioEngine.h"
#include "widgets/StatsGauge.h"
#include "widgets/BasicHeader.h"
#include "utils/TomahawkStyle.h"
#include "utils/TomahawkUtilsGui.h"
#include "utils/Logger.h"
@ -39,131 +39,43 @@ using namespace Tomahawk;
TrackInfoWidget::TrackInfoWidget( const Tomahawk::query_ptr& query, QWidget* parent )
: QWidget( parent )
, ui( new Ui::TrackInfoWidget )
, m_scrollArea( 0 )
{
QWidget* widget = new QWidget;
m_headerWidget = new BasicHeader;
ui->setupUi( widget );
ui->statsLabel->setStyleSheet( "QLabel { background-image:url(); border: 2px solid #dddddd; background-color: #faf9f9; border-radius: 4px; padding: 12px; }" );
ui->statsLabel->setVisible( false );
/* ui->lyricsView->setVisible( false ); // FIXME eventually
TomahawkStyle::stylePageFrame( ui->lyricsView );
TomahawkStyle::styleScrollBar( ui->lyricsView->verticalScrollBar() );*/
ui->lineAbove->setStyleSheet( QString( "QFrame { border: 1px solid %1; }" ).arg( TomahawkStyle::HEADER_BACKGROUND.name() ) );
ui->lineBelow->setStyleSheet( QString( "QFrame { border: 1px solid black; }" ) );
m_pixmap = TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultTrackImage, TomahawkUtils::Original, QSize( 48, 48 ) );
ui->cover->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultTrackImage, TomahawkUtils::Original, ui->cover->size() ) );
ui->cover->setShowText( false );
QHBoxLayout* l = new QHBoxLayout( ui->statsWidget );
m_playStatsGauge = new StatsGauge( ui->statsWidget );
m_playStatsGauge->setText( tr( "# PLAYS / ARTIST" ) );
m_playStatsTotalGauge = new StatsGauge( ui->statsWidget );
m_playStatsTotalGauge->setText( tr( "YOUR SONG RANK" ) );
m_playStatsTotalGauge->setInvertedAppearance( true );
m_relatedTracksModel = new PlayableModel( ui->trackView );
ui->trackView->setPlayableModel( m_relatedTracksModel );
ui->trackView->setCaption( tr( "Similar Tracks" ) );
ui->trackView->setEmptyTip( tr( "Sorry, but we could not find similar tracks for this song!" ) );
l->addSpacerItem( new QSpacerItem( 0, 1, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding ) );
l->addWidget( m_playStatsGauge );
l->addSpacerItem( new QSpacerItem( 0, 1, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding ) );
l->addWidget( m_playStatsTotalGauge );
l->addSpacerItem( new QSpacerItem( 0, 1, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding ) );
ui->statsWidget->setLayout( l );
TomahawkUtils::unmarginLayout( l );
ui->topHits->setStyleSheet( QString( "QListView { background-color: #f9f9f9; }" ) );
TomahawkStyle::stylePageFrame( ui->trackFrame );
ui->topHits->setVisible( false );
ui->topHitsLabel->setVisible( false );
{
m_relatedTracksModel = new PlayableModel( ui->similarTracksView );
ui->similarTracksView->setPlayableModel( m_relatedTracksModel );
ui->similarTracksView->proxyModel()->sort( -1 );
ui->similarTracksView->setEmptyTip( tr( "Sorry, but we could not find similar tracks for this song!" ) );
ui->similarTracksView->setAutoResize( true );
ui->similarTracksView->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
ui->similarTracksView->setItemSize( QSize( 190, 190 + 56 ) );
// TomahawkUtils::styleScrollBar( ui->similarTracksView->verticalScrollBar() );
// ui->similarTracksView->setStyleSheet( "QListView { background-color: transparent; } QListView::item { background-color: transparent; }" );
TomahawkStyle::stylePageFrame( ui->similarTracksView );
TomahawkStyle::stylePageFrame( ui->frame );
}
{
QFont f = ui->trackLabel->font();
f.setFamily( "Titillium Web" );
QPalette p = ui->trackLabel->palette();
p.setColor( QPalette::Foreground, TomahawkStyle::HEADER_LABEL );
ui->trackLabel->setFont( f );
ui->trackLabel->setPalette( p );
}
{
ui->artistLabel->setContentsMargins( 6, 2, 6, 2 );
ui->artistLabel->setType( QueryLabel::Artist );
connect( ui->artistLabel, SIGNAL( clickedArtist() ), SLOT( onArtistClicked() ) );
QFont f = ui->artistLabel->font();
f.setFamily( "Titillium Web" );
QPalette p = ui->artistLabel->palette();
p.setColor( QPalette::Foreground, TomahawkStyle::HEADER_TEXT );
ui->artistLabel->setFont( f );
ui->artistLabel->setPalette( p );
}
{
QFont f = ui->label->font();
f.setFamily( "Pathway Gothic One" );
QPalette p = ui->label->palette();
p.setColor( QPalette::Foreground, TomahawkStyle::PAGE_CAPTION );
ui->label->setFont( f );
ui->label->setPalette( p );
}
{
QFont f = ui->statsLabel->font();
f.setPointSize( TomahawkUtils::defaultFontSize() + 2 );
ui->statsLabel->setFont( f );
}
/*{
QPalette p = ui->lyricsView->palette();
p.setColor( QPalette::Foreground, TomahawkStyle::PAGE_FOREGROUND );
p.setColor( QPalette::Text, TomahawkStyle::PAGE_FOREGROUND );
ui->lyricsView->setPalette( p );
}*/
{
m_scrollArea = new QScrollArea();
m_scrollArea->setWidgetResizable( true );
m_scrollArea->setWidget( widget );
m_scrollArea->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOn );
QScrollArea* area = new QScrollArea();
area->setWidgetResizable( true );
area->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
area->setWidget( widget );
QPalette pal = palette();
pal.setBrush( backgroundRole(), TomahawkStyle::HEADER_BACKGROUND );
m_scrollArea->setPalette( pal );
m_scrollArea->setAutoFillBackground( true );
m_scrollArea->setFrameShape( QFrame::NoFrame );
m_scrollArea->setAttribute( Qt::WA_MacShowFocusRect, 0 );
pal.setBrush( backgroundRole(), Qt::white );
area->setPalette( pal );
area->setAutoFillBackground( true );
area->setFrameShape( QFrame::NoFrame );
area->setAttribute( Qt::WA_MacShowFocusRect, 0 );
QVBoxLayout* layout = new QVBoxLayout();
layout->addWidget( m_scrollArea );
layout->addWidget( m_headerWidget );
layout->addWidget( area );
setLayout( layout );
TomahawkUtils::unmarginLayout( layout );
}
{
QPalette pal = palette();
pal.setBrush( backgroundRole(), TomahawkStyle::PAGE_BACKGROUND );
ui->widget->setPalette( pal );
ui->widget->setAutoFillBackground( true );
}
load( query );
}
@ -178,17 +90,17 @@ TrackInfoWidget::~TrackInfoWidget()
Tomahawk::playlistinterface_ptr
TrackInfoWidget::playlistInterface() const
{
return ui->similarTracksView->playlistInterface();
return ui->trackView->playlistInterface();
}
bool
TrackInfoWidget::isBeingPlayed() const
{
if ( ui->similarTracksView->playlistInterface() == AudioEngine::instance()->currentTrackPlaylist() )
if ( ui->trackView->playlistInterface() == AudioEngine::instance()->currentTrackPlaylist() )
return true;
if ( ui->similarTracksView->playlistInterface()->hasChildInterface( AudioEngine::instance()->currentTrackPlaylist() ) )
if ( ui->trackView->playlistInterface()->hasChildInterface( AudioEngine::instance()->currentTrackPlaylist() ) )
return true;
return false;
@ -198,52 +110,32 @@ TrackInfoWidget::isBeingPlayed() const
bool
TrackInfoWidget::jumpToCurrentTrack()
{
if ( ui->similarTracksView->jumpToCurrentTrack() && !ui->similarTracksView->currentTrackRect().isEmpty() )
{
// We embed the view in a scrollarea, so we have to manually ensure we make it visible
const QRect itemRect = ui->similarTracksView->currentTrackRect();
m_scrollArea->ensureVisible( itemRect.right(), itemRect.bottom(), 50, 50 );
return true;
}
return false;
return ui->trackView && ui->trackView->jumpToCurrentTrack();
}
void
TrackInfoWidget::load( const query_ptr& query )
{
if ( !m_query.isNull() )
if ( m_query )
{
disconnect( m_query->track().data(), SIGNAL( lyricsLoaded() ), this, SLOT( onLyricsLoaded() ) );
disconnect( m_query->track().data(), SIGNAL( similarTracksLoaded() ), this, SLOT( onSimilarTracksLoaded() ) );
disconnect( m_query->track().data(), SIGNAL( statsLoaded() ), this, SLOT( onStatsLoaded() ) );
disconnect( m_query->track().data(), SIGNAL( updated() ), this, SLOT( onCoverUpdated() ) );
disconnect( m_artist.data(), SIGNAL( statsLoaded() ), this, SLOT( onStatsLoaded() ) );
disconnect( m_artist.data(), SIGNAL( similarArtistsLoaded() ), this, SLOT( onSimilarArtistsLoaded() ) );
}
m_query = query;
m_artist = Artist::get( m_query->track()->artist() );
m_title = QString( "%1 - %2" ).arg( query->track()->artist() ).arg( query->track()->track() );
ui->trackLabel->setText( m_query->track()->track() );
ui->artistLabel->setArtist( m_query->track()->artistPtr() );
m_headerWidget->setCaption( m_query->track()->track() );
connect( m_artist.data(), SIGNAL( similarArtistsLoaded() ), SLOT( onSimilarArtistsLoaded() ) );
connect( m_artist.data(), SIGNAL( statsLoaded() ), SLOT( onStatsLoaded() ) );
connect( m_query->track().data(), SIGNAL( lyricsLoaded() ), SLOT( onLyricsLoaded() ) );
connect( m_query->track().data(), SIGNAL( similarTracksLoaded() ), SLOT( onSimilarTracksLoaded() ) );
connect( m_query->track().data(), SIGNAL( updated() ), SLOT( onCoverUpdated() ) );
connect( m_query->track().data(), SIGNAL( statsLoaded() ), SLOT( onStatsLoaded() ) );
m_artist->loadStats();
m_query->track()->loadStats();
// m_query->lyrics();
onCoverUpdated();
ui->cover->setQuery( query );
m_relatedTracksModel->clear();
m_relatedTracksModel->startLoading();
@ -258,51 +150,10 @@ TrackInfoWidget::onCoverUpdated()
if ( m_query->track()->cover( QSize( 0, 0 ) ).isNull() )
return;
m_pixmap = m_query->track()->cover( ui->cover->size() );
ui->cover->setPixmap( TomahawkUtils::createRoundedImage( m_pixmap, QSize( 0, 0 ) ) );
}
m_pixmap = m_query->track()->cover( QSize( 0, 0 ) );
emit pixmapChanged( m_pixmap );
void
TrackInfoWidget::onStatsLoaded()
{
QString stats;
QList< Tomahawk::PlaybackLog > history = m_query->track()->playbackHistory( SourceList::instance()->getLocal() );
const unsigned int trackCounter = m_query->track()->playbackCount( SourceList::instance()->getLocal() );
const unsigned int artistCounter = m_artist->playbackCount( SourceList::instance()->getLocal() );
if ( trackCounter )
stats = tr( "You've listened to this track %n time(s).", "", trackCounter );
else
stats = tr( "You've never listened to this track before." );
if ( history.count() )
{
stats += "\n" + tr( "You first listened to it on %1." ).arg( QDateTime::fromTime_t( history.first().timestamp ).toString( "dd MMM yyyy" ) );
}
if ( artistCounter )
{
stats += "\n" + tr( "You've listened to %1 %n time(s).", "", artistCounter ).arg( m_artist->name() );
m_playStatsGauge->setMaximum( artistCounter );
m_playStatsGauge->setValue( trackCounter );
}
else
stats += "\n" + tr( "You've never listened to %1 before." ).arg( m_artist->name() );
ui->statsLabel->setText( stats );
m_playStatsTotalGauge->setMaximum( m_query->track()->chartCount() );
m_playStatsTotalGauge->setValue( m_query->track()->chartPosition() );
}
void
TrackInfoWidget::onSimilarArtistsLoaded()
{
/* Artist* artist = qobject_cast<Artist*>( sender() );
m_relatedArtistsModel->addArtists( artist->similarArtists() );*/
m_headerWidget->setBackground( m_pixmap, true, false );
}
@ -321,20 +172,6 @@ TrackInfoWidget::onLyricsLoaded()
}
void
TrackInfoWidget::onArtistClicked()
{
ViewManager::instance()->show( m_query->track()->artistPtr() );
}
void
TrackInfoWidget::onAlbumClicked()
{
ViewManager::instance()->show( m_query->track()->albumPtr() );
}
void
TrackInfoWidget::changeEvent( QEvent* e )
{

View File

@ -1,6 +1,6 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2010-2014, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2010-2011, Jeff Mitchell <jeff@tomahawk-player.org>
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
*
@ -40,8 +40,8 @@
#include <QWidget>
class PlayableModel;
class StatsGauge;
class QScrollArea;
class BasicHeader;
namespace Ui
{
@ -75,29 +75,24 @@ public:
public slots:
void load( const Tomahawk::query_ptr& query );
signals:
void pixmapChanged( const QPixmap& pixmap );
protected:
void changeEvent( QEvent* e );
private slots:
void onCoverUpdated();
void onStatsLoaded();
void onSimilarArtistsLoaded();
void onSimilarTracksLoaded();
void onLyricsLoaded();
void onArtistClicked();
void onAlbumClicked();
private:
Ui::TrackInfoWidget *ui;
QScrollArea* m_scrollArea;
BasicHeader* m_headerWidget;
Tomahawk::query_ptr m_query;
Tomahawk::artist_ptr m_artist;
StatsGauge* m_playStatsGauge;
StatsGauge* m_playStatsTotalGauge;
PlayableModel* m_relatedTracksModel;
QString m_title;
QPixmap m_pixmap;

View File

@ -6,14 +6,14 @@
<rect>
<x>0</x>
<y>0</y>
<width>1276</width>
<height>828</height>
<width>828</width>
<height>635</height>
</rect>
</property>
<property name="windowTitle">
<string notr="true" extracomment="not translatable because not shown to the user">Form</string>
<string notr="true">Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="0,0,0,1">
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>0</number>
</property>
@ -21,268 +21,64 @@
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,0,0">
<property name="spacing">
<number>16</number>
</property>
<property name="margin">
<number>12</number>
</property>
<item>
<widget class="PlayableCover" name="cover">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>260</width>
<height>260</height>
</size>
</property>
<property name="text">
<string notr="true" extracomment="not translatable because is placeholder test">Cover</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="ScrollingLabel" name="trackLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>26</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string notr="true" extracomment="not translatable because not shown to the user">TrackName</string>
</property>
<property name="indent">
<number>4</number>
</property>
</widget>
</item>
<item>
<widget class="QueryLabel" name="artistLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>20</pointsize>
</font>
</property>
<property name="text">
<string notr="true" extracomment="not translatable because not shown to the user">ArtistName</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="statsLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>260</height>
</size>
</property>
<property name="text">
<string notr="true" extracomment="not translatable because is placeholder test">Statistics</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="statsWidget" native="true">
<property name="minimumSize">
<size>
<width>440</width>
<height>240</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>440</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Line" name="lineAbove">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>1</height>
</size>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
<widget class="ContextView" name="trackView" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="Line" name="lineBelow">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>1</height>
</size>
<widget class="QFrame" name="trackFrame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="widget" native="true">
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QVBoxLayout" name="verticalLayout_6">
<property name="spacing">
<number>0</number>
<number>4</number>
</property>
<property name="leftMargin">
<number>0</number>
<number>32</number>
</property>
<property name="topMargin">
<number>16</number>
<number>4</number>
</property>
<property name="rightMargin">
<number>0</number>
<number>32</number>
</property>
<property name="bottomMargin">
<number>16</number>
<number>8</number>
</property>
<item>
<widget class="QFrame" name="frame">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
<widget class="CaptionLabel" name="topHitsLabel">
<property name="text">
<string>Top Hits</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
<property name="margin">
<number>0</number>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
<property name="spacing">
<number>4</number>
</property>
<property name="leftMargin">
<number>28</number>
</property>
<property name="topMargin">
<number>4</number>
</property>
<property name="rightMargin">
<number>8</number>
</property>
<property name="bottomMargin">
<number>4</number>
</property>
<item>
<widget class="QLabel" name="label">
<property name="font">
<font>
<pointsize>20</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Similar Tracks</string>
</property>
<property name="margin">
<number>0</number>
</property>
</widget>
</item>
<item>
<widget class="GridView" name="similarTracksView">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
<widget class="GridView" name="topHits">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="sizeHint" stdset="0">
<property name="minimumSize">
<size>
<width>20</width>
<height>0</height>
<width>0</width>
<height>190</height>
</size>
</property>
</spacer>
</widget>
</item>
</layout>
</widget>
@ -296,19 +92,15 @@
<header>playlist/GridView.h</header>
</customwidget>
<customwidget>
<class>PlayableCover</class>
<class>CaptionLabel</class>
<extends>QLabel</extends>
<header>widgets/PlayableCover.h</header>
<header>widgets/CaptionLabel.h</header>
</customwidget>
<customwidget>
<class>QueryLabel</class>
<extends>QLabel</extends>
<header>widgets/QueryLabel.h</header>
</customwidget>
<customwidget>
<class>ScrollingLabel</class>
<extends>QLabel</extends>
<header location="global">widgets/ScrollingLabel.h</header>
<class>ContextView</class>
<extends>QWidget</extends>
<header>playlist/ContextView.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>