1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-07-15 03:26:28 +02:00

Show a querylabel in the infobar if there's artist we can link it to

This commit is contained in:
Leo Franchi
2011-10-29 18:27:08 -04:00
parent ec66cf29f3
commit c1ee97fc40
12 changed files with 230 additions and 60 deletions

View File

@ -27,6 +27,7 @@
#include "utils/tomahawkutils.h" #include "utils/tomahawkutils.h"
#include "utils/logger.h" #include "utils/logger.h"
#include <QCheckBox> #include <QCheckBox>
#include <widgets/querylabel.h>
#define ANIMATION_TIME 400 #define ANIMATION_TIME 400
#define IMAGE_HEIGHT 64 #define IMAGE_HEIGHT 64
@ -37,10 +38,12 @@ using namespace Tomahawk;
InfoBar::InfoBar( QWidget* parent ) InfoBar::InfoBar( QWidget* parent )
: QWidget( parent ) : QWidget( parent )
, ui( new Ui::InfoBar ) , ui( new Ui::InfoBar )
, m_queryLabel( 0 )
{ {
ui->setupUi( this ); ui->setupUi( this );
TomahawkUtils::unmarginLayout( layout() ); TomahawkUtils::unmarginLayout( layout() );
layout()->setContentsMargins( 8, 4, 8, 4 ); layout()->setContentsMargins( 8, 4, 8, 4 );
ui->verticalLayout->setContentsMargins( 0, 0, 0, 15 );
QFont boldFont = ui->captionLabel->font(); QFont boldFont = ui->captionLabel->font();
boldFont.setPixelSize( 18 ); boldFont.setPixelSize( 18 );
@ -71,6 +74,14 @@ InfoBar::InfoBar( QWidget* parent )
ui->longDescriptionLabel->setText( QString() ); ui->longDescriptionLabel->setText( QString() );
ui->imageLabel->setText( QString() ); ui->imageLabel->setText( QString() );
m_queryLabel = new QueryLabel( this );
m_queryLabel->setType( QueryLabel::Artist );
m_queryLabel->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );
m_queryLabel->setTextPen( palette().brightText().color() );
m_queryLabel->setFont( boldFont );
m_queryLabel->hide();
connect( m_queryLabel, SIGNAL( clickedArtist() ), this, SLOT( artistClicked() ) );
m_autoUpdate = new QCheckBox( this ); m_autoUpdate = new QCheckBox( this );
m_autoUpdate->setText( tr( "Automatically update" ) ); m_autoUpdate->setText( tr( "Automatically update" ) );
m_autoUpdate->setLayoutDirection( Qt::RightToLeft ); m_autoUpdate->setLayoutDirection( Qt::RightToLeft );
@ -116,9 +127,47 @@ InfoBar::setCaption( const QString& s )
void void
InfoBar::setDescription( const QString& s ) InfoBar::setDescription( const QString& s )
{ {
if ( m_queryLabel->isVisible() )
{
ui->verticalLayout->removeWidget( m_queryLabel );
m_queryLabel->hide();
ui->verticalLayout->addWidget( ui->descriptionLabel );
ui->descriptionLabel->show();
}
ui->descriptionLabel->setText( s ); ui->descriptionLabel->setText( s );
} }
void
InfoBar::setDescription( const artist_ptr& artist )
{
m_queryLabel->setQuery( Query::get( artist->name(), QString(), QString() ) );
m_queryLabel->setExtraContentsMargins( 4, 0, 0, 0 );
if ( !m_queryLabel->isVisible() )
{
ui->verticalLayout->removeWidget( ui->descriptionLabel );
ui->descriptionLabel->hide();
m_queryLabel->show();
ui->verticalLayout->addWidget( m_queryLabel );
}
}
void
InfoBar::setDescription( const album_ptr& album_ptr )
{
// TODO
}
void
InfoBar::artistClicked()
{
if ( m_queryLabel && !m_queryLabel->query().isNull() )
ViewManager::instance()->show( Artist::get( m_queryLabel->artist() ) );
}
void void
InfoBar::setLongDescription( const QString& s ) InfoBar::setLongDescription( const QString& s )

View File

@ -22,7 +22,9 @@
#include <QWidget> #include <QWidget>
#include "dllmacro.h" #include "dllmacro.h"
#include "artist.h"
class QueryLabel;
class QCheckBox; class QCheckBox;
class QTimeLine; class QTimeLine;
class QSearchField; class QSearchField;
@ -43,7 +45,12 @@ public:
public slots: public slots:
void setCaption( const QString& s ); void setCaption( const QString& s );
void setDescription( const QString& s ); void setDescription( const QString& s );
// If you want a querylabel instead of an ElidedLabel
void setDescription( const Tomahawk::artist_ptr& artist );
void setDescription( const Tomahawk::album_ptr& album_ptr );
void setLongDescription( const QString& s ); void setLongDescription( const QString& s );
void setPixmap( const QPixmap& p ); void setPixmap( const QPixmap& p );
@ -60,12 +67,14 @@ protected:
private slots: private slots:
void onFilterEdited(); void onFilterEdited();
void artistClicked();
private: private:
Ui::InfoBar* ui; Ui::InfoBar* ui;
QSearchField* m_searchWidget; QSearchField* m_searchWidget;
QCheckBox* m_autoUpdate; QCheckBox* m_autoUpdate;
QueryLabel* m_queryLabel;
}; };
#endif // INFOBAR_H #endif // INFOBAR_H

View File

@ -65,10 +65,13 @@
<property name="sizeConstraint"> <property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum> <enum>QLayout::SetDefaultConstraint</enum>
</property> </property>
<property name="bottomMargin">
<number>0</number>
</property>
<item> <item>
<widget class="ElidedLabel" name="captionLabel"> <widget class="ElidedLabel" name="captionLabel">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>

View File

@ -555,6 +555,12 @@ ViewManager::setPage( ViewPage* page, bool trackHistory )
if( obj->metaObject()->indexOfSignal( "descriptionChanged(QString)" ) > -1 ) if( obj->metaObject()->indexOfSignal( "descriptionChanged(QString)" ) > -1 )
connect( obj, SIGNAL( descriptionChanged( QString ) ), m_infobar, SLOT( setDescription( QString ) ), Qt::UniqueConnection ); connect( obj, SIGNAL( descriptionChanged( QString ) ), m_infobar, SLOT( setDescription( QString ) ), Qt::UniqueConnection );
if( obj->metaObject()->indexOfSignal( "descriptionChanged(Tomahawk::artist_ptr)" ) > -1 )
connect( obj, SIGNAL( descriptionChanged( Tomahawk::artist_ptr ) ), m_infobar, SLOT( setDescription( Tomahawk::artist_ptr ) ), Qt::UniqueConnection );
if( obj->metaObject()->indexOfSignal( "descriptionChanged(Tomahawk::album_ptr)" ) > -1 )
connect( obj, SIGNAL( descriptionChanged( Tomahawk::album_ptr ) ), m_infobar, SLOT( setDescription( Tomahawk::album_ptr ) ), Qt::UniqueConnection );
if( obj->metaObject()->indexOfSignal( "longDescriptionChanged(QString)" ) > -1 ) if( obj->metaObject()->indexOfSignal( "longDescriptionChanged(QString)" ) > -1 )
connect( obj, SIGNAL( longDescriptionChanged( QString ) ), m_infobar, SLOT( setLongDescription( QString ) ), Qt::UniqueConnection ); connect( obj, SIGNAL( longDescriptionChanged( QString ) ), m_infobar, SLOT( setLongDescription( QString ) ), Qt::UniqueConnection );
@ -672,7 +678,19 @@ ViewManager::updateView()
m_infobar->setVisible( currentPage()->showInfoBar() ); m_infobar->setVisible( currentPage()->showInfoBar() );
m_infobar->setCaption( currentPage()->title() ); m_infobar->setCaption( currentPage()->title() );
m_infobar->setDescription( currentPage()->description() ); switch( currentPage()->descriptionType() )
{
case ViewPage::TextType:
m_infobar->setDescription( currentPage()->description() );
break;
case ViewPage::ArtistType:
m_infobar->setDescription( currentPage()->descriptionArtist() );
break;
case ViewPage::AlbumType:
m_infobar->setDescription( currentPage()->descriptionAlbum() );
break;
}
m_infobar->setLongDescription( currentPage()->longDescription() ); m_infobar->setLongDescription( currentPage()->longDescription() );
m_infobar->setPixmap( currentPage()->pixmap() ); m_infobar->setPixmap( currentPage()->pixmap() );

View File

@ -23,6 +23,8 @@
#include "typedefs.h" #include "typedefs.h"
#include "playlistinterface.h" #include "playlistinterface.h"
#include "artist.h"
#include "album.h"
#include "utils/tomahawkutils.h" #include "utils/tomahawkutils.h"
#include "dllmacro.h" #include "dllmacro.h"
@ -33,6 +35,12 @@ namespace Tomahawk
class DLLEXPORT ViewPage class DLLEXPORT ViewPage
{ {
public: public:
enum DescriptionType {
TextType = 0,
ArtistType = 1,
AlbumType = 2
};
ViewPage() {} ViewPage() {}
virtual ~ViewPage() {} virtual ~ViewPage() {}
@ -40,7 +48,12 @@ public:
virtual Tomahawk::PlaylistInterface* playlistInterface() const = 0; virtual Tomahawk::PlaylistInterface* playlistInterface() const = 0;
virtual QString title() const = 0; virtual QString title() const = 0;
virtual DescriptionType descriptionType() { return TextType; }
virtual QString description() const = 0; virtual QString description() const = 0;
virtual Tomahawk::artist_ptr descriptionArtist() const { return Tomahawk::artist_ptr(); }
virtual Tomahawk::album_ptr descriptionAlbum() const { return Tomahawk::album_ptr(); }
virtual QString longDescription() const { return QString(); } virtual QString longDescription() const { return QString(); }
virtual QPixmap pixmap() const { return QPixmap( RESPATH "icons/tomahawk-icon-128x128.png" ); } virtual QPixmap pixmap() const { return QPixmap( RESPATH "icons/tomahawk-icon-128x128.png" ); }
@ -62,6 +75,8 @@ public:
/** subclasses implementing ViewPage can emit the following signals: /** subclasses implementing ViewPage can emit the following signals:
* nameChanged( const QString& ) * nameChanged( const QString& )
* descriptionChanged( const QString& ) * descriptionChanged( const QString& )
* descriptionChanged( const Tomahawk::artist_ptr& artist )
* descriptionChanged( const Tomahawk::album_ptr& album )
* longDescriptionChanged( const QString& ) * longDescriptionChanged( const QString& )
* pixmapChanged( const QPixmap& ) * pixmapChanged( const QPixmap& )
* destroyed( QWidget* widget ); * destroyed( QWidget* widget );

View File

@ -121,10 +121,10 @@ Breadcrumb::updateButtons( const QModelIndex& updateFrom )
// Animate all buttons except the first // Animate all buttons except the first
if ( m_buttons.count() > 0 ) if ( m_buttons.count() > 0 )
{ {
QPropertyAnimation* animation = new QPropertyAnimation( btn, "pos" ); QPropertyAnimation* animation = new QPropertyAnimation( btn, "x" );
animation->setDuration( 300 ); animation->setDuration( 300 );
animation->setStartValue( m_buttons.last()->pos() ); animation->setStartValue( m_buttons.last()->pos().x() );
animation->setEndValue( btn->pos() ); animation->setEndValue( btn->pos().x() );
animation->start( QAbstractAnimation::DeleteWhenStopped ); animation->start( QAbstractAnimation::DeleteWhenStopped );
} }
@ -150,19 +150,7 @@ Breadcrumb::updateButtons( const QModelIndex& updateFrom )
while ( m_buttons.size() > cur ) while ( m_buttons.size() > cur )
{ {
BreadcrumbButton* b = m_buttons.takeLast(); BreadcrumbButton* b = m_buttons.takeLast();
m_buttonlayout->removeWidget( b ); m_buttonlayout->removeWidget( b );
b->show();
if ( m_buttons.size() )
{
QPropertyAnimation* animation = new QPropertyAnimation( b, "pos" );
animation->setDuration( 300 );
animation->setStartValue( b->pos() );
animation->setEndValue( m_buttons.last()->pos() );
animation->start( QAbstractAnimation::DeleteWhenStopped );
}
b->deleteLater(); b->deleteLater();
} }

View File

@ -59,6 +59,7 @@ BreadcrumbButton::paintEvent( QPaintEvent* )
StyleHelper::horizontalHeader( &p, r ); // draw the background StyleHelper::horizontalHeader( &p, r ); // draw the background
qDebug() << "BREADCRUMBBUTTON PAINTING IN:" << r << mapToParent( r.topLeft() ) << m_curIndex.data();
if( !hasChildren() ) if( !hasChildren() )
return; return;

View File

@ -136,6 +136,23 @@ AlbumInfoWidget::isBeingPlayed() const
return false; return false;
} }
artist_ptr AlbumInfoWidget::descriptionArtist() const
{
if ( !m_album.isNull() && !m_album->artist().isNull() )
return m_album->artist();
return artist_ptr();
}
ViewPage::DescriptionType
AlbumInfoWidget::descriptionType()
{
if ( !m_album.isNull() && !m_album->artist().isNull() )
return ViewPage::ArtistType;
return ViewPage::TextType;
}
void void
AlbumInfoWidget::load( const album_ptr& album ) AlbumInfoWidget::load( const album_ptr& album )
@ -143,6 +160,7 @@ AlbumInfoWidget::load( const album_ptr& album )
m_album = album; m_album = album;
m_title = album->name(); m_title = album->name();
m_description = album->artist()->name(); m_description = album->artist()->name();
ui->albumsLabel->setText( tr( "Other Albums by %1" ).arg( album->artist()->name() ) ); ui->albumsLabel->setText( tr( "Other Albums by %1" ).arg( album->artist()->name() ) );
m_tracksModel->addTracks( album, QModelIndex() ); m_tracksModel->addTracks( album, QModelIndex() );

View File

@ -53,6 +53,24 @@ public:
AlbumInfoWidget( const Tomahawk::album_ptr& album, QWidget* parent = 0 ); AlbumInfoWidget( const Tomahawk::album_ptr& album, QWidget* parent = 0 );
~AlbumInfoWidget(); ~AlbumInfoWidget();
virtual QWidget* widget() { return this; }
virtual Tomahawk::PlaylistInterface* playlistInterface() const;
virtual QString title() const { return m_title; }
virtual DescriptionType descriptionType();
virtual QString description() const { return m_description; }
virtual Tomahawk::artist_ptr descriptionArtist() const;
virtual QString longDescription() const { return m_longDescription; }
virtual QPixmap pixmap() const { if ( m_pixmap.isNull() ) return Tomahawk::ViewPage::pixmap(); else return m_pixmap; }
virtual bool isTemporaryPage() const { return true; }
virtual bool showStatsBar() const { return false; }
virtual bool jumpToCurrentTrack() { return false; }
virtual bool isBeingPlayed() const;
public slots:
/** \brief Loads information for a given album. /** \brief Loads information for a given album.
* \param album The album that you want to load information for. * \param album The album that you want to load information for.
* *
@ -63,23 +81,9 @@ public:
*/ */
void load( const Tomahawk::album_ptr& album ); void load( const Tomahawk::album_ptr& album );
virtual QWidget* widget() { return this; }
virtual Tomahawk::PlaylistInterface* playlistInterface() const;
virtual QString title() const { return m_title; }
virtual QString description() const { return m_description; }
virtual QString longDescription() const { return m_longDescription; }
virtual QPixmap pixmap() const { if ( m_pixmap.isNull() ) return Tomahawk::ViewPage::pixmap(); else return m_pixmap; }
virtual bool isTemporaryPage() const { return true; }
virtual bool showStatsBar() const { return false; }
virtual bool jumpToCurrentTrack() { return false; }
virtual bool isBeingPlayed() const;
signals: signals:
void longDescriptionChanged( const QString& description ); void longDescriptionChanged( const QString& description );
void descriptionChanged( const QString& description ); void descriptionChanged( const Tomahawk::artist_ptr& artist );
void pixmapChanged( const QPixmap& pixmap ); void pixmapChanged( const QPixmap& pixmap );
protected: protected:

View File

@ -80,8 +80,10 @@ QueryLabel::init()
setContentsMargins( 0, 0, 0, 0 ); setContentsMargins( 0, 0, 0, 0 );
setMouseTracking( true ); setMouseTracking( true );
align = Qt::AlignLeft; m_useCustomPen = false;
mode = Qt::ElideMiddle; m_useCustomFont = false;
m_align = Qt::AlignLeft;
m_mode = Qt::ElideMiddle;
} }
@ -234,38 +236,63 @@ QueryLabel::setQuery( const Tomahawk::query_ptr& query )
Qt::Alignment Qt::Alignment
QueryLabel::alignment() const QueryLabel::alignment() const
{ {
return align; return m_align;
} }
void void
QueryLabel::setAlignment( Qt::Alignment alignment ) QueryLabel::setAlignment( Qt::Alignment alignment )
{ {
if ( this->align != alignment ) if ( m_align != alignment )
{ {
this->align = alignment; m_align = alignment;
update(); // no geometry change, repaint is sufficient update(); // no geometry change, repaint is sufficient
} }
} }
void
QueryLabel::setTextPen( const QPen & pen )
{
m_useCustomPen = true;
m_textPen = pen;
}
QPen
QueryLabel::textPen() const
{
return m_textPen;
}
Qt::TextElideMode Qt::TextElideMode
QueryLabel::elideMode() const QueryLabel::elideMode() const
{ {
return mode; return m_mode;
} }
void void
QueryLabel::setElideMode( Qt::TextElideMode mode ) QueryLabel::setElideMode( Qt::TextElideMode mode )
{ {
if ( this->mode != mode ) if ( m_mode != mode )
{ {
this->mode = mode; m_mode = mode;
updateLabel(); updateLabel();
} }
} }
QFont
QueryLabel::font() const
{
return m_font;
}
void
QueryLabel::setFont( const QFont& font )
{
m_useCustomFont = true;
m_font = font;
}
void void
QueryLabel::updateLabel() QueryLabel::updateLabel()
@ -277,6 +304,17 @@ QueryLabel::updateLabel()
update(); update();
} }
void
QueryLabel::setExtraContentsMargins( int left, int top, int right, int bottom )
{
QMargins margins = contentsMargins();
margins.setLeft( margins.left() + left );
margins.setTop( margins.top() + top );
margins.setRight( margins.right() + right );
margins.setBottom( margins.bottom() + bottom );
setContentsMargins( margins );
}
QSize QSize
QueryLabel::sizeHint() const QueryLabel::sizeHint() const
@ -290,7 +328,7 @@ QueryLabel::sizeHint() const
QSize QSize
QueryLabel::minimumSizeHint() const QueryLabel::minimumSizeHint() const
{ {
switch ( mode ) switch ( m_mode )
{ {
case Qt::ElideNone: case Qt::ElideNone:
return sizeHint(); return sizeHint();
@ -312,11 +350,14 @@ QueryLabel::paintEvent( QPaintEvent* event )
QPainter p( this ); QPainter p( this );
QRect r = contentsRect(); QRect r = contentsRect();
QString s = text(); QString s = text();
const QString elidedText = fontMetrics().elidedText( s, mode, r.width() ); const QString elidedText = fontMetrics().elidedText( s, m_mode, r.width() );
p.save(); p.save();
p.setRenderHint( QPainter::Antialiasing ); p.setRenderHint( QPainter::Antialiasing );
if ( m_useCustomFont )
p.setFont( m_font );
if ( m_hoverArea.width() ) if ( m_hoverArea.width() )
{ {
if ( elidedText != s ) if ( elidedText != s )
@ -343,7 +384,7 @@ QueryLabel::paintEvent( QPaintEvent* event )
p.setBrush( palette().window() ); p.setBrush( palette().window() );
p.setPen( palette().color( foregroundRole() ) ); p.setPen( palette().color( foregroundRole() ) );
} }
p.drawText( r, align, elidedText ); p.drawText( r, m_align, elidedText );
} }
else else
{ {
@ -353,10 +394,14 @@ QueryLabel::paintEvent( QPaintEvent* event )
int albumX = m_type & Album ? fm.width( album() ) : 0; int albumX = m_type & Album ? fm.width( album() ) : 0;
int trackX = m_type & Track ? fm.width( track() ) : 0; int trackX = m_type & Track ? fm.width( track() ) : 0;
if ( m_useCustomPen )
p.setPen( m_textPen );
if ( m_type & Artist ) if ( m_type & Artist )
{ {
p.setBrush( palette().window() ); p.setBrush( palette().window() );
p.setPen( palette().color( foregroundRole() ) ); if ( !m_useCustomPen )
p.setPen( palette().color( foregroundRole() ) );
if ( m_hoverType == Artist ) if ( m_hoverType == Artist )
{ {
@ -364,17 +409,18 @@ QueryLabel::paintEvent( QPaintEvent* event )
p.setBrush( palette().highlight() ); p.setBrush( palette().highlight() );
} }
p.drawText( r, align, artist() ); p.drawText( r, m_align, artist() );
r.adjust( artistX, 0, 0, 0 ); r.adjust( artistX, 0, 0, 0 );
} }
if ( m_type & Album ) if ( m_type & Album )
{ {
p.setBrush( palette().window() ); p.setBrush( palette().window() );
p.setPen( palette().color( foregroundRole() ) ); if ( !m_useCustomPen )
p.setPen( palette().color( foregroundRole() ) );
if ( m_type & Artist ) if ( m_type & Artist )
{ {
p.drawText( r, align, DASH ); p.drawText( r, m_align, DASH );
r.adjust( dashX, 0, 0, 0 ); r.adjust( dashX, 0, 0, 0 );
} }
if ( m_hoverType == Album ) if ( m_hoverType == Album )
@ -383,17 +429,18 @@ QueryLabel::paintEvent( QPaintEvent* event )
p.setBrush( palette().highlight() ); p.setBrush( palette().highlight() );
} }
p.drawText( r, align, album() ); p.drawText( r, m_align, album() );
r.adjust( albumX, 0, 0, 0 ); r.adjust( albumX, 0, 0, 0 );
} }
if ( m_type & Track ) if ( m_type & Track )
{ {
p.setBrush( palette().window() ); p.setBrush( palette().window() );
p.setPen( palette().color( foregroundRole() ) ); if ( !m_useCustomPen )
p.setPen( palette().color( foregroundRole() ) );
if ( m_type & Artist || m_type & Album ) if ( m_type & Artist || m_type & Album )
{ {
p.drawText( r, align, DASH ); p.drawText( r, m_align, DASH );
r.adjust( dashX, 0, 0, 0 ); r.adjust( dashX, 0, 0, 0 );
} }
if ( m_hoverType == Track ) if ( m_hoverType == Track )
@ -402,7 +449,7 @@ QueryLabel::paintEvent( QPaintEvent* event )
p.setBrush( palette().highlight() ); p.setBrush( palette().highlight() );
} }
p.drawText( r, align, track() ); p.drawText( r, m_align, track() );
r.adjust( trackX, 0, 0, 0 ); r.adjust( trackX, 0, 0, 0 );
} }
} }
@ -432,7 +479,8 @@ void
QueryLabel::mousePressEvent( QMouseEvent* event ) QueryLabel::mousePressEvent( QMouseEvent* event )
{ {
QFrame::mousePressEvent( event ); QFrame::mousePressEvent( event );
time.start(); m_time.restart();
m_dragPos = event->pos();
} }
@ -442,7 +490,8 @@ QueryLabel::mouseReleaseEvent( QMouseEvent* event )
QFrame::mouseReleaseEvent( event ); QFrame::mouseReleaseEvent( event );
m_dragPos = QPoint(); m_dragPos = QPoint();
if ( time.elapsed() < qApp->doubleClickInterval() ) qDebug() << "ELAPSED TIME" << m_time.elapsed() << "limit:" << qApp->doubleClickInterval();
if ( m_time.elapsed() < qApp->doubleClickInterval() )
{ {
switch( m_hoverType ) switch( m_hoverType )
{ {
@ -484,7 +533,10 @@ QueryLabel::mouseMoveEvent( QMouseEvent* event )
return; return;
} }
const QFontMetrics& fm = fontMetrics(); QFontMetrics fm = fontMetrics();
if ( m_useCustomFont )
fm = QFontMetrics( m_font );
int dashX = fm.width( DASH ); int dashX = fm.width( DASH );
int artistX = m_type & Artist ? fm.width( artist() ) : 0; int artistX = m_type & Artist ? fm.width( artist() ) : 0;
int albumX = m_type & Album ? fm.width( album() ) : 0; int albumX = m_type & Album ? fm.width( album() ) : 0;

View File

@ -1,5 +1,5 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> === /* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
* *
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org> * Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* *
* Tomahawk is free software: you can redistribute it and/or modify * Tomahawk is free software: you can redistribute it and/or modify
@ -21,6 +21,7 @@
#include <QFrame> #include <QFrame>
#include <QTime> #include <QTime>
#include <QPen>
#include "result.h" #include "result.h"
#include "query.h" #include "query.h"
@ -67,6 +68,14 @@ public:
Qt::TextElideMode elideMode() const; Qt::TextElideMode elideMode() const;
void setElideMode( Qt::TextElideMode mode ); void setElideMode( Qt::TextElideMode mode );
void setTextPen( const QPen& );
QPen textPen() const;
void setFont( const QFont& );
QFont font() const;
void setExtraContentsMargins( int left, int top, int right, int bottom );
virtual QSize sizeHint() const; virtual QSize sizeHint() const;
virtual QSize minimumSizeHint() const; virtual QSize minimumSizeHint() const;
@ -98,18 +107,22 @@ protected:
virtual void paintEvent( QPaintEvent* event ); virtual void paintEvent( QPaintEvent* event );
virtual void startDrag(); virtual void startDrag();
private: private:
QString smartAppend( QString& text, const QString& appendage ) const; QString smartAppend( QString& text, const QString& appendage ) const;
QTime time; QTime m_time;
DisplayType m_type; DisplayType m_type;
QString m_text; QString m_text;
Tomahawk::result_ptr m_result; Tomahawk::result_ptr m_result;
Tomahawk::query_ptr m_query; Tomahawk::query_ptr m_query;
Qt::Alignment align; Qt::Alignment m_align;
Qt::TextElideMode mode; Qt::TextElideMode m_mode;
bool m_useCustomPen, m_useCustomFont;
QPen m_textPen;
QFont m_font;
DisplayType m_hoverType; DisplayType m_hoverType;
QRect m_hoverArea; QRect m_hoverArea;

View File

@ -710,7 +710,7 @@ TomahawkWindow::showAboutTomahawk()
{ {
QMessageBox::about( this, tr( "About Tomahawk" ), QMessageBox::about( this, tr( "About Tomahawk" ),
tr( "<h2><b>Tomahawk %1<br/>(%2)</h2>Copyright 2010, 2011<br/>Christian Muehlhaeuser &lt;muesli@tomahawk-player.org&gt;<br/><br/>" tr( "<h2><b>Tomahawk %1<br/>(%2)</h2>Copyright 2010, 2011<br/>Christian Muehlhaeuser &lt;muesli@tomahawk-player.org&gt;<br/><br/>"
"Thanks to: Leo Franchi, Jeff Mitchell, Dominik Schmidt, Jason Herskowitz, Alejandro Wainzinger, Michael Zanetti, Harald Sitter and Steve Robertson" ) "Thanks to: Leo Franchi, Jeff Mitchell, Dominik Schmidt, Jason Herskowitz, Alejandro Wainzinger, Hugo Lindström, Michael Zanetti, Harald Sitter and Steve Robertson" )
.arg( TomahawkUtils::appFriendlyVersion() ) .arg( TomahawkUtils::appFriendlyVersion() )
.arg( qApp->applicationVersion() ) ); .arg( qApp->applicationVersion() ) );
} }